Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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)
|