deeksonparlma commited on
Commit
e8e1d4e
·
1 Parent(s): 39fafd6

ui changes

Browse files
Files changed (2) hide show
  1. app.py +29 -4
  2. model.ipynb +2 -0
app.py CHANGED
@@ -1,7 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
+
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
+
6
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ # iface.launch()
8
+ # model = AutoModelForSequenceClassification.from_pretrained("tabibu-ai/mental-health-chatbot")
9
+
10
+ # write a gradio interface for tabibu-ai/mental-health-chatbot in huggingfacehub
11
+
12
+ # Path: app.py
13
  import gradio as gr
14
 
15
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
16
+
17
+ tokenizer = AutoTokenizer.from_pretrained("tabibu-ai/mental-health-chatbot")
18
+ model = AutoModelForSequenceClassification.from_pretrained("tabibu-ai/mental-health-chatbot")
19
+
20
+ def classify_text(inp):
21
+ input_ids = tokenizer.encode(inp, return_tensors='pt')
22
+ output = model(input_ids)
23
+ return output.logits.argmax().item()
24
 
25
+ iface = gr.Interface(fn=classify_text, inputs="text", outputs="label",
26
+ interpretation="default", examples=[
27
+ ["I am feeling depressed"],
28
+ ["I am feeling anxious"],
29
+ ["I am feeling stressed"],
30
+ ["I am feeling sad"],
31
+ ])
32
+ iface.launch()
model.ipynb CHANGED
@@ -74,6 +74,8 @@
74
  "\n",
75
  "model.push_to_hub(\"tabibu-ai/mental-health-chatbot\")\n",
76
  "\n",
 
 
77
  "# Step 5: Evaluate the model\n",
78
  "y_pred = model.predict(X_test)\n",
79
  "accuracy = accuracy_score(y_test, y_pred)\n",
 
74
  "\n",
75
  "model.push_to_hub(\"tabibu-ai/mental-health-chatbot\")\n",
76
  "\n",
77
+ "# load model from hub\n",
78
+ "\n",
79
  "# Step 5: Evaluate the model\n",
80
  "y_pred = model.predict(X_test)\n",
81
  "accuracy = accuracy_score(y_test, y_pred)\n",