ardavey commited on
Commit
369475e
·
verified ·
1 Parent(s): c5b92f6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the text classification model
5
+ classifier = pipeline('text-classification', model='ardavey/bert-large-depression-classification-model')
6
+
7
+ # Define a function for text classification
8
+ def classify_text(text):
9
+ predictions = classifier([text])
10
+ label = 'Depressed' if predictions[0]['label'] == 'LABEL_1' else 'Not Depressed'
11
+ score = predictions[0]['score']
12
+ return f"Prediction: {label}, Score: {score:.4f}"
13
+
14
+ # Create a Gradio interface
15
+ interface = gr.Interface(
16
+ fn=classify_text,
17
+ inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
18
+ outputs="text",
19
+ title="Depression Text Classifier",
20
+ description="Enter a text sample to check for signs of depression."
21
+ )
22
+
23
+ # Launch the Gradio app
24
+ interface.launch()