Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,13 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
from tensorflow.keras.models import load_model
|
4 |
import cv2
|
5 |
|
6 |
|
7 |
-
def image_predict (
|
8 |
-
|
9 |
-
model_path = 'resnet_ct.h5'
|
10 |
h5_model = load_model(model_path)
|
11 |
-
|
12 |
-
#OLD IMAGE
|
13 |
-
image = cv2.imread(image_pt)
|
14 |
-
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
15 |
-
image = cv2.resize(image, (224, 224))
|
16 |
image = np.array(image) / 255
|
17 |
image = np.expand_dims(image, axis=0)
|
18 |
h5_prediction = h5_model.predict(image)
|
@@ -20,20 +15,16 @@ def image_predict (image_pt):
|
|
20 |
print(h5_prediction)
|
21 |
probability = h5_prediction[0]
|
22 |
print("H5 Predictions:")
|
23 |
-
|
24 |
-
probability = 0
|
25 |
if probability[0] > 0.5:
|
26 |
covid_chest_pred = str('%.2f' % (probability[0] * 100) + '% COVID-Positive')
|
27 |
-
status = 'Covid-Positive'
|
28 |
probability = (probability[0] * 100)
|
29 |
else:
|
30 |
covid_chest_pred = str('%.2f' % ((1 - probability[0]) * 100) + '% COVID-Negative')
|
31 |
-
status = 'Covid-Negative'
|
32 |
probability = ((1 - probability[0]) * 100)
|
33 |
-
|
34 |
-
return {'status': str(status), 'probability': str(probability) }
|
35 |
|
36 |
|
37 |
|
38 |
-
myApp = gr.Interface(fn=image_predict, inputs="image", outputs="
|
39 |
myApp.launch()#share=True
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
from tensorflow.keras.models import load_model
|
5 |
import cv2
|
6 |
|
7 |
|
8 |
+
def image_predict (image):
|
9 |
+
model_path = 'resnet_ct.h5'
|
|
|
10 |
h5_model = load_model(model_path)
|
|
|
|
|
|
|
|
|
|
|
11 |
image = np.array(image) / 255
|
12 |
image = np.expand_dims(image, axis=0)
|
13 |
h5_prediction = h5_model.predict(image)
|
|
|
15 |
print(h5_prediction)
|
16 |
probability = h5_prediction[0]
|
17 |
print("H5 Predictions:")
|
18 |
+
print (probability)
|
|
|
19 |
if probability[0] > 0.5:
|
20 |
covid_chest_pred = str('%.2f' % (probability[0] * 100) + '% COVID-Positive')
|
|
|
21 |
probability = (probability[0] * 100)
|
22 |
else:
|
23 |
covid_chest_pred = str('%.2f' % ((1 - probability[0]) * 100) + '% COVID-Negative')
|
|
|
24 |
probability = ((1 - probability[0]) * 100)
|
25 |
+
return covid_chest_pred
|
|
|
26 |
|
27 |
|
28 |
|
29 |
+
myApp = gr.Interface(fn=image_predict, inputs="image", outputs="text")
|
30 |
myApp.launch()#share=True
|