ananthujay commited on
Commit
efb3a3f
·
1 Parent(s): 214013d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -1,10 +1,13 @@
 
1
  from transformers import pipeline
2
 
3
-
4
  nlp = pipeline("sentiment-analysis")
5
 
6
  def scoring(text):
7
  results = nlp(text)
8
- for result in results:
9
- score = result['score']
10
- return score
 
 
 
 
1
+ import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  nlp = pipeline("sentiment-analysis")
5
 
6
  def scoring(text):
7
  results = nlp(text)
8
+ sentiment = results[0]['label'] # Get the sentiment label (e.g., 'LABEL_1' or 'LABEL_2')
9
+ score = results[0]['score'] # Get the sentiment score
10
+ return f"Sentiment: {sentiment}, Score: {score}"
11
+
12
+ iface = gr.Interface(fn=scoring, inputs="text", outputs="text")
13
+ iface.launch()