Commit
·
14f2a96
1
Parent(s):
55a937c
Update app.py
Browse files
app.py
CHANGED
@@ -53,13 +53,13 @@ def dice_coef(y_true, y_pred, smooth=1):
|
|
53 |
seg_model = tf.keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
|
54 |
|
55 |
inputs = gr.inputs.Image(type="pil", label="Upload an image", source="upload")
|
56 |
-
image_output = gr.outputs.Image(type="
|
57 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
58 |
|
59 |
def gen_pred(img=inputs, model=seg_model):
|
60 |
# rgb_path = os.path.join(test_image_dir,img)
|
61 |
# img = cv2.imread(rgb_path)
|
62 |
-
|
63 |
# pil_image = Image.open('./003b50a15.jpg')
|
64 |
# img = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
|
65 |
img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
|
@@ -72,8 +72,8 @@ def gen_pred(img=inputs, model=seg_model):
|
|
72 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
73 |
# pil_image = Image.fromarray(pred)
|
74 |
PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|
75 |
-
return "UI in developing process ..."
|
76 |
-
|
77 |
|
78 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
79 |
description = "Upload an image and get prediction mask"
|
@@ -81,7 +81,7 @@ description = "Upload an image and get prediction mask"
|
|
81 |
|
82 |
gr.Interface(fn=gen_pred,
|
83 |
inputs=inputs,
|
84 |
-
outputs="
|
85 |
title=title,
|
86 |
examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
|
87 |
# css=css_code,
|
|
|
53 |
seg_model = tf.keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
|
54 |
|
55 |
inputs = gr.inputs.Image(type="pil", label="Upload an image", source="upload")
|
56 |
+
image_output = gr.outputs.Image(type="numpy", label="Output Image")
|
57 |
# outputs = gr.outputs.HTML() #uncomment for single class output
|
58 |
|
59 |
def gen_pred(img=inputs, model=seg_model):
|
60 |
# rgb_path = os.path.join(test_image_dir,img)
|
61 |
# img = cv2.imread(rgb_path)
|
62 |
+
img = cv2.imread("./003e2c95d.jpg")
|
63 |
# pil_image = Image.open('./003b50a15.jpg')
|
64 |
# img = cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
|
65 |
img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
|
|
|
72 |
# color_coverted = cv2.cvtColor(pred, cv2.COLOR_BGR2RGB)
|
73 |
# pil_image = Image.fromarray(pred)
|
74 |
PIL_image = Image.fromarray(pred.astype('uint8'), 'RGB')
|
75 |
+
# return "UI in developing process ..."
|
76 |
+
return PIL_image
|
77 |
|
78 |
title = "<h1 style='text-align: center;'>Semantic Segmentation</h1>"
|
79 |
description = "Upload an image and get prediction mask"
|
|
|
81 |
|
82 |
gr.Interface(fn=gen_pred,
|
83 |
inputs=inputs,
|
84 |
+
outputs="image",
|
85 |
title=title,
|
86 |
examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
|
87 |
# css=css_code,
|