Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,47 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
40 |
title=title,
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
if __name__ == "__main__":
|
46 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
model_checkpoint = "MuntasirHossain/RoBERTa-base-finetuned-emotion"
|
5 |
+
emotion_model = pipeline("text-classification", model=model_checkpoint)
|
6 |
+
|
7 |
+
def classify_emotion(text):
|
8 |
+
label = emotion_model(text)[0]["label"]
|
9 |
+
return label
|
10 |
+
|
11 |
+
description = "This AI model is trained to classify texts expressing human emotion into different categories."
|
12 |
+
title = "Texts Expressing Emotion"
|
13 |
+
examples = [["He is very happy today", "Free Palestine"]]
|
14 |
+
|
15 |
+
theme = {
|
16 |
+
"container": {
|
17 |
+
"background-color": "#007bff",
|
18 |
+
"color": "#fff",
|
19 |
+
"padding": "20px",
|
20 |
+
},
|
21 |
+
"textbox": {
|
22 |
+
"background-color": "#fff",
|
23 |
+
"border-radius": "5px",
|
24 |
+
"padding": "10px",
|
25 |
+
"margin-bottom": "10px",
|
26 |
+
},
|
27 |
+
"button": {
|
28 |
+
"background-color": "#007bff",
|
29 |
+
"color": "#fff",
|
30 |
+
"padding": "10px",
|
31 |
+
"border-radius": "5px",
|
32 |
+
"cursor": "pointer",
|
33 |
+
},
|
34 |
+
"label": {
|
35 |
+
"color": "#fff",
|
36 |
+
},
|
37 |
+
}
|
38 |
+
|
39 |
+
gr.Interface(
|
40 |
+
fn=classify_emotion,
|
41 |
+
inputs="textbox",
|
42 |
+
outputs="text",
|
43 |
title=title,
|
44 |
+
theme=theme,
|
45 |
+
description=description,
|
46 |
+
examples=examples,
|
47 |
+
).launch()
|
|
|
|