Spaces:
Sleeping
Sleeping
Commit ·
4d246e5
1
Parent(s): e4f2a3f
updated the error
Browse files
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
# Load sentiment analysis model
|
| 5 |
classifier = pipeline("sentiment-analysis")
|
| 6 |
|
| 7 |
-
|
| 8 |
def analyze_sentiment(text):
|
| 9 |
if not text:
|
| 10 |
return "No input", 0
|
|
@@ -16,7 +15,7 @@ def analyze_sentiment(text):
|
|
| 16 |
except Exception as e:
|
| 17 |
return f"Error: {str(e)}", 0
|
| 18 |
|
| 19 |
-
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=analyze_sentiment,
|
| 22 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
|
@@ -27,6 +26,4 @@ iface = gr.Interface(
|
|
| 27 |
title="Sentiment Analyzer",
|
| 28 |
description="Enter a sentence to get its sentiment (POSITIVE/NEGATIVE) and confidence score."
|
| 29 |
)
|
| 30 |
-
|
| 31 |
-
# Run the app
|
| 32 |
iface.launch()
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
| 4 |
classifier = pipeline("sentiment-analysis")
|
| 5 |
|
| 6 |
+
|
| 7 |
def analyze_sentiment(text):
|
| 8 |
if not text:
|
| 9 |
return "No input", 0
|
|
|
|
| 15 |
except Exception as e:
|
| 16 |
return f"Error: {str(e)}", 0
|
| 17 |
|
| 18 |
+
|
| 19 |
iface = gr.Interface(
|
| 20 |
fn=analyze_sentiment,
|
| 21 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
|
|
|
| 26 |
title="Sentiment Analyzer",
|
| 27 |
description="Enter a sentence to get its sentiment (POSITIVE/NEGATIVE) and confidence score."
|
| 28 |
)
|
|
|
|
|
|
|
| 29 |
iface.launch()
|