File size: 1,125 Bytes
9b8f01f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58ae2ff
c441bd3
34fb333
9b8f01f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
from transformers import pipeline
pipe=pipeline('sentiment-analysis','alibidaran/Symptom2disease')
label_2id={'Psoriasis': 0,
'Varicose Veins': 1,
'Typhoid': 2,
'Chicken pox': 3,
'Impetigo': 4,
'Dengue': 5,
'Fungal infection': 6,
'Common Cold': 7,
'Pneumonia': 8,
'Dimorphic Hemorrhoids': 9,
'Arthritis': 10,
'Acne': 11,
'Bronchial Asthma': 12,
'Hypertension': 13,
'Migraine': 14,
'Cervical spondylosis': 15,
'Jaundice': 16,
'Malaria': 17,
'urinary tract infection': 18,
'allergy': 19,
'gastroesophageal reflux disease': 20,
'drug reaction': 21,
'peptic ulcer disease': 22,
'diabetes': 23}
id2_label={f'LABEL_{i}':v for v,i in label_2id.items()}
def detect_symptom(symptoms):
  output=pipe(symptoms)[0]
  label=id2_label[output['label']]
  return f"You are suffering from {label} disease."
examples = [['Weakness,Stomach pain,Headache,'],['fatigue,Have blurry vision,Have numb or tingling hands or feet,Have very dry skin.'],[' raised red spots'],['sore throat,loss of appetite']]
demo=gr.Interface(fn=detect_symptom,inputs='text',outputs='label',examples=examples,title="MEDICAL DIAGNOSIS")
demo.launch()