File size: 1,254 Bytes
d666bea
40fd6ae
 
d666bea
 
0299e88
611d359
28b8c89
611d359
5f22dd7
 
 
 
 
40fd6ae
611d359
d666bea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from fastai.vision.all import *
import gradio as gr

learn = load_learner('model.pkl')
categories = ('chickenpox', 'cowpox', 'healthy', 'measles', 'monkeypox', 'smallpox')
examples = ['ch_0001.jpg', 'co_0001.jpg', 'he_0001.jpg', 'mo_0001.jpg', 'sm_0001.jpg']
title = "Monkeypox Classifier (NOT MEDICAL ADVICE)"
description = "A transfer learning model using resnet 50 to classify Monkeypox/Smallpox/Cowpox/Chickenpox/Measles (NOT MEDICAL ADVICE) using https://www.kaggle.com/datasets/arafathussain/monkeypox-skin-image-dataset-2022 dataset, @article{islam2022aweb, title={A Web-scraped Skin Image Database of Monkeypox, Chickenpox, Smallpox, Cowpox, and Measles}, author={Islam, Towhidul and Hussain, Mohammad Arafat and Chowdhury, Forhad Uddin Hasan and Islam, B M Riazul}, journal={bioRxiv 2022.08.01.502199}, doi {https://doi.org/10.1101/2022.08.01.502199}, year={2022} }"

labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), examples=examples, title=title, description=description).launch(share=True)