Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from model import EmotionModel, SuicidalIntentModel | |
| from utils import calculate_distress | |
| emotion_model = EmotionModel() | |
| suicide_model = SuicidalIntentModel() | |
| def analyze(text): | |
| emotions = emotion_model.predict(text) | |
| suicide_risk = suicide_model.predict(text) | |
| distress = calculate_distress(emotions, suicide_risk) | |
| return { | |
| "emotions": emotions, | |
| "suicidal_risk": round(suicide_risk, 2), | |
| "distress_score": distress | |
| } | |
| app = gr.Interface( | |
| fn=analyze, | |
| inputs=gr.Textbox(label="Enter journal text"), | |
| outputs="json", | |
| title="Emotion + Distress + Suicide Risk Analyzer" | |
| ) | |
| app.launch(share=True) | |