hamdan07 commited on
Commit
005418e
1 Parent(s): d4fe1df

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import cv2
4
+
5
+ title = "Covid 19 Prediction App using X-ray Images"
6
+
7
+ head = (
8
+ "<center>"
9
+ "Upload an X-ray image to check for covid19. The app is for research purposes and not clinically authorized"
10
+ "</center>"
11
+ )
12
+
13
+
14
+ cnn = tf.keras.models.load_model("cnn_model.h5")
15
+
16
+ def predict_input_image(img):
17
+ img = img.reshape(1, 500, 500, 1)
18
+ prediction = cnn.predict(img).tolist()[0]
19
+ class_names = ["Covid"]
20
+ return {class_names[i]: 1-prediction[i] for i in range(1)}
21
+
22
+ image = gr.inputs.Image(shape=(500, 500), image_mode='L', invert_colors=False, source="upload")
23
+ label = gr.outputs.Label()
24
+ iface = gr.Interface(fn=predict_input_image, inputs=image, outputs=label,title=title, description=head)
25
+ iface.launch()