covid_predictor / app.py
Anthony-Ml's picture
Update app.py
8b7fd62
raw
history blame
1.66 kB
import gradio as gr
from fastai.vision.all import *
from efficientnet_pytorch import EfficientNet
title = "COVID_19 Infection Detectation App!"
head = (
"<center>"
"<img src='Gradcam.png' width=400>"
"This Space demonstrates model based on efficientnet base model. I has been trained to classify chest xray image."
"</center>"
"<body>"
"<h2>"
"This Space demonstrates a model based on efficientnet base model"
"</h2>"
"<p>"
"I has been trained to classify chest xray image. To test it, Use the Example Images Provided or Upload your own xray images the space provided."
"</p>"
"<p>"
"The model is trained using [anasmohammedtahir/covidqu(https://www.kaggle.com/datasets/anasmohammedtahir/covidqu) dataset"
"</p>"
"</body>"
)
description = head
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']
]
#learn = load_learner('model/predictcovidfastaifinal18102023.pkl')
learn = load_learner('model/final_20102023_eb7_model.pkl')
categories = learn.dls.vocab
def predict_image(get_image):
pred, idx, probs = learn.predict(get_image)
return dict(zip(categories, map(float, probs)))
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, interpretation=interpretation,enable_queue=enable_queue).launch(share=False)