Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load
|
5 |
-
|
|
|
6 |
|
|
|
7 |
def predict_sentiment(text):
|
8 |
result = sentiment_pipeline(text)
|
9 |
return result[0]["label"]
|
10 |
|
11 |
-
#
|
12 |
interface = gr.Interface(
|
13 |
fn=predict_sentiment,
|
14 |
inputs="text",
|
15 |
outputs="text",
|
16 |
-
title="Sentiment Analysis
|
17 |
-
description="Enter text
|
18 |
)
|
19 |
|
|
|
20 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the sentiment analysis model
|
5 |
+
model_name = "Jr0hamza/sentiment-analysis-model"
|
6 |
+
sentiment_pipeline = pipeline("text-classification", model=model_name)
|
7 |
|
8 |
+
# Function to predict sentiment
|
9 |
def predict_sentiment(text):
|
10 |
result = sentiment_pipeline(text)
|
11 |
return result[0]["label"]
|
12 |
|
13 |
+
# Gradio Interface
|
14 |
interface = gr.Interface(
|
15 |
fn=predict_sentiment,
|
16 |
inputs="text",
|
17 |
outputs="text",
|
18 |
+
title="Sentiment Analysis",
|
19 |
+
description="Enter text to analyze sentiment (Positive/Negative)."
|
20 |
)
|
21 |
|
22 |
+
# Launch the app
|
23 |
interface.launch()
|