File size: 554 Bytes
3330503
06badbc
 
81f670d
3330503
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Use a pipeline as a high-level helper
from transformers import pipeline, Conversation
import gradio as gr
pipe = pipeline("text-classification", model="Junr-syl/sentiments_analysis_DISTILBERT")
def my_function(text):
  out = pipe(text)
  out = out[0]["label"] # cleaning the output
  return out

with gr.Blocks() as demo :
  input_componenet = gr.Text("i love AI",label="input")
  output_componenet = gr.Text(label="output")
  submit = gr.Button("submit")
  submit.click(my_function,inputs=[input_componenet],outputs=[output_componenet])

demo.launch()