Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the DistilBERT model for mental health prediction
|
5 |
+
classifier = pipeline("text-classification", model="AventIQ-AI/distilbert-mental-health-prediction")
|
6 |
+
|
7 |
+
def predict_mental_health(text):
|
8 |
+
result = classifier(text)
|
9 |
+
return f"Prediction: {result[0]['label']}\nConfidence: {result[0]['score']:.2f}"
|
10 |
+
|
11 |
+
# Create Gradio interface
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=predict_mental_health,
|
14 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter text describing feelings or thoughts..."),
|
15 |
+
outputs=gr.Textbox(label="Mental Health Prediction"),
|
16 |
+
title="Mental Health Condition Predictor",
|
17 |
+
description="Analyze text to predict potential mental health conditions using the DistilBERT model fine-tuned by AventIQ.",
|
18 |
+
)
|
19 |
+
|
20 |
+
# Launch the app
|
21 |
+
if __name__ == "__main__":
|
22 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
sentencepiece
|
4 |
+
gradio
|