Update app.py
Browse files
app.py
CHANGED
@@ -88,28 +88,14 @@ 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 |
-
) # height, width, 3
|
94 |
-
for label, color in enumerate(colormap):
|
95 |
-
color_seg[seg.numpy() == label, :] = color
|
96 |
|
97 |
-
|
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 |
-
from io import BytesIO
|
105 |
-
img_byte_array = BytesIO()
|
106 |
-
pred_img.save(img_byte_array, format='PNG')
|
107 |
-
img_data = img_byte_array.getvalue()
|
108 |
-
img_base64 = base64.b64encode(img_data).decode()
|
109 |
|
110 |
demo = gr.Interface(fn=sepia,
|
111 |
inputs=gr.Image(shape=(400, 600)),
|
112 |
-
outputs=
|
113 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
114 |
allow_flagging='never')
|
115 |
|
|
|
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 |
+
# Assuming each label corresponds to a class
|
92 |
+
class_labels = seg.numpy().flatten().tolist()
|
|
|
|
|
|
|
93 |
|
94 |
+
return class_labels
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
demo = gr.Interface(fn=sepia,
|
97 |
inputs=gr.Image(shape=(400, 600)),
|
98 |
+
outputs=gr.outputs.Label(), # Use Label output type for class labels
|
99 |
examples=["cityoutdoor-1.jpg", "cityoutdoor-2.jpg", "cityoutdoor-3.jpg"],
|
100 |
allow_flagging='never')
|
101 |
|