covid_predictor / app.py.bak
Anthony-Ml's picture
Added 2 more images
9ef33e3 unverified
raw
history blame
1.39 kB
import gradio as gr
from fastai.vision.all import *
from efficientnet_pytorch import EfficientNet
learn = load_learner('model/predictcovidfastaifinal18102023.pkl')
categories = learn.dls.vocab
def predict_image(get_image):
pred, idx, probs = learn.predict(get_image)
return dict(zip(categories, map(float, probs)))
title = "Detect COVID_19 Infection Xray Chest Images"
description = "A covid19 infection classifier trained on the anasmohammedtahir/covidqu dataset with efficientnetb0 base model. Created demo using Gradio and HuggingFace Spaces."
examples = [
['covid/covid_1038.png', 'covid/covid_1034.png', 'covid/cd.png', 'covid/covid_1021.png', 'covid/covid_1027.png', 'covid/covid_1042.png', 'covid/covid_1031.png'],
['non_covid/nc.png', 'non_covid/non_COVID (10606).png', 'non_covid/non_COVID (10607).png', 'non_covid/non_COVID (10608).png', 'non_covid/non_COVID (10609).png', 'non_covid/non_COVID (10610).png']]
article="<p style='text-align: center'><a href='https://www.kaggle.com/datasets/anasmohammedtahir/covidqu' target='_blank'>COVID-QU-Ex Dataset</a></p>"
interpretation='default'
enable_queue=True
gr.Interface(fn=predict_image, inputs=gr.Image(shape=(224,224)),
outputs = gr.Label(num_top_classes=3),title=title,description=description,examples=examples,article=article, interpretation=interpretation,enable_queue=enable_queue).launch(share=False)