Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,25 @@
|
|
1 |
-
#Emotion Detection API using FastAPI
|
2 |
import gradio as gr
|
3 |
-
from model import EmotionModel
|
4 |
from utils import calculate_distress
|
5 |
|
6 |
emotion_model = EmotionModel()
|
|
|
7 |
|
8 |
def analyze(text):
|
9 |
emotions = emotion_model.predict(text)
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
app = gr.Interface(
|
15 |
fn=analyze,
|
16 |
-
inputs=gr.Textbox(),
|
17 |
-
outputs="json"
|
|
|
18 |
)
|
19 |
-
# Launch the app
|
20 |
-
app.launch(share=True)
|
21 |
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from model import EmotionModel, SuicidalIntentModel
|
3 |
from utils import calculate_distress
|
4 |
|
5 |
emotion_model = EmotionModel()
|
6 |
+
suicide_model = SuicidalIntentModel()
|
7 |
|
8 |
def analyze(text):
|
9 |
emotions = emotion_model.predict(text)
|
10 |
+
suicide_risk = suicide_model.predict(text)
|
11 |
+
distress = calculate_distress(emotions, suicide_risk)
|
12 |
+
return {
|
13 |
+
"emotions": emotions,
|
14 |
+
"suicidal_risk": round(suicide_risk, 2),
|
15 |
+
"distress_score": distress
|
16 |
+
}
|
17 |
|
18 |
app = gr.Interface(
|
19 |
fn=analyze,
|
20 |
+
inputs=gr.Textbox(label="Enter journal text"),
|
21 |
+
outputs="json",
|
22 |
+
title="Emotion + Distress + Suicide Risk Analyzer"
|
23 |
)
|
|
|
|
|
24 |
|
25 |
+
app.launch(share=True)
|