Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_checkpoint = "MuntasirHossain/RoBERTa-base-finetuned-emotion"
|
5 |
+
model = pipeline("text-classification", model=model_checkpoint)
|
6 |
+
|
7 |
+
def classify(text):
|
8 |
+
label = model(text)[0]["label"]
|
9 |
+
return label
|
10 |
+
|
11 |
+
description = "This AI model is trained to classify texts expressing human emotion into six categories: sadness, joy, love, anger, fear, and surprise."
|
12 |
+
title = "Classify Texts Expressing Emotion"
|
13 |
+
examples = [["This is such a beautiful place"]]
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=classify,
|
17 |
+
inputs=gr.Textbox(),
|
18 |
+
outputs=gr.Label(),
|
19 |
+
title=title,
|
20 |
+
description=description,
|
21 |
+
examples=examples,
|
22 |
+
)
|
23 |
+
|
24 |
+
iface.launch()
|