coldnasser commited on
Commit
b5825cb
·
1 Parent(s): 77fe516

Upload Gradio app for mental health analysis

Browse files
Files changed (1) hide show
  1. app.py +23 -10
app.py CHANGED
@@ -1,17 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load your model from Hugging Face
5
  classifier = pipeline("text-classification", model="coldnasser/depression-anxiety-mindscape")
6
 
7
- # Define the prediction function
8
  def predict(text):
9
- return classifier(text)
 
 
 
10
 
11
- # Create the Gradio interface
12
- gr.Interface(
13
- fn=predict,
14
- inputs="text",
15
- outputs="label",
16
- title="Mindscape AI Therapist"
17
- ).launch()
 
1
+ # import gradio as gr
2
+ # from transformers import pipeline
3
+
4
+ # # Load your model from Hugging Face
5
+ # classifier = pipeline("text-classification", model="coldnasser/depression-anxiety-mindscape")
6
+
7
+ # # Define the prediction function
8
+ # def predict(text):
9
+ # return classifier(text)
10
+
11
+ # # Create the Gradio interface
12
+ # gr.Interface(
13
+ # fn=predict,
14
+ # inputs="text",
15
+ # outputs="label",
16
+ # title="Mindscape AI Therapist"
17
+ # ).launch()
18
+
19
  import gradio as gr
20
  from transformers import pipeline
21
 
 
22
  classifier = pipeline("text-classification", model="coldnasser/depression-anxiety-mindscape")
23
 
 
24
  def predict(text):
25
+ try:
26
+ return classifier(text)
27
+ except Exception as e:
28
+ return f"Error: {str(e)}"
29
 
30
+ gr.Interface(fn=predict, inputs="text", outputs="text", title="Mindscape").launch()