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