Spaces:
Sleeping
Sleeping
patrickligardes
commited on
Commit
β’
5500e55
1
Parent(s):
487adbc
Update utils_mask.py
Browse files- utils_mask.py +16 -0
utils_mask.py
CHANGED
@@ -152,11 +152,27 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
152 |
parser_mask_fixed = np.logical_or(parser_mask_fixed, parse_head)
|
153 |
parse_mask = cv2.dilate(parse_mask, np.ones((5, 5), np.uint16), iterations=5)
|
154 |
if category == 'dresses' or category == 'upper_body':
|
|
|
155 |
neck_mask = (parse_array == 18).astype(np.float32)
|
156 |
neck_mask = cv2.dilate(neck_mask, np.ones((5, 5), np.uint16), iterations=1)
|
157 |
neck_mask = np.logical_and(neck_mask, np.logical_not(parse_head))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
parse_mask = np.logical_or(parse_mask, neck_mask)
|
|
|
|
|
159 |
arm_mask = cv2.dilate(np.logical_or(im_arms_left, im_arms_right).astype('float32'), np.ones((5, 5), np.uint16), iterations=4)
|
|
|
|
|
160 |
parse_mask += np.logical_or(parse_mask, arm_mask)
|
161 |
|
162 |
parse_mask = np.logical_and(parser_mask_changeable, np.logical_not(parse_mask))
|
|
|
152 |
parser_mask_fixed = np.logical_or(parser_mask_fixed, parse_head)
|
153 |
parse_mask = cv2.dilate(parse_mask, np.ones((5, 5), np.uint16), iterations=5)
|
154 |
if category == 'dresses' or category == 'upper_body':
|
155 |
+
# Create a mask for the neck
|
156 |
neck_mask = (parse_array == 18).astype(np.float32)
|
157 |
neck_mask = cv2.dilate(neck_mask, np.ones((5, 5), np.uint16), iterations=1)
|
158 |
neck_mask = np.logical_and(neck_mask, np.logical_not(parse_head))
|
159 |
+
|
160 |
+
# Add padding between the legs
|
161 |
+
legs_mask = (parse_array == 19).astype(np.float32)
|
162 |
+
legs_mask = cv2.dilate(legs_mask, np.ones((5, 5), np.uint16), iterations=1)
|
163 |
+
legs_padding_size = 10 # Adjust the padding size as needed
|
164 |
+
legs_padding = cv2.dilate(legs_mask, np.ones((legs_padding_size, legs_padding_size), np.uint16), iterations=1)
|
165 |
+
|
166 |
+
# Combine the legs mask with padding with existing masks
|
167 |
+
parse_mask += legs_padding
|
168 |
+
|
169 |
+
# Combine the neck mask with existing masks
|
170 |
parse_mask = np.logical_or(parse_mask, neck_mask)
|
171 |
+
|
172 |
+
# Dilate the arm mask
|
173 |
arm_mask = cv2.dilate(np.logical_or(im_arms_left, im_arms_right).astype('float32'), np.ones((5, 5), np.uint16), iterations=4)
|
174 |
+
|
175 |
+
# Combine the arm mask with existing masks
|
176 |
parse_mask += np.logical_or(parse_mask, arm_mask)
|
177 |
|
178 |
parse_mask = np.logical_and(parser_mask_changeable, np.logical_not(parse_mask))
|