vinayakchuni's picture
Update app.py
c41c03e
raw
history blame contribute delete
No virus
1.15 kB
from fastai.vision.all import *
import gradio as gr
diseaseDict={'1':'Eczema','2':'Melanoma','3':'Atopic Dermatitis','4':'Basal Cell Carcinoma','5':'Melanocytic Nevi','6':'Benign Keratosis like Lesions','7':'Psoriasis pictures Lichen Planus and other related diseases','8':'Seborrheic Keratoses and other Benign Tumors','9':'Tinea Ringworm Candidiasis and other Fungal Infections','10':'Warts Molluscum and other Viral Infections'}
def label_func(x): return diseaseDict[x.parent.name[0]]
learn=load_learner('modelSkinDiseaseDetector.pkl')
categories = ('Eczema','Melanoma','Atopic Dermatitis','Basal Cell Carcinoma','Melanocytic Nevi','Benign Keratosis like Lesions','Psoriasis pictures Lichen Planus and other related diseases','Seborrheic Keratoses and other Benign Tumors','Tinea Ringworm Candidiasis and other Fungal Infections','Warts Molluscum and other Viral Infections')
def classify_img(img):
pred,idx,probs=learn.predict(img)
return dict(zip(categories,map(float,probs)))
image=gr.inputs.Image(shape=(192,192))
label=gr.outputs.Label()
intf=gr.Interface(fn=classify_img,inputs=image,outputs=label)
intf.launch(inline=False)