File size: 1,873 Bytes
156c8c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935fd5f
156c8c0
5a081fa
156c8c0
 
935fd5f
156c8c0
 
97e0213
3771670
156c8c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ad1feb
912c7e4
156c8c0
 
fc46688
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Bismillahir Rahmaanir Raheem 
# Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen 


from fastai.vision.all import *
import gradio as gr


def is_pneumonia(x): 
    return (x.find('virus')!=-1 or x.find('bacteria')!=-1)
	


# load the trained fast ai model for predictions
learn = load_learner('model.pkl')


# define the function to call
categories = ('Pneumonia', 'Normal') 

def predict(img):
	pred, idx, probs = learn.predict(img)
	return dict(zip(categories, map(float, probs)))
	
	
title = "Pediatric Pneumonia Chest X-Ray Predictor"

description = "A pediatric pneumonia chest x-ray predictor model trained on the chest-xray-pneumonia dataset using ResNet18 via <a href='http://www.fast.ai/' target='_blank'>fast.ai</a>. The dataset is from: <a href='http://www.kaggle.com/datasets/paultimothymooney/chest-xray-pneumonia' target='_blank'>Chest X-Ray Images (Pneumonia)</a> and the associated scientific journal paper is <a href='http://www.cell.com/cell/fulltext/S0092-8674(18)30154-5' target='_blank'>Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning</a>. The accuracy of the model is: 81.25%"


article = "<p style='text-align: center'><span style='font-size: 15pt;'>Pediatric Pneumonia Chest X-Ray Predictor. Zakia Salod. 2022. </span></p>"


image = gr.Image(height=512, width=512)
label = gr.Label()
examples = [
             ['person1_virus_6.jpeg'],
			 ['NORMAL2-IM-0285-0001.jpeg'],
			 ['person82_bacteria_404.jpeg'],
			 ['NORMAL2-IM-0373-0001.jpeg'],
			 ['person1618_virus_2805.jpeg'],
			 ['NORMAL2-IM-0381-0001.jpeg'],
			 ['person159_bacteria_747.jpeg'],
			 ['NORMAL2-IM-0222-0001.jpeg'],
		   ]


iface = gr.Interface(
		fn=predict, 
		title=title, 
		description=description, 
		article=article,
		inputs=image, 
		outputs=label,
		theme="default",
		examples=examples
)

iface.launch(inline=False, share=True)