File size: 543 Bytes
d438794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from transformers import pipeline

# Load your model (make sure this is your actual model ID)
emotion_classifier = pipeline("text-classification", model="ShahzadSohail/emotion_detection_model_final", return_all_scores=True)

# Define the function to return prediction
def predict_emotion(text):
    results = emotion_classifier(text)
    return results

# Gradio interface (for UI)
iface = gr.Interface(fn=predict_emotion, inputs=gr.Textbox(label="Enter Text"), outputs="json")

# Enable API mode
iface.launch(share=False)