Commit
·
5de8b98
1
Parent(s):
43db0df
added predicted labels
Browse files
app.py
CHANGED
@@ -48,11 +48,17 @@ if raw_image is not None:
|
|
48 |
# Second, apply argmax on the class dimension
|
49 |
seg = upsampled_logits.argmax(dim=1)[0]
|
50 |
color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) # height, width, 3\
|
|
|
51 |
for label, color in enumerate(palette):
|
52 |
color_seg[seg == label, :] = color
|
|
|
|
|
53 |
# Convert to BGR
|
54 |
color_seg = color_seg[..., ::-1]
|
55 |
# Show image + mask
|
56 |
img = np.array(image) * 0.5 + color_seg * 0.5
|
57 |
img = img.astype(np.uint8)
|
58 |
-
st.image(img, caption="Segmented Image")
|
|
|
|
|
|
|
|
48 |
# Second, apply argmax on the class dimension
|
49 |
seg = upsampled_logits.argmax(dim=1)[0]
|
50 |
color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) # height, width, 3\
|
51 |
+
all_labels = []
|
52 |
for label, color in enumerate(palette):
|
53 |
color_seg[seg == label, :] = color
|
54 |
+
if label in seg:
|
55 |
+
all_labels.append(id2label[label])
|
56 |
# Convert to BGR
|
57 |
color_seg = color_seg[..., ::-1]
|
58 |
# Show image + mask
|
59 |
img = np.array(image) * 0.5 + color_seg * 0.5
|
60 |
img = img.astype(np.uint8)
|
61 |
+
st.image(img, caption="Segmented Image")
|
62 |
+
st.header("Predicted Labels")
|
63 |
+
for idx, label in enumerate(all_labels):
|
64 |
+
st.subheader(f'{idx+1}) {label}')
|