File size: 973 Bytes
e81879a
3559626
05c62eb
 
e81879a
c7429e9
 
3559626
4f950cb
05c62eb
3559626
05c62eb
4ddb435
05c62eb
6d69209
4ddb435
6d69209
4ddb435
 
3559626
4ddb435
05c62eb
 
 
 
 
 
 
 
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
import gradio as gr
import tensorflow as tf
import numpy as np
import os

os.system("tar -zxvf examples.tar.gz")

model = tf.keras.models.load_model('model_cv.h5')

def detect(img):
    img = img.reshape(1, 100, 100, 3)
    prediction = np.around(model.predict(img)[0], decimals=0)[0]

    if prediction == 1:
        return "Pneumonia Detected!"

    return "Pneumonia Not Detected!"


input = gr.inputs.Image(shape=(100, 100))

examples = ['examples/n1.jpeg', 'examples/n2.jpeg', 'examples/n3.jpeg', 'examples/n4.jpeg', 'examples/n5.jpeg',
            'examples/n6.jpeg', 'examples/n7.jpeg', 'examples/n8.jpeg', 'examples/p6.jpeg', 'examples/p7.jpeg',
            'examples/p1.jpeg', 'examples/p2.jpeg', 'examples/p3.jpeg', 'examples/p4.jpeg', 'examples/p8.jpeg']

title = "PneumoDetect: Pneumonia Detection from Chest X-Rays"

iface = gr.Interface(fn=detect, inputs=input, outputs="text", examples=examples, examples_per_page=20, title=title)
iface.launch(inline=False)