Spaces:
Running
on
Zero
Running
on
Zero
patrickligardes
commited on
Commit
β’
1629b28
1
Parent(s):
0605b48
Update utils_mask.py
Browse files- utils_mask.py +5 -4
utils_mask.py
CHANGED
@@ -85,10 +85,10 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
85 |
parser_mask_fixed += parser_mask_fixed_lower_cloth
|
86 |
|
87 |
# Create a mask for the legs (including skirts and pants)
|
88 |
-
parse_mask_legs = (parse_array == label_map["skirt"]
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
|
93 |
# Dilate the leg mask to ensure coverage and fill gaps
|
94 |
parse_mask_legs = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
@@ -96,6 +96,7 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
96 |
# Combine the upper body mask with the leg mask
|
97 |
parse_mask = np.maximum(parse_mask_upper, parse_mask_legs)
|
98 |
|
|
|
99 |
elif category == 'upper_body':
|
100 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|
101 |
parser_mask_fixed_lower_cloth = (parse_array == label_map["skirt"]).astype(np.float32) + \
|
|
|
85 |
parser_mask_fixed += parser_mask_fixed_lower_cloth
|
86 |
|
87 |
# Create a mask for the legs (including skirts and pants)
|
88 |
+
parse_mask_legs = np.logical_or.reduce((parse_array == label_map["skirt"],
|
89 |
+
parse_array == label_map["pants"],
|
90 |
+
parse_array == label_map["left_leg"],
|
91 |
+
parse_array == label_map["right_leg"])).astype(np.float32)
|
92 |
|
93 |
# Dilate the leg mask to ensure coverage and fill gaps
|
94 |
parse_mask_legs = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((6, 6), np.uint8), iterations=6)
|
|
|
96 |
# Combine the upper body mask with the leg mask
|
97 |
parse_mask = np.maximum(parse_mask_upper, parse_mask_legs)
|
98 |
|
99 |
+
|
100 |
elif category == 'upper_body':
|
101 |
parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
|
102 |
parser_mask_fixed_lower_cloth = (parse_array == label_map["skirt"]).astype(np.float32) + \
|