Spaces:
Running
on
Zero
Running
on
Zero
patrickligardes
commited on
Commit
β’
60a3886
1
Parent(s):
d5ddcb4
Update utils_mask.py
Browse files- utils_mask.py +7 -5
utils_mask.py
CHANGED
@@ -85,13 +85,15 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
85 |
|
86 |
parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
|
87 |
|
88 |
-
#
|
89 |
-
|
90 |
-
|
91 |
|
92 |
# Fill gaps between legs
|
93 |
-
|
94 |
-
|
|
|
|
|
95 |
|
96 |
elif category == 'upper_body':
|
97 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|
|
|
85 |
|
86 |
parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
|
87 |
|
88 |
+
# Create a separate mask for the gap between legs
|
89 |
+
leg_gap_mask = (parse_array == 12).astype(np.float32) + \
|
90 |
+
(parse_array == 13).astype(np.float32)
|
91 |
|
92 |
# Fill gaps between legs
|
93 |
+
leg_gap_filled = cv2.dilate(leg_gap_mask.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
94 |
+
|
95 |
+
# Add the gap-filled mask to the existing parse_mask
|
96 |
+
parse_mask += leg_gap_filled
|
97 |
|
98 |
elif category == 'upper_body':
|
99 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|