import gradio as gr from fastai.vision.all import * # load model learn = load_learner('./model.pkl') categories = ('CLEAR', 'PNEUMONIA') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) examples = ['./unseen_data/NORMAL/NORMAL2-IM-1427-0001.jpeg', './unseen_data/PNEUMONIA/person1946_bacteria_4874.jpeg', './unseen_data/NORMAL/NORMAL2-IM-1430-0001.jpeg', './unseen_data/PNEUMONIA/person1946_bacteria_4875.jpeg'] title = 'Pneumonia Child Chest X-Ray Classifier' description = """An X-Ray classifier trained on the Children Chest X-Ray Images.""" article="""
License: CC BY 4.0
Trained using the fast.ai library
""" intf = gr.Interface(fn=classify_image, inputs=gr.Image(type='pil'), outputs=gr.Label(), examples=examples, title = title, description = description, article = article) intf.launch(inline=False, share=True)