def registration_test(register: RegistrationAlgorithm, test_name: str, export_number=(0, 0)): registration_test_folder = f'{const.REGISTRATION}/{test_name}/' files = collect(registration_test_folder, '.npz') progress = tqdm(total=len(files), desc=f'Registration | {test_name} | {register.name}') total_error = 0 total_check = 0 for i, file in enumerate(files): data = np.load(''.join(file)) source, target = data['test_vs'][0], data['test_vs'][1] rot, trnl = data['rotations'], data['translations'] rot_, trnl_ = register(source, target) target_ = apply_affine(source, rot_, trnl_) error = mse_error(source, target_, rot, trnl) if np.isnan(error): print('error') total_error += min(error, 1) total_check += 1 progress.update() progress.set_postfix(error=error, average=total_error / max(1, total_check)) print(f'testeted: {total_check} / {len(files)}') print(f'error: {total_error / max(1, total_check)}') progress.set_postfix({'error': total_error / max(1, total_check)}) progress.close()
def init_prefix(prefix: str, saving_index: int, saving_folder: str): nonlocal saving_dict, suffix same_type_file = collect(saving_folder, suffix[saving_index], prefix=prefix) if len(same_type_file) == 0: saving_dict[saving_index][prefix] = 0 else: last_number_file_name = same_type_file[-1][1] saving_dict[saving_index][prefix] = int(last_number_file_name.split('_')[1]) + 1
def get_taxonomy_models_paths(self): with open(self.join2root('taxonomy.json'), 'r') as f: metadata = json.load(f) for info in metadata: class_name = info['name'].split(',')[0].replace(' ', '_') if class_name == self.opt.tag: taxonomy_dir = self.join2root(info['synsetId']) if os.path.isdir(taxonomy_dir): return files_utils.collect(taxonomy_dir, '.obj', '.off')
np_images = [ render_mesh(mesh, ambient_color, light_dir) for mesh in meshes ] im = make_pretty(np_images) if save_path: save_path = files_utils.add_suffix(save_path, '.png') files_utils.init_folders(save_path) im.save(save_path) elif 'DISPLAY' in os.environ: im.show() if __name__ == '__main__': meshes = [ ''.join(path) for path in files_utils.collect( '/home/amir/projects/mishmesh/checkpoints/bunny_noise/inference/', '.obj') ] plot_mesh( *meshes, save_path= '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/bunnies' ) # plot_mesh('/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp15.obj', # '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp24.obj', # '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp24.obj', # '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp23.obj', # '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp44.obj', # '/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/temp33.obj', # save_path='/home/amir/projects/mishmesh/checkpoints/sphere_rail_noise/inference/sphere_rail_bunny')