Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
-
|
| 4 |
-
# Load the sentiment-analysis pipeline
|
| 5 |
classifier = pipeline("sentiment-analysis")
|
| 6 |
-
|
| 7 |
-
# Define the function that will process input text
|
| 8 |
def analyze_sentiment(text):
|
| 9 |
return classifier(text)
|
| 10 |
-
|
| 11 |
-
# Set up the Gradio interface with a submit button instead of clear
|
| 12 |
interface = gr.Interface(
|
| 13 |
fn=analyze_sentiment,
|
| 14 |
inputs=gr.Textbox(label="Input Text", placeholder="Enter your text here..."),
|
| 15 |
-
outputs=[gr.Textbox(label="Sentiment Output")],
|
| 16 |
-
live=False,
|
| 17 |
-
title="Sentiment Analysis",
|
| 18 |
description="Enter text to analyze its sentiment. The model will predict whether the sentiment is positive or negative.",
|
| 19 |
-
theme="compact"
|
| 20 |
)
|
| 21 |
|
| 22 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
| 3 |
classifier = pipeline("sentiment-analysis")
|
|
|
|
|
|
|
| 4 |
def analyze_sentiment(text):
|
| 5 |
return classifier(text)
|
|
|
|
|
|
|
| 6 |
interface = gr.Interface(
|
| 7 |
fn=analyze_sentiment,
|
| 8 |
inputs=gr.Textbox(label="Input Text", placeholder="Enter your text here..."),
|
| 9 |
+
outputs=[gr.Textbox(label="Sentiment Output")],
|
| 10 |
+
live=False,
|
| 11 |
+
title="Sentiment Analysis",
|
| 12 |
description="Enter text to analyze its sentiment. The model will predict whether the sentiment is positive or negative.",
|
| 13 |
+
theme="compact"
|
| 14 |
)
|
| 15 |
|
| 16 |
interface.launch()
|