quocviethere
commited on
Commit
•
90cad01
1
Parent(s):
4c34000
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Initialize the sentiment analysis pipeline with your model
|
5 |
-
sentiment_pipeline = pipeline("sentiment-analysis", model="
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
result = sentiment_pipeline(text)[0]
|
@@ -12,13 +12,17 @@ def analyze_sentiment(text):
|
|
12 |
confidence = f"Confidence: {round(score * 100, 2)}%"
|
13 |
return sentiment, confidence
|
14 |
|
15 |
-
# Define the Gradio interface
|
16 |
iface = gr.Interface(
|
17 |
fn=analyze_sentiment,
|
18 |
-
inputs=gr.
|
|
|
|
|
|
|
|
|
19 |
outputs=[
|
20 |
-
gr.
|
21 |
-
gr.
|
22 |
],
|
23 |
title="IMDb Sentiment Analysis with RoBERTa",
|
24 |
description="Analyze the sentiment of movie reviews using a fine-tuned RoBERTa model.",
|
@@ -30,4 +34,4 @@ iface = gr.Interface(
|
|
30 |
)
|
31 |
|
32 |
# Launch the interface
|
33 |
-
iface.launch()
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Initialize the sentiment analysis pipeline with your model
|
5 |
+
sentiment_pipeline = pipeline("sentiment-analysis", model="your-username/imdb-roberta")
|
6 |
|
7 |
def analyze_sentiment(text):
|
8 |
result = sentiment_pipeline(text)[0]
|
|
|
12 |
confidence = f"Confidence: {round(score * 100, 2)}%"
|
13 |
return sentiment, confidence
|
14 |
|
15 |
+
# Define the Gradio interface using the updated API
|
16 |
iface = gr.Interface(
|
17 |
fn=analyze_sentiment,
|
18 |
+
inputs=gr.Textbox(
|
19 |
+
lines=5,
|
20 |
+
placeholder="Enter a movie review here...",
|
21 |
+
label="Movie Review"
|
22 |
+
),
|
23 |
outputs=[
|
24 |
+
gr.Textbox(label="Sentiment"),
|
25 |
+
gr.Textbox(label="Confidence")
|
26 |
],
|
27 |
title="IMDb Sentiment Analysis with RoBERTa",
|
28 |
description="Analyze the sentiment of movie reviews using a fine-tuned RoBERTa model.",
|
|
|
34 |
)
|
35 |
|
36 |
# Launch the interface
|
37 |
+
iface.launch()
|