@@ -219,7 +219,7 @@ pipelines.
219
219
<!-- TODO : update with better (final) example -->
220
220
221
221
` ` ` yaml
222
- https://github.com/explosion/spacy-boilerplates/blob/master/ner_fashion /project.yml
222
+ https://github.com/explosion/projects/tree/v3/tutorials/ner_fashion_brands /project.yml
223
223
` ` `
224
224
225
225
| Section | Description |
@@ -815,8 +815,10 @@ package helps you integrate spaCy visualizations into your Streamlit apps and
815
815
quickly spin up demos to explore your pipelines interactively. It includes a
816
816
full embedded visualizer, as well as individual components.
817
817
818
+ <!-- TODO : update once version is stable -->
819
+
818
820
` ` ` bash
819
- $ pip install spacy_streamlit
821
+ $ pip install " spacy_streamlit>=1.0.0a0"
820
822
` ` `
821
823
822
824
</div>
@@ -828,22 +830,15 @@ $ pip install spacy_streamlit
828
830
Using [`spacy-streamlit`](https://github.com/explosion/spacy-streamlit), your
829
831
projects can easily define their own scripts that spin up an interactive
830
832
visualizer, using the latest pipeline you trained, or a selection of pipelines
831
- so you can compare their results. The following script starts an
832
- [NER visualizer](/usage/visualizers#ent) and takes two positional command-line
833
- argument you can pass in from your `config.yml` : a comma-separated list of paths
834
- to load the pipelines from and an example text to use as the default text.
833
+ so you can compare their results.
835
834
836
- <!-- TODO : replace with embed -- >
835
+ <Project id="integrations/streamlit" >
837
836
838
- ` ` ` python
839
- ### scripts/visualize.py
840
- import spacy_streamlit
841
- import sys
837
+ Get started with spaCy and Streamlit using our project template. It includes a
838
+ script to spin up a custom visualizer and commands you can adjust to showcase
839
+ and explore your own custom trained pipelines.
842
840
843
- DEFAULT_TEXT = sys.argv[2] if len(sys.argv) >= 3 else ""
844
- PIPELINES = [name.strip() for name in sys.argv[1].split(",")]
845
- spacy_streamlit.visualize(PIPELINES, DEFAULT_TEXT, visualizers=["ner"])
846
- ` ` `
841
+ </Project>
847
842
848
843
> # ### Example usage
849
844
>
@@ -860,16 +855,16 @@ commands:
860
855
script:
861
856
- 'streamlit run ./scripts/visualize.py ./training/model-best "I like Adidas shoes."'
862
857
deps:
863
- - ' training/model-best'
858
+ - " training/model-best"
864
859
` ` `
865
860
866
- <Project id="integrations/streamlit">
861
+ The following script is called from the `project.yml` and takes two positional
862
+ command-line argument : a comma-separated list of paths or packages to load the
863
+ pipelines from and an example text to use as the default text.
867
864
868
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum
869
- sodales lectus, ut sodales orci ullamcorper id. Sed condimentum neque ut erat
870
- mattis pretium.
871
-
872
- </Project>
865
+ ` ` ` python
866
+ https://github.com/explosion/projects/blob/v3/integrations/streamlit/scripts/visualize.py
867
+ ` ` `
873
868
874
869
---
875
870
@@ -882,9 +877,11 @@ library for serving machine learning models and you can use it in your spaCy
882
877
projects to quickly serve up a trained pipeline and make it available behind a
883
878
REST API.
884
879
885
- ` ` ` python
886
- # TODO: show an example that addresses some of the main concerns for serving ML (workers etc.)
887
- ` ` `
880
+ <Project id="integrations/fastapi">
881
+
882
+ Get started with spaCy and FastAPI using our project template.
883
+
884
+ </Project>
888
885
889
886
> # ### Example usage
890
887
>
@@ -895,23 +892,24 @@ REST API.
895
892
<!-- prettier-ignore -->
896
893
` ` ` yaml
897
894
### project.yml
898
- commands:
899
- - name: serve
900
- help: "Serve the trained pipeline with FastAPI"
895
+ - name: "serve"
896
+ help: "Serve the models via a FastAPI REST API using the given host and port"
901
897
script:
902
- - 'python ./ scripts/serve.py ./training/model-best'
898
+ - "uvicorn scripts.main:app --reload --host 127.0.0.1 --port 5000"
903
899
deps:
904
- - 'training/model-best'
900
+ - "scripts/main.py"
905
901
no_skip: true
906
902
` ` `
907
903
908
- <Project id="integrations/fastapi">
904
+ The script included in the template shows a simple REST API with a `POST`
905
+ endpoint that accepts batches of texts and returns batches of predictions, e.g.
906
+ named entities found in the documents. Type hints and
907
+ [`pydantic`](https://github.com/samuelcolvin/pydantic) are used to define the
908
+ expected data types.
909
909
910
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum
911
- sodales lectus, ut sodales orci ullamcorper id. Sed condimentum neque ut erat
912
- mattis pretium.
913
-
914
- </Project>
910
+ ` ` ` python
911
+ https://github.com/explosion/projects/blob/v3/integrations/fastapi/scripts/main.py
912
+ ` ` `
915
913
916
914
---
917
915
0 commit comments