Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
# Define the function for sentiment analysis
|
| 4 |
+
def analyze_sentiment(text):
|
| 5 |
+
result = sentiment_pipeline(text)
|
| 6 |
+
return result[0]["label"], result[0]["score"]
|
| 7 |
+
|
| 8 |
+
# Create Gradio Interface
|
| 9 |
+
iface = gr.Interface(
|
| 10 |
+
fn=analyze_sentiment,
|
| 11 |
+
inputs=gr.Textbox(lines=3, placeholder="Enter text here..."),
|
| 12 |
+
outputs=[gr.Text(label="Sentiment"), gr.Text(label="Confidence Score")],
|
| 13 |
+
title="Sentiment Analysis",
|
| 14 |
+
description="Enter a sentence, and the model will predict its sentiment."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
# Launch the Gradio app
|
| 18 |
+
iface.launch()
|