MCPcopy Create free account
hub / github.com/Picsart-AI-Research/Text2Video-Zero / pre_process_pose

Function pre_process_pose

utils.py:77–92  ·  view source on GitHub ↗
(input_video, apply_pose_detect: bool = True)

Source from the content-addressed store, hash-verified

75
76
77def pre_process_pose(input_video, apply_pose_detect: bool = True):
78 detected_maps = []
79 for frame in input_video:
80 img = rearrange(frame, 'c h w -> h w c').cpu().numpy().astype(np.uint8)
81 img = HWC3(img)
82 if apply_pose_detect:
83 detected_map, _ = apply_openpose(img)
84 else:
85 detected_map = img
86 detected_map = HWC3(detected_map)
87 H, W, C = img.shape
88 detected_map = cv2.resize(detected_map, (W, H), interpolation=cv2.INTER_NEAREST)
89 detected_maps.append(detected_map[None])
90 detected_maps = np.concatenate(detected_maps)
91 control = torch.from_numpy(detected_maps.copy()).float() / 255.0
92 return rearrange(control, 'f h w c -> f c h w')
93
94
95def create_video(frames, fps, rescale=False, path=None, watermark=None):

Callers

nothing calls this directly

Calls 1

HWC3Function · 0.90

Tested by

no test coverage detected