Spaces:
Runtime error
Runtime error
danielferreira
commited on
Commit
β’
fef0bcc
1
Parent(s):
08c7df0
Added emotion classification
Browse files- README.md +3 -3
- app.py +19 -3
- requirements.txt +74 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: Emotion Text Classification
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
|
|
1 |
---
|
2 |
title: Emotion Text Classification
|
3 |
+
emoji: π
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: red
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
pinned: false
|
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
pipeline = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion", return_all_scores=True)
|
5 |
+
|
6 |
+
def predict(input_text):
|
7 |
+
preds = pipeline(input_text)
|
8 |
+
pred= preds[0]
|
9 |
+
res = {"Sadness π": pred[0]["score"],
|
10 |
+
"Joy π": pred[1]["score"],
|
11 |
+
"Love π": pred[2]["score"],
|
12 |
+
"Anger π ": pred[3]["score"],
|
13 |
+
"Fear π¨": pred[4]["score"],
|
14 |
+
"Surprise π²": pred[5]["score"],
|
15 |
+
}
|
16 |
+
return res
|
17 |
+
|
18 |
+
iface = gr.Interface(fn = predict,
|
19 |
+
inputs = "text",
|
20 |
+
outputs = gr.outputs.Label(num_top_classes=None, type="auto", label=None),
|
21 |
+
title = 'Sentiment Analysis')
|
22 |
|
|
|
23 |
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
analytics-python==1.4.0
|
2 |
+
backcall==0.2.0
|
3 |
+
backoff==1.10.0
|
4 |
+
bcrypt==3.2.0
|
5 |
+
certifi==2021.10.8
|
6 |
+
cffi==1.15.0
|
7 |
+
charset-normalizer==2.0.8
|
8 |
+
click==8.0.3
|
9 |
+
cryptography==36.0.0
|
10 |
+
cycler==0.11.0
|
11 |
+
debugpy==1.5.1
|
12 |
+
decorator==5.1.0
|
13 |
+
entrypoints==0.3
|
14 |
+
ffmpy==0.3.0
|
15 |
+
filelock==3.4.0
|
16 |
+
Flask==2.0.2
|
17 |
+
Flask-CacheBuster==1.0.0
|
18 |
+
Flask-Cors==3.0.10
|
19 |
+
Flask-Login==0.5.0
|
20 |
+
fonttools==4.28.2
|
21 |
+
gradio==2.4.6
|
22 |
+
huggingface-hub==0.1.2
|
23 |
+
idna==3.3
|
24 |
+
ipykernel==6.5.1
|
25 |
+
ipython==7.30.0
|
26 |
+
itsdangerous==2.0.1
|
27 |
+
jedi==0.18.1
|
28 |
+
Jinja2==3.0.3
|
29 |
+
joblib==1.1.0
|
30 |
+
jupyter-client==7.1.0
|
31 |
+
jupyter-core==4.9.1
|
32 |
+
kiwisolver==1.3.2
|
33 |
+
markdown2==2.4.1
|
34 |
+
MarkupSafe==2.0.1
|
35 |
+
matplotlib==3.5.0
|
36 |
+
matplotlib-inline==0.1.3
|
37 |
+
monotonic==1.6
|
38 |
+
nest-asyncio==1.5.1
|
39 |
+
numpy==1.21.4
|
40 |
+
packaging==21.3
|
41 |
+
pandas==1.3.4
|
42 |
+
paramiko==2.8.1
|
43 |
+
parso==0.8.2
|
44 |
+
pexpect==4.8.0
|
45 |
+
pickleshare==0.7.5
|
46 |
+
Pillow==8.4.0
|
47 |
+
prompt-toolkit==3.0.23
|
48 |
+
ptyprocess==0.7.0
|
49 |
+
pycparser==2.21
|
50 |
+
pycryptodome==3.11.0
|
51 |
+
pydub==0.25.1
|
52 |
+
Pygments==2.10.0
|
53 |
+
PyNaCl==1.4.0
|
54 |
+
pyparsing==3.0.6
|
55 |
+
python-dateutil==2.8.2
|
56 |
+
pytz==2021.3
|
57 |
+
PyYAML==6.0
|
58 |
+
pyzmq==22.3.0
|
59 |
+
regex==2021.11.10
|
60 |
+
requests==2.26.0
|
61 |
+
sacremoses==0.0.46
|
62 |
+
setuptools-scm==6.3.2
|
63 |
+
six==1.16.0
|
64 |
+
tokenizers==0.10.3
|
65 |
+
tomli==1.2.2
|
66 |
+
torch==1.10.0
|
67 |
+
tornado==6.1
|
68 |
+
tqdm==4.62.3
|
69 |
+
traitlets==5.1.1
|
70 |
+
transformers==4.12.5
|
71 |
+
typing-extensions==4.0.0
|
72 |
+
urllib3==1.26.7
|
73 |
+
wcwidth==0.2.5
|
74 |
+
Werkzeug==2.0.2
|