| 119 | ThreadPoolExecutor(max_workers=32) as saver_executor: |
| 120 | |
| 121 | def loader(sha256): |
| 122 | try: |
| 123 | attrs = ['base_color', 'metallic', 'roughness', 'alpha'] |
| 124 | coords, attr = o_voxel.io.read_vxz( |
| 125 | os.path.join(opt.pbr_voxel_root, f'pbr_voxels_{opt.resolution}', f'{sha256}.vxz'), |
| 126 | num_threads=4 |
| 127 | ) |
| 128 | feats = torch.concat([attr[k] for k in attrs], dim=-1) / 255.0 * 2 - 1 |
| 129 | x = sp.SparseTensor( |
| 130 | feats.float(), |
| 131 | torch.cat([torch.zeros_like(coords[:, 0:1]), coords], dim=-1), |
| 132 | ) |
| 133 | load_queue.put((sha256, x)) |
| 134 | except Exception as e: |
| 135 | print(f"[Loader Error] {sha256}: {e}") |
| 136 | load_queue.put((sha256, None)) |
| 137 | |
| 138 | loader_executor.map(loader, sha256s) |
| 139 | |