Update app.py
Browse files
app.py
CHANGED
@@ -88,14 +88,22 @@ def sepia(input_img):
|
|
88 |
) # We reverse the shape of `image` because `image.size` returns width and height.
|
89 |
seg = tf.math.argmax(logits, axis=-1)[0]
|
90 |
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
93 |
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
demo = gr.Interface(fn=sepia,
|
97 |
inputs=gr.Image(shape=(400, 600)),
|
98 |
-
outputs=
|
99 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
100 |
allow_flagging='never')
|
101 |
|
|
|
88 |
) # We reverse the shape of `image` because `image.size` returns width and height.
|
89 |
seg = tf.math.argmax(logits, axis=-1)[0]
|
90 |
|
91 |
+
color_seg = np.zeros(
|
92 |
+
(seg.shape[0], seg.shape[1], 3), dtype=np.uint8
|
93 |
+
) # height, width, 3
|
94 |
+
for label, color in enumerate(colormap):
|
95 |
+
color_seg[seg.numpy() == label, :] = color
|
96 |
|
97 |
+
# Show image + mask
|
98 |
+
pred_img = np.array(input_img) * 0.5 + color_seg * 0.5
|
99 |
+
pred_img = pred_img.astype(np.uint8)
|
100 |
+
|
101 |
+
fig = draw_plot(pred_img, seg)
|
102 |
+
return fig
|
103 |
|
104 |
demo = gr.Interface(fn=sepia,
|
105 |
inputs=gr.Image(shape=(400, 600)),
|
106 |
+
outputs=['plot'],
|
107 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
108 |
allow_flagging='never')
|
109 |
|