File size: 562 Bytes
33d9cec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

distilled_student_sentiment_classifier = pipeline(
    model="lxyuan/distilbert-base-multilingual-cased-sentiments-student", 
    return_all_scores=True
)

def sentiment_analysis(user_query: str):
  result = distilled_student_sentiment_classifier(user_query)[0]
  structured_result = dict()
  for r in result:
    structured_result[r["label"]] = r["score"]
  return structured_result

demo = gr.Interface(
    fn = sentiment_analysis,
    inputs = [gr.Textbox()],
    outputs = [gr.Label()]
)

demo.launch()