Commit
·
5b95e34
1
Parent(s):
5b08525
fix: Errors and warnings
Browse files- app.py +5 -2
- requirements.txt +28 -2
app.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
"""Gradio app that showcases Danish offensive text models."""
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from transformers import pipeline
|
| 5 |
from shap import Explainer
|
|
@@ -7,6 +10,7 @@ import numpy as np
|
|
| 7 |
|
| 8 |
|
| 9 |
def main():
|
|
|
|
| 10 |
pipe = pipeline(
|
| 11 |
task="text-classification",
|
| 12 |
model="alexandrainst/da-offensive-detection-small",
|
|
@@ -57,7 +61,6 @@ def main():
|
|
| 57 |
start=start,
|
| 58 |
end=end,
|
| 59 |
))
|
| 60 |
-
print(list(zip(words, shap_values)))
|
| 61 |
print(records)
|
| 62 |
|
| 63 |
return ({output["label"]: output["score"]}, dict(text=text, entities=records))
|
|
@@ -66,7 +69,7 @@ def main():
|
|
| 66 |
demo = gr.Interface(
|
| 67 |
fn=classification,
|
| 68 |
inputs=gr.Textbox(placeholder="Enter sentence here...", value=examples[0]),
|
| 69 |
-
outputs=[gr.Label(), gr.HighlightedText(color_map=color_map)],
|
| 70 |
examples=examples,
|
| 71 |
title="Danish Offensive Text Detection",
|
| 72 |
description="""
|
|
|
|
| 1 |
"""Gradio app that showcases Danish offensive text models."""
|
| 2 |
|
| 3 |
+
import warnings
|
| 4 |
+
from numba.core.errors import NumbaDeprecationWarning
|
| 5 |
+
warnings.filterwarnings("ignore", category=NumbaDeprecationWarning)
|
| 6 |
import gradio as gr
|
| 7 |
from transformers import pipeline
|
| 8 |
from shap import Explainer
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def main():
|
| 13 |
+
|
| 14 |
pipe = pipeline(
|
| 15 |
task="text-classification",
|
| 16 |
model="alexandrainst/da-offensive-detection-small",
|
|
|
|
| 61 |
start=start,
|
| 62 |
end=end,
|
| 63 |
))
|
|
|
|
| 64 |
print(records)
|
| 65 |
|
| 66 |
return ({output["label"]: output["score"]}, dict(text=text, entities=records))
|
|
|
|
| 69 |
demo = gr.Interface(
|
| 70 |
fn=classification,
|
| 71 |
inputs=gr.Textbox(placeholder="Enter sentence here...", value=examples[0]),
|
| 72 |
+
outputs=[gr.Label(), gr.HighlightedText().style(color_map=color_map)],
|
| 73 |
examples=examples,
|
| 74 |
title="Danish Offensive Text Detection",
|
| 75 |
description="""
|
requirements.txt
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
|
|
| 1 |
aiohttp==3.8.3
|
| 2 |
aiosignal==1.3.1
|
|
|
|
| 3 |
anyio==3.6.2
|
|
|
|
|
|
|
| 4 |
async-timeout==4.0.2
|
| 5 |
attrs==22.1.0
|
|
|
|
| 6 |
bcrypt==4.0.1
|
| 7 |
beautifulsoup4==4.11.1
|
| 8 |
certifi==2022.9.24
|
|
@@ -13,6 +18,9 @@ cloudpickle==2.2.1
|
|
| 13 |
contourpy==1.0.6
|
| 14 |
cryptography==38.0.4
|
| 15 |
cycler==0.11.0
|
|
|
|
|
|
|
|
|
|
| 16 |
fastapi==0.88.0
|
| 17 |
fasttext-wheel==0.9.2
|
| 18 |
ffmpy==0.3.0
|
|
@@ -21,14 +29,18 @@ fonttools==4.38.0
|
|
| 21 |
frozenlist==1.3.3
|
| 22 |
fsspec==2022.11.0
|
| 23 |
gdown==4.5.4
|
| 24 |
-
gradio==3.
|
|
|
|
| 25 |
h11==0.12.0
|
| 26 |
httpcore==0.15.0
|
| 27 |
httpx==0.23.1
|
| 28 |
-
huggingface-hub==0.
|
| 29 |
idna==3.4
|
|
|
|
|
|
|
| 30 |
Jinja2==3.1.2
|
| 31 |
joblib==1.2.0
|
|
|
|
| 32 |
kiwisolver==1.4.4
|
| 33 |
linkify-it-py==1.0.3
|
| 34 |
llvmlite==0.40.0
|
|
@@ -36,6 +48,7 @@ luga==0.2.6
|
|
| 36 |
markdown-it-py==2.1.0
|
| 37 |
MarkupSafe==2.1.1
|
| 38 |
matplotlib==3.6.2
|
|
|
|
| 39 |
mdit-py-plugins==0.3.1
|
| 40 |
mdurl==0.1.2
|
| 41 |
mpmath==1.3.0
|
|
@@ -48,14 +61,22 @@ orjson==3.8.2
|
|
| 48 |
packaging==21.3
|
| 49 |
pandas==1.5.2
|
| 50 |
paramiko==2.12.0
|
|
|
|
|
|
|
|
|
|
| 51 |
Pillow==9.3.0
|
|
|
|
|
|
|
|
|
|
| 52 |
pybind11==2.10.1
|
| 53 |
pycparser==2.21
|
| 54 |
pycryptodome==3.16.0
|
| 55 |
pydantic==1.10.2
|
| 56 |
pydub==0.25.1
|
|
|
|
| 57 |
PyNaCl==1.5.0
|
| 58 |
pyparsing==3.0.9
|
|
|
|
| 59 |
PySocks==1.7.1
|
| 60 |
python-dateutil==2.8.2
|
| 61 |
python-multipart==0.0.5
|
|
@@ -66,22 +87,27 @@ requests==2.28.1
|
|
| 66 |
rfc3986==1.5.0
|
| 67 |
scikit-learn==1.2.2
|
| 68 |
scipy==1.10.1
|
|
|
|
| 69 |
shap==0.41.0
|
| 70 |
six==1.16.0
|
| 71 |
slicer==0.0.7
|
| 72 |
sniffio==1.3.0
|
| 73 |
soupsieve==2.3.2.post1
|
|
|
|
| 74 |
starlette==0.22.0
|
| 75 |
sympy==1.11.1
|
| 76 |
threadpoolctl==3.1.0
|
| 77 |
tokenizers==0.13.2
|
|
|
|
| 78 |
torch==2.0.0
|
| 79 |
tqdm==4.64.1
|
|
|
|
| 80 |
transformers==4.28.1
|
| 81 |
typing_extensions==4.4.0
|
| 82 |
typish==1.9.3
|
| 83 |
uc-micro-py==1.0.1
|
| 84 |
urllib3==1.26.13
|
| 85 |
uvicorn==0.20.0
|
|
|
|
| 86 |
websockets==10.4
|
| 87 |
yarl==1.8.1
|
|
|
|
| 1 |
+
aiofiles==23.1.0
|
| 2 |
aiohttp==3.8.3
|
| 3 |
aiosignal==1.3.1
|
| 4 |
+
altair==4.2.2
|
| 5 |
anyio==3.6.2
|
| 6 |
+
appnope==0.1.3
|
| 7 |
+
asttokens==2.2.1
|
| 8 |
async-timeout==4.0.2
|
| 9 |
attrs==22.1.0
|
| 10 |
+
backcall==0.2.0
|
| 11 |
bcrypt==4.0.1
|
| 12 |
beautifulsoup4==4.11.1
|
| 13 |
certifi==2022.9.24
|
|
|
|
| 18 |
contourpy==1.0.6
|
| 19 |
cryptography==38.0.4
|
| 20 |
cycler==0.11.0
|
| 21 |
+
decorator==5.1.1
|
| 22 |
+
entrypoints==0.4
|
| 23 |
+
executing==1.2.0
|
| 24 |
fastapi==0.88.0
|
| 25 |
fasttext-wheel==0.9.2
|
| 26 |
ffmpy==0.3.0
|
|
|
|
| 29 |
frozenlist==1.3.3
|
| 30 |
fsspec==2022.11.0
|
| 31 |
gdown==4.5.4
|
| 32 |
+
gradio==3.28.3
|
| 33 |
+
gradio_client==0.1.4
|
| 34 |
h11==0.12.0
|
| 35 |
httpcore==0.15.0
|
| 36 |
httpx==0.23.1
|
| 37 |
+
huggingface-hub==0.14.1
|
| 38 |
idna==3.4
|
| 39 |
+
ipython==8.13.2
|
| 40 |
+
jedi==0.18.2
|
| 41 |
Jinja2==3.1.2
|
| 42 |
joblib==1.2.0
|
| 43 |
+
jsonschema==4.17.3
|
| 44 |
kiwisolver==1.4.4
|
| 45 |
linkify-it-py==1.0.3
|
| 46 |
llvmlite==0.40.0
|
|
|
|
| 48 |
markdown-it-py==2.1.0
|
| 49 |
MarkupSafe==2.1.1
|
| 50 |
matplotlib==3.6.2
|
| 51 |
+
matplotlib-inline==0.1.6
|
| 52 |
mdit-py-plugins==0.3.1
|
| 53 |
mdurl==0.1.2
|
| 54 |
mpmath==1.3.0
|
|
|
|
| 61 |
packaging==21.3
|
| 62 |
pandas==1.5.2
|
| 63 |
paramiko==2.12.0
|
| 64 |
+
parso==0.8.3
|
| 65 |
+
pexpect==4.8.0
|
| 66 |
+
pickleshare==0.7.5
|
| 67 |
Pillow==9.3.0
|
| 68 |
+
prompt-toolkit==3.0.38
|
| 69 |
+
ptyprocess==0.7.0
|
| 70 |
+
pure-eval==0.2.2
|
| 71 |
pybind11==2.10.1
|
| 72 |
pycparser==2.21
|
| 73 |
pycryptodome==3.16.0
|
| 74 |
pydantic==1.10.2
|
| 75 |
pydub==0.25.1
|
| 76 |
+
Pygments==2.15.1
|
| 77 |
PyNaCl==1.5.0
|
| 78 |
pyparsing==3.0.9
|
| 79 |
+
pyrsistent==0.19.3
|
| 80 |
PySocks==1.7.1
|
| 81 |
python-dateutil==2.8.2
|
| 82 |
python-multipart==0.0.5
|
|
|
|
| 87 |
rfc3986==1.5.0
|
| 88 |
scikit-learn==1.2.2
|
| 89 |
scipy==1.10.1
|
| 90 |
+
semantic-version==2.10.0
|
| 91 |
shap==0.41.0
|
| 92 |
six==1.16.0
|
| 93 |
slicer==0.0.7
|
| 94 |
sniffio==1.3.0
|
| 95 |
soupsieve==2.3.2.post1
|
| 96 |
+
stack-data==0.6.2
|
| 97 |
starlette==0.22.0
|
| 98 |
sympy==1.11.1
|
| 99 |
threadpoolctl==3.1.0
|
| 100 |
tokenizers==0.13.2
|
| 101 |
+
toolz==0.12.0
|
| 102 |
torch==2.0.0
|
| 103 |
tqdm==4.64.1
|
| 104 |
+
traitlets==5.9.0
|
| 105 |
transformers==4.28.1
|
| 106 |
typing_extensions==4.4.0
|
| 107 |
typish==1.9.3
|
| 108 |
uc-micro-py==1.0.1
|
| 109 |
urllib3==1.26.13
|
| 110 |
uvicorn==0.20.0
|
| 111 |
+
wcwidth==0.2.6
|
| 112 |
websockets==10.4
|
| 113 |
yarl==1.8.1
|