MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / padding_resize2

Method padding_resize2

tools/preprocess/pose2d_utils.py:240–272  ·  view source on GitHub ↗

kps will be changed inplace

(self, height=512, width=512)

Source from the content-addressed store, hash-verified

238 kps[:, 1] *= sy
239
240 def padding_resize2(self, height=512, width=512):
241 """kps will be changed inplace"""
242
243 all_kps = [self.kps_body, self.kps_lhand, self.kps_rhand, self.kps_face]
244
245 ori_height, ori_width = self.height, self.width
246
247 if (ori_height / ori_width) > (height / width):
248 new_width = int(height / ori_height * ori_width)
249 padding = int((width - new_width) / 2)
250 padding_width = padding
251 padding_height = 0
252 scale = height / ori_height
253
254 for kps in all_kps:
255 if kps is not None:
256 kps[:, 0] = kps[:, 0] * scale + padding
257 kps[:, 1] = kps[:, 1] * scale
258
259 else:
260 new_height = int(width / ori_width * ori_height)
261 padding = int((height - new_height) / 2)
262 padding_width = 0
263 padding_height = padding
264 scale = width / ori_width
265 for kps in all_kps:
266 if kps is not None:
267 kps[:, 1] = kps[:, 1] * scale + padding
268 kps[:, 0] = kps[:, 0] * scale
269
270 self.width = width
271 self.height = height
272 return self
273
274
275def transform_preds(coords, center, scale, output_size, use_udp=False):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected