File size: 764 Bytes
1a0842b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c262133
1a0842b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from transformers import pipeline

senti_pipeline = pipeline("sentiment-analysis")



app_inputs = gr.inputs.Textbox(lines=2, placeholder="Enter title here...")

def res(app_inputs):
  result= senti_pipeline(app_inputs)
  sentiment_label = result[0]['label']
  sentiment_score = result[0]['score']

  formatted_output = f"This sentiment is {sentiment_label} with the probability {sentiment_score*100:.2f}%"
  return formatted_output

interface = gr.Interface(fn=res, 
                        inputs=app_inputs,
                         outputs=gr.outputs.Textbox(label="Sentiment Analysis Result"),
         title="Sup, I'm a Sentiment Analyzer Babe",
    description="Enter a text and see the sentiment analysis result!")

interface.launch()