ireneminhee commited on
Commit
d6c9be2
ยท
verified ยท
1 Parent(s): 520ac92

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +1 -0
  2. model.zip +3 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1 @@
 
 
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOewSj8PHA49VeNmaZxMZGo"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":null,"metadata":{"id":"SPAkgiSviyO0"},"outputs":[],"source":["import gradio as gr\n","import torch\n","from transformers import AutoModelForSequenceClassification, AutoTokenizer\n","\n","# ๋ชจ๋ธ ๊ฒฝ๋กœ ์„ค์ •\n","model_path = \"./model\" # ์—…๋กœ๋“œ๋œ ๋ชจ๋ธ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ\n","\n","# ๋ชจ๋ธ๊ณผ ํ† ํฌ๋‚˜์ด์ € ๋กœ๋“œ\n","model = AutoModelForSequenceClassification.from_pretrained(model_path)\n","tokenizer = AutoTokenizer.from_pretrained(\"klue/bert-base\")\n","\n","# ์˜ˆ์ธก ํ•จ์ˆ˜\n","def predict(text):\n"," inputs = tokenizer(text, return_tensors=\"pt\")\n"," outputs = model(**inputs)\n"," probabilities = torch.sigmoid(outputs.logits)\n"," depression_prob = probabilities[0, 1].item()\n","\n"," if depression_prob > 0.5:\n"," return f\"Depressed (Confidence: {depression_prob:.2%})\"\n"," else:\n"," return f\"Not Depressed (Confidence: {1 - depression_prob:.2%})\"\n","\n","# Gradio ์ธํ„ฐํŽ˜์ด์Šค\n","interface = gr.Interface(\n"," fn=predict,\n"," inputs=gr.Textbox(label=\"Enter your text here\"),\n"," outputs=gr.Textbox(label=\"Result\"),\n"," title=\"Depression Detection\",\n"," description=\"Predict the likelihood of depression based on text input.\",\n",")\n","\n","interface.launch()\n"]}]}
model.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:721fb53d5d3f47fdf1ea3e470eecd088239c31c0b6b274b8d09f14201ca28644
3
+ size 410465546
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch