import gradio as gr | |
from transformers import pipeline | |
classifier = pipeline("sentiment-analysis") | |
def generate(text): | |
result = classifier(text) | |
return result[0]['label'] | |
examples = [ | |
["SE is the best company in the world!"], | |
["GE is the worst company in the world!"], | |
] | |
demo = gr.Interface( | |
fn=generate, | |
inputs=gr.inputs.Textbox(lines=5, label="Input Text"), | |
outputs=gr.outputs.Textbox(label="Sentiment"), | |
examples=examples | |
) | |
demo.launch() |