Upload First Demo Files
Browse files- BERT_2_SINGLE_LABELED_GUI.zip +3 -0
- app.py +45 -0
- requirements.txt +4 -0
- symptom_classifier/config.json +144 -0
- symptom_classifier/model.safetensors +3 -0
- symptom_classifier/special_tokens_map.json +7 -0
- symptom_classifier/symptom_list.txt +58 -0
- symptom_classifier/tokenizer.json +0 -0
- symptom_classifier/tokenizer_config.json +56 -0
- symptom_classifier/vocab.txt +0 -0
BERT_2_SINGLE_LABELED_GUI.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2eeb050fabb6cbe9ec021174801ead547fedec0fab47e73a7f4367b9aa405579
|
| 3 |
+
size 358203938
|
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
+
from deep_translator import GoogleTranslator
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
MODEL_DIR = "symptom_classifier"
|
| 7 |
+
|
| 8 |
+
device = torch.device("cpu")
|
| 9 |
+
|
| 10 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR)
|
| 11 |
+
model = AutoModelForSequenceClassification.from_pretrained(MODEL_DIR)
|
| 12 |
+
model.to(device)
|
| 13 |
+
model.eval()
|
| 14 |
+
|
| 15 |
+
translator = GoogleTranslator(source='tr', target='en')
|
| 16 |
+
|
| 17 |
+
def analyze(text):
|
| 18 |
+
text_en = translator.translate(text)
|
| 19 |
+
|
| 20 |
+
inputs = tokenizer(text_en, return_tensors="pt").to(device)
|
| 21 |
+
|
| 22 |
+
with torch.no_grad():
|
| 23 |
+
outputs = model(**inputs)
|
| 24 |
+
probs = torch.nn.functional.softmax(outputs.logits, dim=1)[0]
|
| 25 |
+
|
| 26 |
+
best_idx = torch.argmax(probs).item()
|
| 27 |
+
label = model.config.id2label[best_idx]
|
| 28 |
+
|
| 29 |
+
return label
|
| 30 |
+
|
| 31 |
+
with gr.Blocks() as demo:
|
| 32 |
+
|
| 33 |
+
gr.Markdown("# NeuroSymptom AI")
|
| 34 |
+
gr.Markdown("Türkçe belirti girin, model tahmin yapsın.")
|
| 35 |
+
|
| 36 |
+
input_box = gr.Textbox(label="Türkçe Belirti")
|
| 37 |
+
output_box = gr.Textbox(label="Tahmin")
|
| 38 |
+
|
| 39 |
+
btn = gr.Button("Demo Çalıştır")
|
| 40 |
+
btn.click(analyze, input_box, output_box)
|
| 41 |
+
|
| 42 |
+
gr.Markdown("## Uygulamayı İndir")
|
| 43 |
+
gr.File("BERT_2_SINGLE_LABELED_GUI.zip")
|
| 44 |
+
|
| 45 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
transformers
|
| 3 |
+
deep-translator
|
| 4 |
+
gradio
|
symptom_classifier/config.json
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"dim": 768,
|
| 8 |
+
"dropout": 0.1,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"hidden_dim": 3072,
|
| 11 |
+
"id2label": {
|
| 12 |
+
"0": "headache",
|
| 13 |
+
"1": "dizziness",
|
| 14 |
+
"2": "fatigue",
|
| 15 |
+
"3": "blurred_vision",
|
| 16 |
+
"4": "runny_nose",
|
| 17 |
+
"5": "blocked_nose",
|
| 18 |
+
"6": "itchy_nose",
|
| 19 |
+
"7": "shortness_of_breath",
|
| 20 |
+
"8": "coughing",
|
| 21 |
+
"9": "sneezing",
|
| 22 |
+
"10": "pressure_in_ears",
|
| 23 |
+
"11": "pressure_in_face",
|
| 24 |
+
"12": "low_fever",
|
| 25 |
+
"13": "high_fever",
|
| 26 |
+
"14": "diarrhea",
|
| 27 |
+
"15": "nausea",
|
| 28 |
+
"16": "vomiting",
|
| 29 |
+
"17": "stomach_cramps",
|
| 30 |
+
"18": "stomach_pain",
|
| 31 |
+
"19": "occasional_muscle_ache",
|
| 32 |
+
"20": "sore_throat",
|
| 33 |
+
"21": "chest_tightness",
|
| 34 |
+
"22": "itchy_eyes",
|
| 35 |
+
"23": "watery_eyes",
|
| 36 |
+
"24": "rashes",
|
| 37 |
+
"25": "swelling_of_skin",
|
| 38 |
+
"26": "redness_of_skin",
|
| 39 |
+
"27": "throat_pain",
|
| 40 |
+
"28": "itchy_skin",
|
| 41 |
+
"29": "dry_skin",
|
| 42 |
+
"30": "blisters",
|
| 43 |
+
"31": "dandruff",
|
| 44 |
+
"32": "thickened_skin",
|
| 45 |
+
"33": "raised_bumps_on_skin",
|
| 46 |
+
"34": "blotchy_skin",
|
| 47 |
+
"35": "redness_in_eyes",
|
| 48 |
+
"36": "sensitivity_to_light",
|
| 49 |
+
"37": "swelling_eyes",
|
| 50 |
+
"38": "double_vision",
|
| 51 |
+
"39": "seeing_faded_colors",
|
| 52 |
+
"40": "difficulty_seeing_in_the_dark",
|
| 53 |
+
"41": "constant_weight_loss",
|
| 54 |
+
"42": "pain_or_numbness_at_hands_and_feet",
|
| 55 |
+
"43": "frequent_urination",
|
| 56 |
+
"44": "slow_healing_of_cuts_and_bruises",
|
| 57 |
+
"45": "constant_hunger",
|
| 58 |
+
"46": "burning_skin",
|
| 59 |
+
"47": "constipation",
|
| 60 |
+
"48": "low_back_pain",
|
| 61 |
+
"49": "ear_pain",
|
| 62 |
+
"50": "hearing_loss",
|
| 63 |
+
"51": "melancholy",
|
| 64 |
+
"52": "loss_of_apetite",
|
| 65 |
+
"53": "lack_of_sleep",
|
| 66 |
+
"54": "palpitation",
|
| 67 |
+
"55": "pale_skin",
|
| 68 |
+
"56": "pain_during_urination",
|
| 69 |
+
"57": "groin_pain"
|
| 70 |
+
},
|
| 71 |
+
"initializer_range": 0.02,
|
| 72 |
+
"label2id": {
|
| 73 |
+
"blisters": 30,
|
| 74 |
+
"blocked_nose": 5,
|
| 75 |
+
"blotchy_skin": 34,
|
| 76 |
+
"blurred_vision": 3,
|
| 77 |
+
"burning_skin": 46,
|
| 78 |
+
"chest_tightness": 21,
|
| 79 |
+
"constant_hunger": 45,
|
| 80 |
+
"constant_weight_loss": 41,
|
| 81 |
+
"constipation": 47,
|
| 82 |
+
"coughing": 8,
|
| 83 |
+
"dandruff": 31,
|
| 84 |
+
"diarrhea": 14,
|
| 85 |
+
"difficulty_seeing_in_the_dark": 40,
|
| 86 |
+
"dizziness": 1,
|
| 87 |
+
"double_vision": 38,
|
| 88 |
+
"dry_skin": 29,
|
| 89 |
+
"ear_pain": 49,
|
| 90 |
+
"fatigue": 2,
|
| 91 |
+
"frequent_urination": 43,
|
| 92 |
+
"groin_pain": 57,
|
| 93 |
+
"headache": 0,
|
| 94 |
+
"hearing_loss": 50,
|
| 95 |
+
"high_fever": 13,
|
| 96 |
+
"itchy_eyes": 22,
|
| 97 |
+
"itchy_nose": 6,
|
| 98 |
+
"itchy_skin": 28,
|
| 99 |
+
"lack_of_sleep": 53,
|
| 100 |
+
"loss_of_apetite": 52,
|
| 101 |
+
"low_back_pain": 48,
|
| 102 |
+
"low_fever": 12,
|
| 103 |
+
"melancholy": 51,
|
| 104 |
+
"nausea": 15,
|
| 105 |
+
"occasional_muscle_ache": 19,
|
| 106 |
+
"pain_during_urination": 56,
|
| 107 |
+
"pain_or_numbness_at_hands_and_feet": 42,
|
| 108 |
+
"pale_skin": 55,
|
| 109 |
+
"palpitation": 54,
|
| 110 |
+
"pressure_in_ears": 10,
|
| 111 |
+
"pressure_in_face": 11,
|
| 112 |
+
"raised_bumps_on_skin": 33,
|
| 113 |
+
"rashes": 24,
|
| 114 |
+
"redness_in_eyes": 35,
|
| 115 |
+
"redness_of_skin": 26,
|
| 116 |
+
"runny_nose": 4,
|
| 117 |
+
"seeing_faded_colors": 39,
|
| 118 |
+
"sensitivity_to_light": 36,
|
| 119 |
+
"shortness_of_breath": 7,
|
| 120 |
+
"slow_healing_of_cuts_and_bruises": 44,
|
| 121 |
+
"sneezing": 9,
|
| 122 |
+
"sore_throat": 20,
|
| 123 |
+
"stomach_cramps": 17,
|
| 124 |
+
"stomach_pain": 18,
|
| 125 |
+
"swelling_eyes": 37,
|
| 126 |
+
"swelling_of_skin": 25,
|
| 127 |
+
"thickened_skin": 32,
|
| 128 |
+
"throat_pain": 27,
|
| 129 |
+
"vomiting": 16,
|
| 130 |
+
"watery_eyes": 23
|
| 131 |
+
},
|
| 132 |
+
"max_position_embeddings": 512,
|
| 133 |
+
"model_type": "distilbert",
|
| 134 |
+
"n_heads": 12,
|
| 135 |
+
"n_layers": 6,
|
| 136 |
+
"pad_token_id": 0,
|
| 137 |
+
"problem_type": "single_label_classification",
|
| 138 |
+
"qa_dropout": 0.1,
|
| 139 |
+
"seq_classif_dropout": 0.2,
|
| 140 |
+
"sinusoidal_pos_embds": false,
|
| 141 |
+
"tie_weights_": true,
|
| 142 |
+
"transformers_version": "4.57.1",
|
| 143 |
+
"vocab_size": 30522
|
| 144 |
+
}
|
symptom_classifier/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d62a90324b437a7d298e5c0f007ceb805f5f115acce561d2105e1e9c0f973ef
|
| 3 |
+
size 268004832
|
symptom_classifier/special_tokens_map.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cls_token": "[CLS]",
|
| 3 |
+
"mask_token": "[MASK]",
|
| 4 |
+
"pad_token": "[PAD]",
|
| 5 |
+
"sep_token": "[SEP]",
|
| 6 |
+
"unk_token": "[UNK]"
|
| 7 |
+
}
|
symptom_classifier/symptom_list.txt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
headache
|
| 2 |
+
dizziness
|
| 3 |
+
fatigue
|
| 4 |
+
blurred_vision
|
| 5 |
+
runny_nose
|
| 6 |
+
blocked_nose
|
| 7 |
+
itchy_nose
|
| 8 |
+
shortness_of_breath
|
| 9 |
+
coughing
|
| 10 |
+
sneezing
|
| 11 |
+
pressure_in_ears
|
| 12 |
+
pressure_in_face
|
| 13 |
+
low_fever
|
| 14 |
+
high_fever
|
| 15 |
+
diarrhea
|
| 16 |
+
nausea
|
| 17 |
+
vomiting
|
| 18 |
+
stomach_cramps
|
| 19 |
+
stomach_pain
|
| 20 |
+
occasional_muscle_ache
|
| 21 |
+
sore_throat
|
| 22 |
+
chest_tightness
|
| 23 |
+
itchy_eyes
|
| 24 |
+
watery_eyes
|
| 25 |
+
rashes
|
| 26 |
+
swelling_of_skin
|
| 27 |
+
redness_of_skin
|
| 28 |
+
throat_pain
|
| 29 |
+
itchy_skin
|
| 30 |
+
dry_skin
|
| 31 |
+
blisters
|
| 32 |
+
dandruff
|
| 33 |
+
thickened_skin
|
| 34 |
+
raised_bumps_on_skin
|
| 35 |
+
blotchy_skin
|
| 36 |
+
redness_in_eyes
|
| 37 |
+
sensitivity_to_light
|
| 38 |
+
swelling_eyes
|
| 39 |
+
double_vision
|
| 40 |
+
seeing_faded_colors
|
| 41 |
+
difficulty_seeing_in_the_dark
|
| 42 |
+
constant_weight_loss
|
| 43 |
+
pain_or_numbness_at_hands_and_feet
|
| 44 |
+
frequent_urination
|
| 45 |
+
slow_healing_of_cuts_and_bruises
|
| 46 |
+
constant_hunger
|
| 47 |
+
burning_skin
|
| 48 |
+
constipation
|
| 49 |
+
low_back_pain
|
| 50 |
+
ear_pain
|
| 51 |
+
hearing_loss
|
| 52 |
+
melancholy
|
| 53 |
+
loss_of_apetite
|
| 54 |
+
lack_of_sleep
|
| 55 |
+
palpitation
|
| 56 |
+
pale_skin
|
| 57 |
+
pain_during_urination
|
| 58 |
+
groin_pain
|
symptom_classifier/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
symptom_classifier/tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"100": {
|
| 12 |
+
"content": "[UNK]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"101": {
|
| 20 |
+
"content": "[CLS]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"102": {
|
| 28 |
+
"content": "[SEP]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": false,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"103": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"clean_up_tokenization_spaces": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": true,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
symptom_classifier/vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|