Spaces:
Running
on
Zero
Running
on
Zero
patrickligardes
commited on
Commit
β’
37277a1
1
Parent(s):
12c519f
Update utils_mask.py
Browse files- utils_mask.py +7 -2
utils_mask.py
CHANGED
@@ -94,8 +94,13 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
94 |
parse_array == label_map["right_leg"],
|
95 |
parse_array == label_map["skirt"],
|
96 |
parse_array == label_map["pants"])).astype(np.float32)
|
97 |
-
parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
elif category == 'upper_body':
|
101 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|
|
|
94 |
parse_array == label_map["right_leg"],
|
95 |
parse_array == label_map["skirt"],
|
96 |
parse_array == label_map["pants"])).astype(np.float32)
|
97 |
+
parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=6)
|
98 |
+
parse_mask_lower = np.maximum(parse_mask_lower, parse_mask_legs_dilated)
|
99 |
+
|
100 |
+
# Only fill the gaps between the legs
|
101 |
+
fill_gap_between_legs = cv2.morphologyEx(parse_mask_lower.astype(np.uint8), cv2.MORPH_CLOSE, np.ones((15, 15), np.uint8))
|
102 |
+
|
103 |
+
parse_mask = np.logical_or(parse_mask_upper, fill_gap_between_legs)
|
104 |
|
105 |
elif category == 'upper_body':
|
106 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|