data_vis_list.append({ 'category': category_name, 'it': c_it, 'data': data_vis }) model_counter[category_id] += 1 # Model model = config.get_model(cfg, device=device, dataset=train_dataset) # Intialize training optimizer = optim.Adam(model.parameters(), lr=1e-4) trainer = config.get_trainer(model, optimizer, cfg, device=device) checkpoint_io = CheckpointIO(out_dir, model=model, optimizer=optimizer) try: load_dict = checkpoint_io.load(f'{model_name}.pt') except FileExistsError: load_dict = dict() epoch_it = load_dict.get('epoch_it', -1) it = load_dict.get('it', -1) it0 = load_dict.get('it', -1) metric_val_best = load_dict.get('loss_val_best', -model_selection_sign * np.inf) # Generator generator = config.get_generator(model, cfg, device=device) if metric_val_best == np.inf or metric_val_best == -np.inf: metric_val_best = -model_selection_sign * np.inf
c_it = model_counter[category_id] if c_it < vis_n_outputs: data_vis_list.append({'category': category_name, 'it': c_it, 'data': data_vis}) model_counter[category_id] += 1 """ # Model model = config.get_model(cfg, device=device, dataset=train_dataset) # Intialize training optimizer = optim.Adam(model.parameters(), lr=1e-4) trainer = config.get_trainer(model, optimizer, cfg, device=device) checkpoint_io = CheckpointIO(out_dir, model=model, optimizer=optimizer) try: load_dict = checkpoint_io.load('model.pt') except FileExistsError: load_dict = dict() epoch_it = load_dict.get('epoch_it', -1) it = load_dict.get('it', -1) it0 = load_dict.get('it', -1) metric_val_best = load_dict.get('loss_val_best', -model_selection_sign * np.inf) # Generator generator = config.get_generator(model, cfg, device=device) if metric_val_best == np.inf or metric_val_best == -np.inf: metric_val_best = -model_selection_sign * np.inf
out_time_file_class = os.path.join(generation_dir, 'time_generation.pkl') batch_size = cfg['generation']['batch_size'] input_type = cfg['data']['input_type'] vis_n_outputs = cfg['generation']['vis_n_outputs'] if vis_n_outputs is None: vis_n_outputs = -1 # Dataset dataset = config.get_dataset('test', cfg, return_idx=True) print(dataset) # Model model = config.get_model(cfg, device=device, dataset=dataset) checkpoint_io = CheckpointIO(out_dir, model=model) checkpoint_io.load(cfg['test']['model_file']) # Generator generator = config.get_generator(model, cfg, device=device) # Determine what to generate generate_mesh = cfg['generation']['generate_mesh'] generate_pointcloud = cfg['generation']['generate_pointcloud'] if generate_mesh and not hasattr(generator, 'generate_mesh'): generate_mesh = False print('Warning: generator does not support mesh generation.') if generate_pointcloud and not hasattr(generator, 'generate_pointcloud'): generate_pointcloud = False