Spaces:
Runtime error
Runtime error
Commit
·
28dfd94
1
Parent(s):
4de44f5
Working locally
Browse files- app.py +5 -1
- requirements.txt +170 -1
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
def process_swedish_text(text):
|
| 5 |
# Models from https://huggingface.co/models
|
|
@@ -9,8 +10,11 @@ def process_swedish_text(text):
|
|
| 9 |
# Run NER
|
| 10 |
pipeline_results = ner_pipeline(text)
|
| 11 |
print('NER results:', pipeline_results)
|
|
|
|
|
|
|
|
|
|
| 12 |
# Return values
|
| 13 |
-
return
|
| 14 |
|
| 15 |
gradio_interface = gr.Interface(fn=process_swedish_text, inputs="text", outputs="json")
|
| 16 |
gradio_interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
+
import json
|
| 4 |
|
| 5 |
def process_swedish_text(text):
|
| 6 |
# Models from https://huggingface.co/models
|
|
|
|
| 10 |
# Run NER
|
| 11 |
pipeline_results = ner_pipeline(text)
|
| 12 |
print('NER results:', pipeline_results)
|
| 13 |
+
# Fix TypeError("'numpy.float32' object is not iterable")
|
| 14 |
+
pipeline_results_adjusted = map(lambda entity: entity | { 'score': float(entity['score']) }, pipeline_results)
|
| 15 |
+
print(pipeline_results_adjusted)
|
| 16 |
# Return values
|
| 17 |
+
return json.dumps({'entities': list(pipeline_results_adjusted)})
|
| 18 |
|
| 19 |
gradio_interface = gr.Interface(fn=process_swedish_text, inputs="text", outputs="json")
|
| 20 |
gradio_interface.launch()
|
requirements.txt
CHANGED
|
@@ -1 +1,170 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
async-timeout==4.0.2
|
| 9 |
+
attrs==22.1.0
|
| 10 |
+
Babel==2.10.3
|
| 11 |
+
backcall==0.2.0
|
| 12 |
+
bcrypt==4.0.1
|
| 13 |
+
beautifulsoup4==4.11.1
|
| 14 |
+
bleach==5.0.1
|
| 15 |
+
blis==0.7.9
|
| 16 |
+
catalogue==2.0.8
|
| 17 |
+
certifi==2022.6.15
|
| 18 |
+
cffi==1.15.1
|
| 19 |
+
charset-normalizer==2.1.0
|
| 20 |
+
click==8.1.3
|
| 21 |
+
confection==0.0.3
|
| 22 |
+
contourpy==1.0.5
|
| 23 |
+
cryptography==38.0.4
|
| 24 |
+
cycler==0.11.0
|
| 25 |
+
cymem==2.0.7
|
| 26 |
+
datasets==2.6.1
|
| 27 |
+
debugpy==1.6.3
|
| 28 |
+
decorator==5.1.1
|
| 29 |
+
defusedxml==0.7.1
|
| 30 |
+
dill==0.3.5.1
|
| 31 |
+
entrypoints==0.4
|
| 32 |
+
executing==1.1.1
|
| 33 |
+
fastai==2.7.9
|
| 34 |
+
fastapi==0.88.0
|
| 35 |
+
fastbook==0.0.28
|
| 36 |
+
fastcore==1.5.27
|
| 37 |
+
fastdownload==0.0.7
|
| 38 |
+
fastjsonschema==2.16.2
|
| 39 |
+
fastprogress==1.0.3
|
| 40 |
+
ffmpy==0.3.0
|
| 41 |
+
filelock==3.8.0
|
| 42 |
+
Flask==2.2.2
|
| 43 |
+
fonttools==4.38.0
|
| 44 |
+
frozenlist==1.3.1
|
| 45 |
+
fsspec==2022.10.0
|
| 46 |
+
gradio==3.12.0
|
| 47 |
+
graphviz==0.20.1
|
| 48 |
+
gunicorn==20.1.0
|
| 49 |
+
h11==0.12.0
|
| 50 |
+
httpcore==0.15.0
|
| 51 |
+
httpx==0.23.1
|
| 52 |
+
huggingface-hub==0.10.1
|
| 53 |
+
idna==3.3
|
| 54 |
+
importlib-metadata==5.0.0
|
| 55 |
+
ipykernel==6.16.1
|
| 56 |
+
ipython==8.5.0
|
| 57 |
+
ipython-genutils==0.2.0
|
| 58 |
+
ipywidgets==8.0.2
|
| 59 |
+
itsdangerous==2.1.2
|
| 60 |
+
jedi==0.18.1
|
| 61 |
+
Jinja2==3.1.2
|
| 62 |
+
joblib==1.2.0
|
| 63 |
+
json5==0.9.10
|
| 64 |
+
jsonschema==4.16.0
|
| 65 |
+
jupyter-server==1.21.0
|
| 66 |
+
jupyter_client==7.4.3
|
| 67 |
+
jupyter_core==4.11.2
|
| 68 |
+
jupyterlab-pygments==0.2.2
|
| 69 |
+
jupyterlab-widgets==3.0.3
|
| 70 |
+
jupyterlab_server==2.16.1
|
| 71 |
+
kiwisolver==1.4.4
|
| 72 |
+
langcodes==3.3.0
|
| 73 |
+
linkify-it-py==1.0.3
|
| 74 |
+
markdown-it-py==2.1.0
|
| 75 |
+
MarkupSafe==2.1.1
|
| 76 |
+
matplotlib==3.6.1
|
| 77 |
+
matplotlib-inline==0.1.6
|
| 78 |
+
mdit-py-plugins==0.3.1
|
| 79 |
+
mdurl==0.1.2
|
| 80 |
+
mistune==2.0.4
|
| 81 |
+
multidict==6.0.2
|
| 82 |
+
multiprocess==0.70.13
|
| 83 |
+
murmurhash==1.0.9
|
| 84 |
+
nbclassic==0.4.5
|
| 85 |
+
nbclient==0.7.0
|
| 86 |
+
nbconvert==7.2.2
|
| 87 |
+
nbformat==5.7.0
|
| 88 |
+
nest-asyncio==1.5.6
|
| 89 |
+
notebook==6.5.1
|
| 90 |
+
notebook_shim==0.2.0
|
| 91 |
+
numpy==1.23.4
|
| 92 |
+
orjson==3.8.2
|
| 93 |
+
packaging==21.3
|
| 94 |
+
pandas==1.5.1
|
| 95 |
+
pandocfilters==1.5.0
|
| 96 |
+
paramiko==2.12.0
|
| 97 |
+
parso==0.8.3
|
| 98 |
+
pathy==0.6.2
|
| 99 |
+
pexpect==4.8.0
|
| 100 |
+
pickleshare==0.7.5
|
| 101 |
+
Pillow==9.2.0
|
| 102 |
+
preshed==3.0.8
|
| 103 |
+
prometheus-client==0.15.0
|
| 104 |
+
prompt-toolkit==3.0.31
|
| 105 |
+
psutil==5.9.3
|
| 106 |
+
psycopg2==2.9.5
|
| 107 |
+
ptyprocess==0.7.0
|
| 108 |
+
pure-eval==0.2.2
|
| 109 |
+
pyarrow==9.0.0
|
| 110 |
+
pycparser==2.21
|
| 111 |
+
pycryptodome==3.16.0
|
| 112 |
+
pydantic==1.10.2
|
| 113 |
+
pydub==0.25.1
|
| 114 |
+
Pygments==2.13.0
|
| 115 |
+
PyNaCl==1.5.0
|
| 116 |
+
pyparsing==3.0.9
|
| 117 |
+
pyrsistent==0.18.1
|
| 118 |
+
python-dateutil==2.8.2
|
| 119 |
+
python-dotenv==0.20.0
|
| 120 |
+
python-multipart==0.0.5
|
| 121 |
+
pytz==2022.5
|
| 122 |
+
PyYAML==6.0
|
| 123 |
+
pyzmq==24.0.1
|
| 124 |
+
regex==2022.9.13
|
| 125 |
+
requests==2.28.1
|
| 126 |
+
responses==0.18.0
|
| 127 |
+
rfc3986==1.5.0
|
| 128 |
+
scikit-learn==1.1.2
|
| 129 |
+
scipy==1.9.3
|
| 130 |
+
Send2Trash==1.8.0
|
| 131 |
+
sentencepiece==0.1.97
|
| 132 |
+
six==1.16.0
|
| 133 |
+
smart-open==5.2.1
|
| 134 |
+
sniffio==1.3.0
|
| 135 |
+
soupsieve==2.3.2.post1
|
| 136 |
+
spacy==3.4.2
|
| 137 |
+
spacy-legacy==3.0.10
|
| 138 |
+
spacy-loggers==1.0.3
|
| 139 |
+
srsly==2.4.5
|
| 140 |
+
stack-data==0.5.1
|
| 141 |
+
starlette==0.22.0
|
| 142 |
+
stripe==3.5.0
|
| 143 |
+
terminado==0.16.0
|
| 144 |
+
thinc==8.1.5
|
| 145 |
+
threadpoolctl==3.1.0
|
| 146 |
+
tinycss2==1.2.1
|
| 147 |
+
tokenizers==0.13.1
|
| 148 |
+
tomli==2.0.1
|
| 149 |
+
torch==1.12.1
|
| 150 |
+
torchvision==0.13.1
|
| 151 |
+
tornado==6.2
|
| 152 |
+
tqdm==4.64.1
|
| 153 |
+
traitlets==5.5.0
|
| 154 |
+
transformers==4.23.1
|
| 155 |
+
typer==0.4.2
|
| 156 |
+
typing_extensions==4.4.0
|
| 157 |
+
uc-micro-py==1.0.1
|
| 158 |
+
urllib3==1.26.10
|
| 159 |
+
uvicorn==0.20.0
|
| 160 |
+
wasabi==0.10.1
|
| 161 |
+
wcwidth==0.2.5
|
| 162 |
+
webencodings==0.5.1
|
| 163 |
+
websocket-client==1.4.1
|
| 164 |
+
websockets==10.4
|
| 165 |
+
Werkzeug==2.2.2
|
| 166 |
+
widgetsnbextension==4.0.3
|
| 167 |
+
XlsxWriter==3.0.3
|
| 168 |
+
xxhash==3.1.0
|
| 169 |
+
yarl==1.8.1
|
| 170 |
+
zipp==3.9.0
|