(args, model_cls)
| 189 | print("!!!!!Setted seed to!!!!!!!", seed) |
| 190 | |
| 191 | def sampling_main(args, model_cls): |
| 192 | |
| 193 | |
| 194 | if isinstance(model_cls, type): |
| 195 | model = get_model(args, model_cls) |
| 196 | else: |
| 197 | model = model_cls |
| 198 | |
| 199 | iteration = load_checkpoint(model, args) # 20000 |
| 200 | model.eval() |
| 201 | |
| 202 | predictive_mode = False |
| 203 | |
| 204 | if args.input_type == "latent_dir": |
| 205 | latent_files = get_all_file_from_dir(args.input_file) |
| 206 | print("show latent_files\n", latent_files[:5]) |
| 207 | decode_latents(model, latent_files) |
| 208 | return |
| 209 | elif args.input_type == "dataset": |
| 210 | data_class = get_obj_from_str(args.data_config["target"]) |
| 211 | create_dataset_function = partial(data_class.create_dataset_function, **args.data_config["params"]) |
| 212 | |
| 213 | args.num_workers = 8 # * More workers |
| 214 | train_data, val_data, test_data = make_loaders(args, create_dataset_function) |
| 215 | data_iter = val_data # * Checked, len(val_data) == 12146 |
| 216 | predictive_mode = True |
| 217 | else: |
| 218 | raise NotImplementedError |
| 219 | |
| 220 | # * Custom configs for sampling |
| 221 | image_size = args.sampling_video_size # * Remember set image size in your config |
| 222 | n_prediction_round = args.n_prediction_round |
| 223 | |
| 224 | T, H, W, C, F = args.sampling_num_frames, image_size[0], image_size[1], args.latent_channels, 8 |
| 225 | num_samples = [1] |
| 226 | |
| 227 | force_uc_zero_embeddings = ["txt", "fut_traj", "with_human_drive_token"] |
| 228 | |
| 229 | |
| 230 | APPLY_TRAJ = args.apply_traj # * Default False |
| 231 | SAVE_RECON = args.save_recon # * Default True, Turn to false to speed up sampling |
| 232 | SAVE_GT = args.save_gt |
| 233 | |
| 234 | CONCAT_RECON_FOR_DEMO = args.concat_recon_for_demo # * Default False |
| 235 | CONCAT_GT_FOR_DEMO = args.concat_gt_for_demo # * Default False |
| 236 | N_COND_FRAMES = args.n_cond_frames # * Default 3 |
| 237 | |
| 238 | device = model.device |
| 239 | |
| 240 | repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
| 241 | out_root = os.path.join(repo_root, "outputs") |
| 242 | |
| 243 | if isinstance(args.base, list): |
| 244 | cfg_path = args.base[0] |
| 245 | else: |
| 246 | cfg_path = args.base |
| 247 | |
| 248 | if "GROUP" not in cfg_path: |
no test coverage detected