chidojawbreaker commited on
Commit
6af0ef0
1 Parent(s): f41348c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import tensorflow as tf
4
+ from tensorflow.keras.preprocessing import image
5
+
6
+ model = tf.keras.models.load_model('model.hdf5')
7
+
8
+ def predict(img_path):
9
+ test_image = image.load_img(img_path, target_size=(224,224))
10
+ test_image = image.img_to_array(test_image)
11
+ test_image = test_image/255.0
12
+ test_image = np.expand_dims(test_image, axis = 0)
13
+ prediction = model.predict(test_image)
14
+ result = np.argmax(prediction, axis=1)
15
+ if result[0] == 0:
16
+ prediction = 'COVID DETECTED'
17
+ elif result[0] == 1:
18
+ prediction = 'HEALTHY'
19
+ elif result[0] == 2:
20
+ prediction = 'LUNG CANCER DETECTED'
21
+ else:
22
+ prediction = 'PNEUMONIA DETECTED'
23
+ return prediction
24
+
25
+ iface = gr.Interface(fn=predict, inputs="text", outputs="text")
26
+ iface.launch(share=True)