Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the sentiment analysis model
|
5 |
+
classifier = pipeline('sentiment-analysis')
|
6 |
+
|
7 |
+
def sentiment_analysis(text):
|
8 |
+
result = classifier(text)
|
9 |
+
return result[0]['label'], result[0]['score']
|
10 |
+
|
11 |
+
# Create a Gradio interface
|
12 |
+
demo = gr.Interface(fn=sentiment_analysis, inputs="text", outputs=["text", "number"])
|
13 |
+
|
14 |
+
# Launch the Gradio app
|
15 |
+
demo.launch()
|