i0xs0 commited on
Commit
bd7036e
·
verified ·
1 Parent(s): 9f8df19

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load your pre-trained model
5
+ model = pipeline("text-classification", model="i0xs0/Text_Classifiction", tokenizer="i0xs0/Text_Classifiction")
6
+
7
+
8
+ def predict_emotion(text):
9
+
10
+ results = model(text)
11
+ return {item["label"]: item["score"] for item in results}
12
+
13
+
14
+ theme = gr.themes.Ocean()
15
+
16
+ demo = gr.Interface(
17
+ fn=predict_emotion,
18
+ inputs=gr.Textbox(label="Input Text"),
19
+ outputs=gr.Label(label="Emotion"),
20
+ title="Emotion Classifier",
21
+ description="Enter a text to classify its emotion.",
22
+ allow_flagging="never",
23
+
24
+ theme=theme
25
+ )
26
+
27
+
28
+ demo.launch()