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)