File size: 669 Bytes
582d4d4
ac0afbc
582d4d4
dd70cec
582d4d4
ac0afbc
dd70cec
582d4d4
 
ac0afbc
 
 
 
 
 
 
dd70cec
582d4d4
 
ac0afbc
 
 
582d4d4
dd70cec
ac0afbc
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
26
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)