Jagannath8 commited on
Commit
7d453ef
·
1 Parent(s): 0d438cf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ import tensorflow as tf
4
+ import os
5
+ import numpy as np
6
+
7
+ model = tf.keras.models.load_model('model.hdf5')
8
+
9
+ LABELS = ['NORMAL', 'TUBERCULOSIS', 'PNEUMONIA', 'COVID19']
10
+
11
+ def predict_input_image(img):
12
+ img_4d=img.reshape(-1,128,128,3)/255.0
13
+ print(img_4d.min())
14
+ print(img_4d.max())
15
+ prediction=model.predict(img_4d)[0]
16
+ return {LABELS[i]: float(prediction[i]) for i in range(4)}
17
+
18
+ def k():
19
+ return gr.update(value=None)
20
+
21
+ with gr.Blocks(title="Chest X-Ray Disease Classification", css="") as demo:
22
+ with gr.Row():
23
+ textmd = gr.Markdown()
24
+ with gr.Row():
25
+ with gr.Column(scale=1, min_width=600):
26
+ image = gr.inputs.Image(shape=(128,128))
27
+ with gr.Row():
28
+ clear_btn = gr.Button("Clear")
29
+ submit_btn = gr.Button("Submit", elem_id="warningk", variant='primary')
30
+ '''examples = gr.Examples(examples=["COVID19-0.jpg",
31
+ "NORMAL-0.jpeg",
32
+ "COVID19-1.jpg",
33
+ "PNEUMONIA-0.jpeg"], inputs=image)'''
34
+ label = gr.outputs.Label(num_top_classes=4)
35
+
36
+ clear_btn.click(k, inputs=[], outputs=image)
37
+ submit_btn.click(predict_input_image, inputs=image, outputs=label)
38
+
39
+ demo.launch()