ShahzadSohail commited on
Commit
d438794
·
verified ·
1 Parent(s): 16fe02a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load your model (make sure this is your actual model ID)
5
+ emotion_classifier = pipeline("text-classification", model="ShahzadSohail/emotion_detection_model_final", return_all_scores=True)
6
+
7
+ # Define the function to return prediction
8
+ def predict_emotion(text):
9
+ results = emotion_classifier(text)
10
+ return results
11
+
12
+ # Gradio interface (for UI)
13
+ iface = gr.Interface(fn=predict_emotion, inputs=gr.Textbox(label="Enter Text"), outputs="json")
14
+
15
+ # Enable API mode
16
+ iface.launch(share=False)