Spaces:
Runtime error
Runtime error
Commit
·
d93c84c
1
Parent(s):
a6546e9
Update app.py
Browse files
app.py
CHANGED
@@ -14,21 +14,14 @@ print('Successfully loaded model...')
|
|
14 |
examples = ['examples/VinDr_RibCXR_val_008.png', 'examples/VinDr_RibCXR_val_013.png']
|
15 |
|
16 |
|
17 |
-
def
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
threshold = 0.5
|
|
|
22 |
prob = tf.sigmoid(logits)
|
23 |
pred = tf.cast(prob > threshold, dtype=tf.float32)
|
24 |
-
pred = pred.numpy())[0,:,:,0]
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
iface = gr.Interface(
|
29 |
-
fn=infer,
|
30 |
-
title="ribs segmentation",
|
31 |
-
description = "Keras Implementation of Unet++ architecture for ribs segmentation 📏",
|
32 |
-
inputs=[gr.inputs.Image(label="image", type="numpy", shape=(640, 480))],
|
33 |
-
outputs="image",
|
34 |
-
examples=examples).launch(debug=True, cache_examples=True)
|
|
|
14 |
examples = ['examples/VinDr_RibCXR_val_008.png', 'examples/VinDr_RibCXR_val_013.png']
|
15 |
|
16 |
|
17 |
+
def segment(img_arr):
|
18 |
+
if np.ndim(img_arr) != 2:
|
19 |
+
img_arr = img_arr[:, :, 1]
|
20 |
+
image = img_arr[np.newaxis, :, :, np.newaxis]
|
21 |
threshold = 0.5
|
22 |
+
logits = model(image)
|
23 |
prob = tf.sigmoid(logits)
|
24 |
pred = tf.cast(prob > threshold, dtype=tf.float32)
|
25 |
+
pred = np.array(pred.numpy())[0,:,:,0]
|
26 |
+
return pred
|
27 |
+
iface = gr.Interface(fn=segment, inputs=gr.inputs.Image(shape=(512, 512)), outputs="image", flagging_dir=os.path.join(sys.path[0], "flagged")).launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|