patrickligardes commited on
Commit
487adbc
β€’
1 Parent(s): ef2edb7

Update utils_mask.py

Browse files
Files changed (1) hide show
  1. utils_mask.py +15 -14
utils_mask.py CHANGED
@@ -85,21 +85,22 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
85
 
86
  parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
87
 
88
- elif category == 'upper_body':
89
- parse_mask = (parse_array == 4).astype(np.float32) + (parse_array == 7).astype(np.float32)
90
- parser_mask_fixed_lower_cloth = (parse_array == label_map["skirt"]).astype(np.float32) + \
91
- (parse_array == label_map["pants"]).astype(np.float32)
92
- parser_mask_fixed += parser_mask_fixed_lower_cloth
93
- parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
94
  elif category == 'lower_body' or category == 'full_body':
95
- parse_mask = (parse_array == 6).astype(np.float32) + \
96
- (parse_array == 12).astype(np.float32) + \
97
- (parse_array == 13).astype(np.float32) + \
98
- (parse_array == 5).astype(np.float32)
99
- parser_mask_fixed += (parse_array == label_map["upper_clothes"]).astype(np.float32) + \
100
- (parse_array == 14).astype(np.float32) + \
101
- (parse_array == 15).astype(np.float32)
102
- parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
 
 
 
 
 
 
103
 
104
  # Fill gaps in legs
105
  leg_mask = cv2.dilate(parse_mask.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=5)
 
85
 
86
  parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
87
 
88
+
 
 
 
 
 
89
  elif category == 'lower_body' or category == 'full_body':
90
+ if category == 'lower_body':
91
+ # For lower body category, include only lower body parts of the garment
92
+ parse_mask = (parse_array == 5).astype(np.float32) + \
93
+ (parse_array == 6).astype(np.float32)
94
+ else:
95
+ # For full body category, include all garment parts
96
+ parse_mask = (parse_array == 4).astype(np.float32) + \
97
+ (parse_array == 5).astype(np.float32) + \
98
+ (parse_array == 6).astype(np.float32)
99
+
100
+ parser_mask_fixed += (parse_array == label_map["upper_clothes"]).astype(np.float32) + \
101
+ (parse_array == 14).astype(np.float32) + \
102
+ (parse_array == 15).astype(np.float32)
103
+ parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
104
 
105
  # Fill gaps in legs
106
  leg_mask = cv2.dilate(parse_mask.astype(np.uint8), np.ones((5, 5), np.uint8), iterations=5)