MCPcopy Index your code
hub / github.com/OpenDriveLab/ReSim / sampling_main

Function sampling_main

sat/sample_video.py:191–424  ·  view source on GitHub ↗
(args, model_cls)

Source from the content-addressed store, hash-verified

189 print("!!!!!Setted seed to!!!!!!!", seed)
190
191def 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:

Callers 1

sample_video.pyFile · 0.85

Calls 15

get_modelFunction · 0.90
load_checkpointFunction · 0.90
get_obj_from_strFunction · 0.90
make_loadersFunction · 0.90
get_all_file_from_dirFunction · 0.85
decode_latentsFunction · 0.85
get_cond_indsFunction · 0.85
save_textFunction · 0.85
save_trajFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected