Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,10 +10,7 @@ sentiment_model = pipeline("sentiment-analysis", model=model, tokenizer=tokenize
|
|
10 |
# Function for Gradio
|
11 |
def analyze_sentiment(text):
|
12 |
result = sentiment_model(text)[0]
|
13 |
-
return {
|
14 |
-
"Sentiment": result["label"],
|
15 |
-
"Confidence": f"{result['score']:.2f}"
|
16 |
-
}
|
17 |
|
18 |
# Example texts
|
19 |
examples = [
|
@@ -26,11 +23,11 @@ examples = [
|
|
26 |
demo = gr.Interface(
|
27 |
fn=analyze_sentiment,
|
28 |
inputs=gr.Textbox(lines=3, placeholder="Type a sentence here..."),
|
29 |
-
outputs="
|
30 |
examples=examples,
|
31 |
title="Tweet Sentiment Analyzer",
|
32 |
-
description=""
|
33 |
)
|
34 |
|
35 |
-
if
|
36 |
-
demo.launch()
|
|
|
10 |
# Function for Gradio
|
11 |
def analyze_sentiment(text):
|
12 |
result = sentiment_model(text)[0]
|
13 |
+
return f"Sentiment: {result['label']} | Confidence: {result['score']:.2f}"
|
|
|
|
|
|
|
14 |
|
15 |
# Example texts
|
16 |
examples = [
|
|
|
23 |
demo = gr.Interface(
|
24 |
fn=analyze_sentiment,
|
25 |
inputs=gr.Textbox(lines=3, placeholder="Type a sentence here..."),
|
26 |
+
outputs="text",
|
27 |
examples=examples,
|
28 |
title="Tweet Sentiment Analyzer",
|
29 |
+
description="A simple Hugging Face Space to analyze sentiment in tweets using CardiffNLP's RoBERTa model."
|
30 |
)
|
31 |
|
32 |
+
if __name__ == "__main__":
|
33 |
+
demo.launch()
|