Spaces:
Running
Running
Commit
•
222fb9a
1
Parent(s):
850a521
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
pipe=pipeline('sentiment-analysis','alibidaran/Symptom2disease')
|
4 |
+
label_2id={'Psoriasis': 0,
|
5 |
+
'Varicose Veins': 1,
|
6 |
+
'Typhoid': 2,
|
7 |
+
'Chicken pox': 3,
|
8 |
+
'Impetigo': 4,
|
9 |
+
'Dengue': 5,
|
10 |
+
'Fungal infection': 6,
|
11 |
+
'Common Cold': 7,
|
12 |
+
'Pneumonia': 8,
|
13 |
+
'Dimorphic Hemorrhoids': 9,
|
14 |
+
'Arthritis': 10,
|
15 |
+
'Acne': 11,
|
16 |
+
'Bronchial Asthma': 12,
|
17 |
+
'Hypertension': 13,
|
18 |
+
'Migraine': 14,
|
19 |
+
'Cervical spondylosis': 15,
|
20 |
+
'Jaundice': 16,
|
21 |
+
'Malaria': 17,
|
22 |
+
'urinary tract infection': 18,
|
23 |
+
'allergy': 19,
|
24 |
+
'gastroesophageal reflux disease': 20,
|
25 |
+
'drug reaction': 21,
|
26 |
+
'peptic ulcer disease': 22,
|
27 |
+
'diabetes': 23}
|
28 |
+
id2_label={f'LABEL_{i}':v for v,i in label_2id.items()}
|
29 |
+
def detect_symptom(symptoms):
|
30 |
+
output=pipe(symptoms)[0]
|
31 |
+
label=id2_label[output['label']]
|
32 |
+
return f"You have {label} disease."
|
33 |
+
|
34 |
+
demo=gr.Interface(fn=detect_symptom,inputs='text',outputs='label')
|
35 |
+
demo.launch()
|