Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 5 |
|
| 6 |
def analyze(text):
|
| 7 |
result = sentiment_pipeline(text)[0]
|
| 8 |
-
return f"
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load sentiment analysis model
|
| 5 |
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 6 |
|
| 7 |
def analyze(text):
|
| 8 |
result = sentiment_pipeline(text)[0]
|
| 9 |
+
return f"{result['label']} (Confidence: {result['score']:.2f})"
|
| 10 |
|
| 11 |
+
# Create Gradio interface
|
| 12 |
+
gr.Interface(
|
| 13 |
+
fn=analyze,
|
| 14 |
+
inputs=gr.Textbox(placeholder="Enter crypto news headline..."),
|
| 15 |
+
outputs="text"
|
| 16 |
+
).launch()
|