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

Function pre_process_depth

utils.py:59–74  ·  view source on GitHub ↗
(input_video, apply_depth_detect: bool = True)

Source from the content-addressed store, hash-verified

57
58
59def pre_process_depth(input_video, apply_depth_detect: bool = True):
60 detected_maps = []
61 for frame in input_video:
62 img = rearrange(frame, 'c h w -> h w c').cpu().numpy().astype(np.uint8)
63 img = HWC3(img)
64 if apply_depth_detect:
65 detected_map, _ = apply_midas(img)
66 else:
67 detected_map = img
68 detected_map = HWC3(detected_map)
69 H, W, C = img.shape
70 detected_map = cv2.resize(detected_map, (W, H), interpolation=cv2.INTER_NEAREST)
71 detected_maps.append(detected_map[None])
72 detected_maps = np.concatenate(detected_maps)
73 control = torch.from_numpy(detected_maps.copy()).float() / 255.0
74 return rearrange(control, 'f h w c -> f c h w')
75
76
77def pre_process_pose(input_video, apply_pose_detect: bool = True):

Callers

nothing calls this directly

Calls 1

HWC3Function · 0.90

Tested by

no test coverage detected