i0xs0's picture
Update app.py
de3e019 verified
raw
history blame
659 Bytes
import gradio as gr
from transformers import pipeline
import os
model = pipeline("text-classification", model="i0xs0/Emotion_Detection", tokenizer="i0xs0/Emotion_Detection")
def predict_emotion(text):
results = model(text)
return {item["label"]: item["score"] for item in results}
#theme = gr.themes.Ocean()
theme = gr.themes.Glass()
demo = gr.Interface(
fn=predict_emotion,
inputs=gr.Textbox(label="Input Text"),
outputs=gr.Label(label="Emotion"),
title="Emotion Classifier",
description="Enter a text to classify its emotion.",
allow_flagging="never",
theme=theme
)
demo.launch()