CoolFace
Apppublic

ShadowDominator/emotion-classification

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py24 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3 4 5classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", return_all_scores=True)6 7def fn_emotion(text):8    results = classifier(text, padding='max_length', max_length=512)9    return {label['label']: [label['score']] for label in results[0]}10 11 12 13with gr.Blocks(title="Emotion",css="footer {visibility: hidden}") as demo:14    with gr.Row():15        with gr.Column():16            gr.Markdown("## Sentence Emotion")17            with gr.Row():           18                with gr.Column():19                    inputs = gr.TextArea(label="sentence",value=" I am so excited to go on vacation!",interactive=True)20                    btn = gr.Button(value="RUN")21                with gr.Column():22                    output = gr.Label(label="output")23                btn.click(fn=fn_emotion,inputs=[inputs],outputs=[output])24demo.launch()