Spaces:
Sleeping
Sleeping
File size: 875 Bytes
450e96e 1e1c342 450e96e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import pipeline
# Load pre-trained models
emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
severity_model = pipeline("text-classification", model="bhadresh-savani/bert-base-uncased-emotion")
dialog_model = pipeline("text-generation", model="microsoft/DialoGPT-medium")
def chatbot(user_input):
emotion = emotion_model(user_input)[0]['label']
severity = severity_model(user_input)[0]['label']
reply = dialog_model(user_input, max_length=50, num_return_sequences=1)[0]['generated_text']
return f"Emotion: {emotion}\nSeverity: {severity}\nBot Reply: {reply}"
iface = gr.Interface(
fn=chatbot,
inputs="text",
outputs="text",
title="Mental Health Bot",
description="Detects emotion & severity, then replies with supportive text."
)
iface.launch()
|