Spaces:
Sleeping
Sleeping
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 have {label} disease." | |
demo=gr.Interface(fn=detect_symptom,inputs='text',outputs='label') | |
demo.launch() |