INNER CODE UNIT · Python
load_depth_model
wenhaochai/StableVideo · app.py:55
def load_depth_model(
self,
base_cfg='ckpt/cldm_v15.yaml',
depth_model_cfg='ckpt/control_sd15_depth.pth',
):
self.apply_midas = MidasDetector()
depth_model = create_model(base_cfg).cpu()
depth_model.load_state_dict(load_state_dict(depth_model_cfg, location='cuda'), strict=False)
self.depth_ddim_sampler = DDIMSampler(depth_model)
self.depth_model = depth_model
def load_video(self, video_name):
self.data = AtlasData(video_name)
save_name = f"data/{video_name}/{video_name}.mp4"
if not os.path.exists(save_name):
imageio.mimwrite(save_name, self.data.original_video.cpu().permute(0, 2, 3, 1))
print("original video saved.")
toIMG = transforms.ToPILImage()