Zakia commited on
Commit
156c8c0
1 Parent(s): cd10662

add figures and change app.py

Browse files
NORMAL2-IM-0222-0001.jpeg ADDED
NORMAL2-IM-0285-0001.jpeg ADDED
NORMAL2-IM-0373-0001.jpeg ADDED
NORMAL2-IM-0381-0001.jpeg ADDED
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Bismillahir Rahmaanir Raheem
2
+ # Almadadh Ya Gause Radi Allahu Ta'alah Anh - Ameen
3
+
4
+
5
+ from fastai.vision.all import *
6
+ import gradio as gr
7
+
8
+
9
+ def is_pneumonia(x):
10
+ return (x.find('virus')!=-1 or x.find('bacteria')!=-1)
11
+
12
+
13
+
14
+ # load the trained fast ai model for predictions
15
+ learn = load_learner('model.pkl')
16
+
17
+
18
+ # define the function to call
19
+ categories = ('Pneumonia', 'Normal')
20
+
21
+ def predict(img):
22
+ pred, idx, probs = learn.predict(img)
23
+ return dict(zip(categories, map(float, probs)))
24
+
25
+
26
+ title = "Pneumonia or Normal X-Ray Predictor"
27
+
28
+ description = "A pneumonia or normal x-ray predictor model trained on the chest-xray-pneumonia dataset with fastai. </br> Dataset taken from: <a href='https://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='https://www.cell.com/cell/fulltext/S0092-8674(18)30154-5' target='_blank'>Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning</a>"
29
+
30
+
31
+ article = "<p style='text-align: center'><span style='font-size: 15pt;'>Pneumonia or Normal X-Ray Predictor. Zakia Salod. 2022. </span></p>"
32
+
33
+
34
+ image = gr.inputs.Image(shape=(512, 512))
35
+ label = gr.outputs.Label()
36
+ examples = [
37
+ ['person1_virus_6.jpeg'],
38
+ ['NORMAL2-IM-0285-0001.jpeg'],
39
+ ['person82_bacteria_404.jpeg'],
40
+ ['NORMAL2-IM-0373-0001.jpeg'],
41
+ ['person1618_virus_2805.jpeg'],
42
+ ['NORMAL2-IM-0381-0001.jpeg'],
43
+ ['person159_bacteria_747.jpeg'],
44
+ ['NORMAL2-IM-0222-0001.jpeg'],
45
+ ]
46
+ interpretation = 'default'
47
+ enable_queue = True
48
+
49
+
50
+
51
+
52
+ iface = gr.Interface(
53
+ fn=predict,
54
+ title=title,
55
+ description=description,
56
+ article=article,
57
+ inputs=image,
58
+ outputs=label,
59
+ theme="huggingface",
60
+ examples=examples,
61
+ interpretation=interpretation,
62
+ enable_queue=enable_queue
63
+ )
64
+
65
+
66
+
67
+ iface.launch(inline=False)
person159_bacteria_747.jpeg ADDED
person1618_virus_2805.jpeg ADDED
person1_virus_6.jpeg ADDED
person82_bacteria_404.jpeg ADDED