nadzo commited on
Commit
228b0be
·
verified ·
1 Parent(s): 9af37ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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"Label: {result['label']}, Score: {result['score']:.2f}"
9
 
10
- gr.Interface(fn=analyze, inputs="text", outputs="text").launch()
 
 
 
 
 
 
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()