Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import tensorflow as tf
|
|
5 |
import matplotlib
|
6 |
matplotlib.use('Agg')
|
7 |
|
8 |
-
#
|
9 |
model = tf.keras.models.load_model('model.h5')
|
10 |
|
11 |
def preprocess_image(image):
|
@@ -17,7 +17,10 @@ def predict_pneumonia(image):
|
|
17 |
img_array = preprocess_image(image)
|
18 |
prediction = model.predict(img_array)[0][0]
|
19 |
|
20 |
-
|
|
|
|
|
|
|
21 |
pneumonia_prediction = 1
|
22 |
else:
|
23 |
pneumonia_prediction = 0
|
@@ -40,7 +43,8 @@ gradio_interface = gr.Interface(
|
|
40 |
["NORMAL2-IM-1427-0001.jpeg"],
|
41 |
["NORMAL2-IM-1431-0001.jpeg"]
|
42 |
],
|
43 |
-
theme="default"
|
|
|
44 |
)
|
45 |
|
46 |
gradio_interface.launch()
|
|
|
5 |
import matplotlib
|
6 |
matplotlib.use('Agg')
|
7 |
|
8 |
+
# Load the model
|
9 |
model = tf.keras.models.load_model('model.h5')
|
10 |
|
11 |
def preprocess_image(image):
|
|
|
17 |
img_array = preprocess_image(image)
|
18 |
prediction = model.predict(img_array)[0][0]
|
19 |
|
20 |
+
# Use a more robust threshold for determining whether an image has pneumonia
|
21 |
+
threshold = 0.6
|
22 |
+
|
23 |
+
if prediction >= threshold:
|
24 |
pneumonia_prediction = 1
|
25 |
else:
|
26 |
pneumonia_prediction = 0
|
|
|
43 |
["NORMAL2-IM-1427-0001.jpeg"],
|
44 |
["NORMAL2-IM-1431-0001.jpeg"]
|
45 |
],
|
46 |
+
theme="default",
|
47 |
+
feedback=True
|
48 |
)
|
49 |
|
50 |
gradio_interface.launch()
|