Spaces:
Sleeping
Sleeping
patrickligardes
commited on
Commit
β’
0f37c73
1
Parent(s):
7772536
Update utils_mask.py
Browse files- utils_mask.py +7 -7
utils_mask.py
CHANGED
@@ -77,8 +77,9 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
77 |
arms_left = (parse_array == 14).astype(np.float32)
|
78 |
arms_right = (parse_array == 15).astype(np.float32)
|
79 |
|
|
|
80 |
if category == 'dresses':
|
81 |
-
# Initial dress mask
|
82 |
parse_mask_upper = (parse_array == 7).astype(np.float32) + \
|
83 |
(parse_array == 4).astype(np.float32) + \
|
84 |
(parse_array == 5).astype(np.float32)
|
@@ -87,18 +88,17 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
87 |
parse_mask_legs = (parse_array == 12).astype(np.float32) + \
|
88 |
(parse_array == 13).astype(np.float32) + \
|
89 |
(parse_array == 6).astype(np.float32)
|
90 |
-
|
91 |
parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
|
92 |
|
93 |
# Fill gaps between legs
|
94 |
leg_mask_filled = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
95 |
-
|
96 |
|
97 |
-
# Combine filled leg mask with upper body mask
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
|
|
|
|
|
102 |
|
103 |
|
104 |
elif category == 'upper_body':
|
|
|
77 |
arms_left = (parse_array == 14).astype(np.float32)
|
78 |
arms_right = (parse_array == 15).astype(np.float32)
|
79 |
|
80 |
+
|
81 |
if category == 'dresses':
|
82 |
+
# Initial dress mask for the upper body
|
83 |
parse_mask_upper = (parse_array == 7).astype(np.float32) + \
|
84 |
(parse_array == 4).astype(np.float32) + \
|
85 |
(parse_array == 5).astype(np.float32)
|
|
|
88 |
parse_mask_legs = (parse_array == 12).astype(np.float32) + \
|
89 |
(parse_array == 13).astype(np.float32) + \
|
90 |
(parse_array == 6).astype(np.float32)
|
91 |
+
|
92 |
parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
|
93 |
|
94 |
# Fill gaps between legs
|
95 |
leg_mask_filled = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
|
|
96 |
|
97 |
+
# Combine the filled leg mask with the upper body mask
|
98 |
+
combined_mask = np.maximum(parse_mask_upper, leg_mask_filled)
|
|
|
|
|
99 |
|
100 |
+
# Final dilation to ensure there are no small gaps
|
101 |
+
parse_mask = cv2.dilate(combined_mask.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=5)
|
102 |
|
103 |
|
104 |
elif category == 'upper_body':
|