patrickligardes commited on
Commit
eb3df1e
β€’
1 Parent(s): 58491f9

Update utils_mask.py

Browse files
Files changed (1) hide show
  1. utils_mask.py +4 -6
utils_mask.py CHANGED
@@ -82,17 +82,15 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
82
  (parse_array == label_map["dress"]).astype(np.float32)
83
 
84
  parse_mask_lower = (parse_array == label_map["skirt"]).astype(np.float32) + \
85
- (parse_array == label_map["pants"]).astype(np.float32) + \
86
- (parse_array == label_map["left_leg"]).astype(np.float32) + \
87
- (parse_array == label_map["right_leg"]).astype(np.float32)
88
 
89
- # Fill gaps between the legs
90
  parse_mask_legs = (parse_array == label_map["left_leg"]).astype(np.float32) + \
91
  (parse_array == label_map["right_leg"]).astype(np.float32)
92
  parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=6)
93
- parse_mask_lower = np.maximum(parse_mask_lower, parse_mask_legs_dilated)
94
 
95
- # Combine upper and filled lower body masks
 
96
  parse_mask = np.logical_or(parse_mask_upper, parse_mask_lower)
97
 
98
  elif category == 'upper_body':
 
82
  (parse_array == label_map["dress"]).astype(np.float32)
83
 
84
  parse_mask_lower = (parse_array == label_map["skirt"]).astype(np.float32) + \
85
+ (parse_array == label_map["pants"]).astype(np.float32)
 
 
86
 
87
+ # Dilate the leg parts to fill gaps
88
  parse_mask_legs = (parse_array == label_map["left_leg"]).astype(np.float32) + \
89
  (parse_array == label_map["right_leg"]).astype(np.float32)
90
  parse_mask_legs_dilated = cv2.dilate(parse_mask_legs.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=6)
 
91
 
92
+ # Combine upper body and dilated lower body masks
93
+ parse_mask_lower = np.maximum(parse_mask_lower, parse_mask_legs_dilated)
94
  parse_mask = np.logical_or(parse_mask_upper, parse_mask_lower)
95
 
96
  elif category == 'upper_body':