Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, Conversation
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None)
|
5 |
+
|
6 |
+
def top3_text_classes(message, history):
|
7 |
+
return str(classifier(message)[0][:3]).replace('}, {', '\n').replace('[{', '').replace('}]', '')
|
8 |
+
|
9 |
+
demo_sentiment = gr.ChatInterface(top3_text_classes, title="Text Sentiment Chatbot",
|
10 |
+
description="Enter your text, and the chatbot will classify the sentiment.")
|
11 |
+
|
12 |
+
demo_sentiment.launch()
|