Spaces:
Running
on
Zero
Running
on
Zero
patrickligardes
commited on
Commit
β’
f4b3582
1
Parent(s):
5a19f35
Update utils_mask.py
Browse files- utils_mask.py +13 -13
utils_mask.py
CHANGED
@@ -76,22 +76,22 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
76 |
|
77 |
arms_left = (parse_array == label_map["left_arm"]).astype(np.float32)
|
78 |
arms_right = (parse_array == label_map["right_arm"]).astype(np.float32)
|
79 |
-
|
80 |
if category == 'dresses':
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
90 |
parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
91 |
|
92 |
-
# Combine upper body
|
93 |
-
|
94 |
-
parse_mask = np.logical_or(parse_mask_upper, parse_mask_lower)
|
95 |
|
96 |
elif category == 'upper_body':
|
97 |
parse_mask = (parse_array == label_map["upper_clothes"]).astype(np.float32)
|
|
|
76 |
|
77 |
arms_left = (parse_array == label_map["left_arm"]).astype(np.float32)
|
78 |
arms_right = (parse_array == label_map["right_arm"]).astype(np.float32)
|
79 |
+
|
80 |
if category == 'dresses':
|
81 |
+
# Initial dress mask for the upper body (excluding head)
|
82 |
+
parse_mask_upper = np.logical_or((parse_array == label_map["upper_clothes"]), (parse_array == label_map["dress"])).astype(np.float32)
|
83 |
+
|
84 |
+
# Create a mask for the legs (including skirts and pants)
|
85 |
+
parse_mask_legs = np.logical_or.reduce((parse_array == label_map["skirt"],
|
86 |
+
parse_array == label_map["pants"],
|
87 |
+
parse_array == label_map["left_leg"],
|
88 |
+
parse_array == label_map["right_leg"])).astype(np.float32)
|
89 |
+
|
90 |
+
# Dilate the leg mask to ensure coverage and fill gaps
|
91 |
parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
92 |
|
93 |
+
# Combine the upper body mask with the dilated leg mask
|
94 |
+
parse_mask = np.maximum(parse_mask_upper, parse_mask_legs_dilated)
|
|
|
95 |
|
96 |
elif category == 'upper_body':
|
97 |
parse_mask = (parse_array == label_map["upper_clothes"]).astype(np.float32)
|