|
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() |