Spaces:
Sleeping
Sleeping
ireneminhee
commited on
Upload 3 files
Browse files- app.py +1 -0
- model.zip +3 -0
- 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
|