Spaces:
Runtime error
Runtime error
polejowska
commited on
Commit
•
1d1bc10
1
Parent(s):
032542c
Update visualization.py
Browse files- visualization.py +9 -2
visualization.py
CHANGED
@@ -24,12 +24,19 @@ def visualize_prediction(
|
|
24 |
fig, ax = plt.subplots(figsize=(12, 12))
|
25 |
ax.imshow(pil_img)
|
26 |
if display_mask and mask is not None:
|
|
|
|
|
|
|
27 |
# Create a new mask with white objects and black background
|
28 |
-
new_mask = np.zeros_like(
|
29 |
-
new_mask[
|
|
|
|
|
|
|
30 |
|
31 |
# Display the new mask as a semi-transparent overlay
|
32 |
ax.imshow(new_mask, alpha=0.5, cmap='gray')
|
|
|
33 |
colors = COLORS * 100
|
34 |
for score, (xmin, ymin, xmax, ymax), label, color in zip(
|
35 |
scores, boxes, labels, colors
|
|
|
24 |
fig, ax = plt.subplots(figsize=(12, 12))
|
25 |
ax.imshow(pil_img)
|
26 |
if display_mask and mask is not None:
|
27 |
+
# Convert the mask image to a numpy array
|
28 |
+
mask_arr = np.asarray(mask)
|
29 |
+
|
30 |
# Create a new mask with white objects and black background
|
31 |
+
new_mask = np.zeros_like(mask_arr)
|
32 |
+
new_mask[mask_arr > 0] = 255
|
33 |
+
|
34 |
+
# Convert the numpy array back to a PIL Image
|
35 |
+
new_mask = Image.fromarray(new_mask)
|
36 |
|
37 |
# Display the new mask as a semi-transparent overlay
|
38 |
ax.imshow(new_mask, alpha=0.5, cmap='gray')
|
39 |
+
|
40 |
colors = COLORS * 100
|
41 |
for score, (xmin, ymin, xmax, ymax), label, color in zip(
|
42 |
scores, boxes, labels, colors
|