Spaces:
Running
on
Zero
Running
on
Zero
Update utils_mask.py
Browse filesCombines upper_clothes, skirt, and dress parts to simulate saree
- utils_mask.py +11 -2
utils_mask.py
CHANGED
@@ -100,6 +100,15 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
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 |
else:
|
104 |
raise NotImplementedError
|
105 |
|
@@ -112,7 +121,7 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
112 |
im_arms_right = Image.new('L', (width, height))
|
113 |
arms_draw_left = ImageDraw.Draw(im_arms_left)
|
114 |
arms_draw_right = ImageDraw.Draw(im_arms_right)
|
115 |
-
if category
|
116 |
shoulder_right = np.multiply(tuple(pose_data[2][:2]), height / 512.0)
|
117 |
shoulder_left = np.multiply(tuple(pose_data[5][:2]), height / 512.0)
|
118 |
elbow_right = np.multiply(tuple(pose_data[3][:2]), height / 512.0)
|
@@ -145,7 +154,7 @@ def get_mask_location(model_type, category, model_parse: Image.Image, keypoint:
|
|
145 |
|
146 |
parser_mask_fixed = np.logical_or(parser_mask_fixed, parse_head)
|
147 |
parse_mask = cv2.dilate(parse_mask, np.ones((5, 5), np.uint16), iterations=5)
|
148 |
-
if category
|
149 |
neck_mask = (parse_array == 18).astype(np.float32)
|
150 |
neck_mask = cv2.dilate(neck_mask, np.ones((5, 5), np.uint16), iterations=1)
|
151 |
neck_mask = np.logical_and(neck_mask, np.logical_not(parse_head))
|
|
|
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 |
+
elif category == 'saree':
|
104 |
+
# Include upper clothes, dress, and skirt for saree draping
|
105 |
+
parse_mask = (parse_array == 4).astype(np.float32) + \
|
106 |
+
(parse_array == 5).astype(np.float32) + \
|
107 |
+
(parse_array == 7).astype(np.float32)
|
108 |
+
parser_mask_fixed += (parse_array == label_map["pants"]).astype(np.float32)
|
109 |
+
parser_mask_fixed += arms_left + arms_right
|
110 |
+
parser_mask_changeable += np.logical_and(parse_array, np.logical_not(parser_mask_fixed))
|
111 |
+
|
112 |
else:
|
113 |
raise NotImplementedError
|
114 |
|
|
|
121 |
im_arms_right = Image.new('L', (width, height))
|
122 |
arms_draw_left = ImageDraw.Draw(im_arms_left)
|
123 |
arms_draw_right = ImageDraw.Draw(im_arms_right)
|
124 |
+
if category in ['dresses', 'upper_body', 'saree']:
|
125 |
shoulder_right = np.multiply(tuple(pose_data[2][:2]), height / 512.0)
|
126 |
shoulder_left = np.multiply(tuple(pose_data[5][:2]), height / 512.0)
|
127 |
elbow_right = np.multiply(tuple(pose_data[3][:2]), height / 512.0)
|
|
|
154 |
|
155 |
parser_mask_fixed = np.logical_or(parser_mask_fixed, parse_head)
|
156 |
parse_mask = cv2.dilate(parse_mask, np.ones((5, 5), np.uint16), iterations=5)
|
157 |
+
if category in ['dresses', 'upper_body', 'saree']:
|
158 |
neck_mask = (parse_array == 18).astype(np.float32)
|
159 |
neck_mask = cv2.dilate(neck_mask, np.ones((5, 5), np.uint16), iterations=1)
|
160 |
neck_mask = np.logical_and(neck_mask, np.logical_not(parse_head))
|