bish17 commited on
Commit
450e96e
·
1 Parent(s): b13478f

Deploy app with pre-trained models

Browse files
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Pre-trained models from Hugging Face Hub
6
+ emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
7
+ severity_model = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion")
8
+ dialog_model = pipeline("text-generation", model="microsoft/DialoGPT-medium")
9
+
10
+ def chatbot(user_input):
11
+ emotion = emotion_model(user_input)[0]['label']
12
+ severity = severity_model(user_input)[0]['label']
13
+ reply = dialog_model(user_input, max_length=50, num_return_sequences=1)[0]['generated_text']
14
+ return f"Emotion: {emotion}\nSeverity: {severity}\nBot Reply: {reply}"
15
+
16
+ iface = gr.Interface(
17
+ fn=chatbot,
18
+ inputs="text",
19
+ outputs="text",
20
+ title="Mental Health Bot",
21
+ description="Detects emotion & severity, then replies with supportive text."
22
+ )
23
+
24
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers
2
+ gradio
3
+ datasets
4
+ huggingface_hub