├── .gitignore ├── LICENSE.md ├── README.md ├── data ├── __init__.py ├── base_dataset.py ├── data_utils.py ├── download-scannet.py ├── dtu_configs │ ├── dtu_finetune_init_pairs.txt │ ├── dtu_pairs.txt │ ├── lists │ │ ├── dtu_test_all.txt │ │ ├── dtu_test_ground.txt │ │ ├── dtu_train_all.txt │ │ ├── dtu_train_all_bk.txt │ │ ├── dtu_train_ground.txt │ │ └── dtu_val_all.txt │ └── pairs.th ├── dtu_dataset.py ├── dtu_ft_dataset.py ├── fitplane.py ├── llff_ft_dataset.py ├── load_blender.py ├── nerf_synth360_ft_dataset.py ├── nerf_synth_configs │ └── list │ │ ├── lego360_init_pairs.txt │ │ ├── lego_finetune_init_pairs.txt │ │ └── lego_finetune_init_pairs_final.txt ├── nerf_synth_ft_dataset.py ├── scannet_ft_dataset.py └── tt_ft_dataset.py ├── dev_scripts ├── dtu_test_inf │ ├── inftest_scan1.sh │ ├── inftest_scan103.sh │ ├── inftest_scan114.sh │ ├── inftest_scan21.sh │ └── inftest_scan8.sh ├── ete │ ├── dtu_dgt_d012_img0123_conf_agg2_32_dirclr20.sh │ └── dtu_dgt_d012_img0123_conf_color_dir_agg2.sh ├── w_colmap_n360 │ ├── col_chair.sh │ ├── col_drums.sh │ ├── col_ficus.sh │ ├── col_hotdog.sh │ ├── col_lego.sh │ ├── col_materials.sh │ ├── col_mic.sh │ └── col_ship.sh ├── w_n360 │ ├── chair.sh │ ├── chair_cuda.sh │ ├── chair_test.sh │ ├── drums.sh │ ├── drums_cuda.sh │ ├── drums_test.sh │ ├── ficus.sh │ ├── ficus_cuda.sh │ ├── ficus_test.sh │ ├── hotdog.sh │ ├── hotdog_cuda.sh │ ├── hotdog_test.sh │ ├── lego.sh │ ├── lego_cuda.sh │ ├── lego_test.sh │ ├── materials.sh │ ├── materials_cuda.sh │ ├── materials_test.sh │ ├── mic.sh │ ├── mic_cuda.sh │ ├── mic_test.sh │ ├── ship.sh │ ├── ship_all.sh │ ├── ship_all_test.sh │ ├── ship_cuda.sh │ └── ship_test.sh ├── w_scannet_etf │ ├── scene101.sh │ ├── scene101_test.sh │ ├── scene241.sh │ └── scene241_test.sh └── w_tt_ft │ ├── barn.sh │ ├── barn_test.sh │ ├── caterpillar.sh │ ├── caterpillar_test.sh │ ├── family.sh │ ├── family_test.sh │ ├── ignatius.sh │ ├── ignatius_test.sh │ ├── truck.sh │ └── truck_test.sh ├── images ├── Adobe-Logos.png ├── USC-Logos.png ├── pipeline.png └── youtube.png ├── models ├── __init__.py ├── aggregators │ ├── __init__.py │ └── point_aggregators.py ├── base_model.py ├── base_rendering_model.py ├── depth_estimators │ ├── __init__.py │ ├── module.py │ └── mvsnet.py ├── helpers │ ├── __init__.py │ ├── geometrics.py │ └── networks.py ├── mvs │ ├── filter_utils.py │ ├── models.py │ ├── mvs_points_model.py │ ├── mvs_utils.py │ └── renderer.py ├── mvs_points_volumetric_model.py ├── neural_points │ ├── __init__.py │ ├── cuda │ │ ├── query_worldcoords.cpp │ │ └── query_worldcoords.cu │ ├── neural_points.py │ ├── point_query.py │ ├── query_point_indices.py │ └── query_point_indices_worldcoords.py ├── neural_points_volumetric_model.py └── rendering │ ├── __init__.py │ ├── diff_ray_marching.py │ └── diff_render_func.py ├── options ├── __init__.py ├── base_options.py ├── edit_options.py ├── test_options.py └── train_options.py ├── requirement.sh ├── run ├── editing.py ├── evaluate.py ├── render_vid.py ├── test_ft.py ├── train.py ├── train_ft.py ├── train_ft_nonstop.py ├── vis_grow_train.py └── visualize.py └── utils ├── format.py ├── ncg_string.py ├── spherical.py ├── util.py └── visualizer.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | tags 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pretrained/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # mkdocs documentation 103 | /site 104 | 105 | # mypy 106 | .mypy_cache/ 107 | 108 | #others 109 | __pycache__ 110 | *.el 111 | /run/checkpoints 112 | /sensei/checkpoints 113 | /sensei/sessions.txt 114 | .vscode* 115 | .DS_Store 116 | .idea/ 117 | 118 | #viewer 119 | viewer/setting.ini 120 | viewer/ui_Viewer.py 121 | viewer/Viewer_rc.py 122 | viewer/breeze_rc.py 123 | viewer/testData 124 | -------------------------------------------------------------------------------- /data/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import torch.utils.data 3 | import sys 4 | sys.path.append("../") 5 | from utils.ncg_string import underscore2camelcase 6 | from .base_dataset import BaseDataset 7 | import numpy as np 8 | import time 9 | 10 | def find_dataset_class_by_name(name): 11 | ''' 12 | Input 13 | name: string with underscore representation 14 | 15 | Output 16 | dataset: a dataset class with class name {camelcase(name)}Dataset 17 | 18 | Searches for a dataset module with name {name}_dataset in current 19 | directory, returns the class with name {camelcase(name)}Dataset found in 20 | the module. 21 | ''' 22 | cls_name = underscore2camelcase(name) + 'Dataset' 23 | filename = "data.{}_dataset".format(name) 24 | module = importlib.import_module(filename) 25 | 26 | assert cls_name in module.__dict__, 'Cannot find dataset class name "{}" in "{}"'.format( 27 | cls_name, filename) 28 | cls = module.__dict__[cls_name] 29 | assert issubclass(cls, BaseDataset), 'Dataset class "{}" must inherit from BaseDataset'.format(cls_name) 30 | 31 | return cls 32 | 33 | 34 | def get_option_setter(dataset_name): 35 | dataset_class = find_dataset_class_by_name(dataset_name) 36 | return dataset_class.modify_commandline_options 37 | 38 | 39 | def create_dataset(opt): 40 | dataset = find_dataset_class_by_name(opt.dataset_name) 41 | instance = dataset() 42 | instance.initialize(opt) 43 | print("dataset [{}] was created".format(instance.name())) 44 | return instance 45 | 46 | 47 | def create_data_loader(opt, dataset=None): 48 | data_loader = DefaultDataLoader() 49 | data_loader.initialize(opt, dataset=dataset) 50 | return data_loader 51 | 52 | def worker_init_fn(worker_id): 53 | # np.random.seed(np.random.get_state()[1][0] + worker_id) 54 | np.random.seed((worker_id + torch.initial_seed() + np.floor(time.time()).astype(np.int64)) % np.iinfo(np.int32).max) 55 | 56 | 57 | class DefaultDataLoader: 58 | def name(self): 59 | return self.__class__.name 60 | 61 | def initialize(self, opt, dataset=None): 62 | assert opt.batch_size >= 1 63 | assert opt.n_threads >= 0 64 | assert opt.max_dataset_size >= 1 65 | 66 | self.opt = opt 67 | self.dataset = create_dataset(opt) if dataset is None else dataset 68 | self.dataloader = torch.utils.data.DataLoader(self.dataset, 69 | batch_size=opt.batch_size, 70 | shuffle=not opt.serial_batches, 71 | num_workers=int(opt.n_threads), 72 | worker_init_fn=worker_init_fn) 73 | 74 | def load_data(self): 75 | return self.dataset 76 | 77 | def __len__(self): 78 | return min(len(self.dataset), self.opt.max_dataset_size) 79 | 80 | def __iter__(self): 81 | for i, data in enumerate(self.dataloader): 82 | if i * self.opt.batch_size >= self.opt.max_dataset_size: 83 | break 84 | yield data 85 | 86 | def get_item(self, index): 87 | return self.dataset.get_item(index) 88 | -------------------------------------------------------------------------------- /data/base_dataset.py: -------------------------------------------------------------------------------- 1 | import torch.utils.data as data 2 | from PIL import Image 3 | 4 | 5 | class BaseDataset(data.Dataset): 6 | def __init__(self): 7 | super(BaseDataset, self).__init__() 8 | 9 | def name(self): 10 | return self.__class__.__name__ 11 | 12 | @staticmethod 13 | def modify_commandline_options(parser, is_train): 14 | return parser 15 | 16 | def initialize(self, opt): 17 | raise NotImplementedError() 18 | 19 | def __len__(self): 20 | raise NotImplementedError() 21 | -------------------------------------------------------------------------------- /data/data_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import open3d as o3d 3 | def get_cv_raydir(pixelcoords, height, width, focal, rot): 4 | # pixelcoords: H x W x 2 5 | if isinstance(focal, float): 6 | focal = [focal, focal] 7 | x = (pixelcoords[..., 0] - width / 2.0) / focal[0] 8 | y = (pixelcoords[..., 1] - height / 2.0) / focal[1] 9 | z = np.ones_like(x) 10 | dirs = np.stack([x, y, z], axis=-1) 11 | dirs = np.sum(rot[None,None,:,:] * dirs[...,None], axis=-2) # 1*1*3*3 x h*w*3*1 12 | dirs = dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5) 13 | 14 | return dirs 15 | 16 | 17 | def get_camera_rotation(eye, center, up): 18 | nz = center - eye 19 | nz /= np.linalg.norm(nz) 20 | x = np.cross(nz, up) 21 | x /= np.linalg.norm(x) 22 | y = np.cross(x, nz) 23 | return np.array([x, y, -nz]).T 24 | 25 | # 26 | # def get_blender_raydir(pixelcoords, height, width, focal, rot, dir_norm): 27 | # ## pixelcoords: H x W x 2 28 | # x = (pixelcoords[..., 0] - width / 2.0) / focal 29 | # y = (pixelcoords[..., 1] - height / 2.0) / focal 30 | # z = np.ones_like(x) 31 | # dirs = np.stack([x, -y, -z], axis=-1) 32 | # dirs = np.sum(dirs[...,None,:] * rot[:,:], axis=-1) # 32, 32, 3 33 | # if dir_norm: 34 | # # print("dirs",dirs-dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5)) 35 | # dirs = dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5) 36 | # # print("dirs", dirs.shape) 37 | # 38 | # return dirs 39 | 40 | 41 | def get_blender_raydir(pixelcoords, height, width, focal, rot, dir_norm): 42 | ## pixelcoords: H x W x 2 43 | x = (pixelcoords[..., 0] + 0.5 - width / 2.0) / focal 44 | y = (pixelcoords[..., 1] + 0.5 - height / 2.0) / focal 45 | z = np.ones_like(x) 46 | dirs = np.stack([x, -y, -z], axis=-1) 47 | dirs = np.sum(dirs[...,None,:] * rot[:,:], axis=-1) # h*w*1*3 x 3*3 48 | if dir_norm: 49 | # print("dirs",dirs-dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5)) 50 | dirs = dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5) 51 | # print("dirs", dirs.shape) 52 | 53 | return dirs 54 | 55 | def get_dtu_raydir(pixelcoords, intrinsic, rot, dir_norm): 56 | # rot is c2w 57 | ## pixelcoords: H x W x 2 58 | x = (pixelcoords[..., 0] + 0.5 - intrinsic[0, 2]) / intrinsic[0, 0] 59 | y = (pixelcoords[..., 1] + 0.5 - intrinsic[1, 2]) / intrinsic[1, 1] 60 | z = np.ones_like(x) 61 | dirs = np.stack([x, y, z], axis=-1) 62 | # dirs = np.sum(dirs[...,None,:] * rot[:,:], axis=-1) # h*w*1*3 x 3*3 63 | dirs = dirs @ rot[:,:].T # 64 | if dir_norm: 65 | # print("dirs",dirs-dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5)) 66 | dirs = dirs / (np.linalg.norm(dirs, axis=-1, keepdims=True) + 1e-5) 67 | # print("dirs", dirs.shape) 68 | 69 | return dirs 70 | 71 | 72 | def get_optix_raydir(pixelcoords, height, width, focal, eye, center, up): 73 | c2w = get_camera_rotation(eye, center, up) 74 | return get_blender_raydir(pixelcoords, height, width, focal, c2w) 75 | 76 | 77 | def flip_z(poses): 78 | z_flip_matrix = np.eye(4, dtype=np.float32) 79 | z_flip_matrix[2, 2] = -1.0 80 | return np.matmul(poses, z_flip_matrix[None,...]) 81 | 82 | 83 | def triangluation_bpa(pnts, test_pnts=None, full_comb=False): 84 | pcd = o3d.geometry.PointCloud() 85 | pcd.points = o3d.utility.Vector3dVector(pnts[:, :3]) 86 | pcd.normals = o3d.utility.Vector3dVector(pnts[:, :3] / np.linalg.norm(pnts[:, :3], axis=-1, keepdims=True)) 87 | 88 | # pcd.colors = o3d.utility.Vector3dVector(pnts[:, 3:6] / 255) 89 | # pcd.normals = o3d.utility.Vector3dVector(pnts[:, 6:9]) 90 | # o3d.visualization.draw_geometries([pcd]) 91 | 92 | distances = pcd.compute_nearest_neighbor_distance() 93 | avg_dist = np.mean(distances) 94 | 95 | 96 | radius = 3 * avg_dist 97 | dec_mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd, o3d.utility.DoubleVector( 98 | [radius, radius * 2])) 99 | # dec_mesh = dec_mesh.simplify_quadric_decimation(100000) 100 | # dec_mesh.remove_degenerate_triangles() 101 | # dec_mesh.remove_duplicated_triangles() 102 | # dec_mesh.remove_duplicated_vertices() 103 | # dec_mesh.remove_non_manifold_edges() 104 | 105 | # vis_lst = [dec_mesh, pcd] 106 | # vis_lst = [dec_mesh, pcd] 107 | # o3d.visualization.draw_geometries(vis_lst) 108 | # if test_pnts is not None : 109 | # tpcd = o3d.geometry.PointCloud() 110 | # print("test_pnts",test_pnts.shape) 111 | # tpcd.points = o3d.utility.Vector3dVector(test_pnts[:, :3]) 112 | # tpcd.normals = o3d.utility.Vector3dVector(test_pnts[:, :3] / np.linalg.norm(test_pnts[:, :3], axis=-1, keepdims=True)) 113 | # o3d.visualization.draw_geometries([dec_mesh, tpcd] ) 114 | triangles = np.asarray(dec_mesh.triangles, dtype=np.int32) 115 | if full_comb: 116 | q, w, e = triangles[..., 0], triangles[..., 1], triangles[..., 2] 117 | triangles2 = np.stack([w,q,e], axis=-1) 118 | triangles3 = np.stack([e,q,w], axis=-1) 119 | triangles = np.concatenate([triangles, triangles2, triangles3], axis=0) 120 | return triangles 121 | 122 | -------------------------------------------------------------------------------- /data/dtu_configs/dtu_finetune_init_pairs.txt: -------------------------------------------------------------------------------- 1 | 16 2 | 25 3 | 26,31,14,22 4 | 21 5 | 36,22,35,16 6 | 33 7 | 34,31,43,22 8 | 22 9 | 34,21,16,35 10 | 14 11 | 25,15,26,29 12 | 15 13 | 14,16,22,26 14 | 26 15 | 30,25,29,22 16 | 30 17 | 26,29,31,33 18 | 31 19 | 25,21,26,33 20 | 35 21 | 34,36,22,16 22 | 34 23 | 33,35,22,25 24 | 43 25 | 33,34,46,31 26 | 46 27 | 30,31,29,43 28 | 29 29 | 30,26,46,31 30 | 16 31 | 14,22,21,25 32 | 36 33 | 35,21,22,43 -------------------------------------------------------------------------------- /data/dtu_configs/dtu_pairs.txt: -------------------------------------------------------------------------------- 1 | 49 2 | 0 3 | 10 10 2346.41 1 2036.53 9 1243.89 12 1052.87 11 1000.84 13 703.583 2 604.456 8 439.759 14 327.419 27 249.278 4 | 1 5 | 10 9 2850.87 10 2583.94 2 2105.59 0 2052.84 8 1868.24 13 1184.23 14 1017.51 12 961.966 7 670.208 15 657.218 6 | 2 7 | 10 8 2501.24 1 2106.88 7 1856.5 9 1782.34 3 1141.77 15 1061.76 14 815.457 16 762.153 6 709.789 10 699.921 8 | 3 9 | 10 7 1294.39 6 1159.13 2 1134.27 4 905.717 8 687.32 5 600.015 17 496.958 16 481.969 1 379.011 15 307.45 10 | 4 11 | 10 5 1333.74 6 1145.15 3 895.254 7 486.504 18 446.42 2 418.517 17 326.528 8 161.115 16 149.154 1 103.626 12 | 5 13 | 10 6 1676.06 18 1555.06 4 1335.55 17 868.416 3 593.755 7 467.816 20 440.579 19 428.255 16 242.327 21 210.253 14 | 6 15 | 10 17 2332.35 7 1848.24 18 1812.74 5 1696.07 16 1273 3 1157.99 4 1155.41 20 771.624 21 744.945 2 700.368 16 | 7 17 | 10 16 2709.46 8 2439.7 15 2078.21 6 1864.16 2 1846.6 17 1791.71 3 1296.86 22 957.793 9 879.088 21 782.277 18 | 8 19 | 10 15 3124.01 9 3099.92 14 2756.29 2 2501.22 7 2449.32 1 1875.94 16 1726.04 13 1325.76 23 1177.09 24 1108.82 20 | 9 21 | 10 13 3355.62 14 3226.07 8 3098.8 10 3097.07 1 2861.42 12 1873.63 2 1785.98 15 1753.32 25 1365.45 0 1261.59 22 | 10 23 | 10 12 3750.7 9 3085.87 13 3028.39 1 2590.55 0 2369.79 11 2266.67 14 1524.16 26 1448.15 27 1293.6 8 1041.84 24 | 11 25 | 10 12 3543.76 27 3056.05 10 2248.07 26 1524.28 28 1273.33 13 1265.9 29 1129.55 0 998.164 9 591.176 30 572.919 26 | 12 27 | 10 27 3889.87 10 3754.54 13 3745.21 11 3584.26 26 3574.56 25 1877.11 9 1866.34 29 1482.72 30 1418.51 14 1341.86 28 | 13 29 | 10 12 3773.14 26 3699.28 25 3657.17 14 3652.04 9 3356.29 10 3049.27 24 2098.91 27 1900.96 31 1460.96 30 1349.62 30 | 14 31 | 10 13 3663.52 24 3610.69 9 3232.55 25 3216.4 15 3128.84 8 2758.04 23 2219.91 26 1567.45 10 1536.6 32 1419.33 32 | 15 33 | 10 23 3194.92 14 3126 8 3120.43 16 2897.02 24 2562.49 7 2084.05 22 2041.63 9 1752.08 33 1232.29 13 1137.55 34 | 16 35 | 10 15 2884.14 7 2713.88 22 2708.57 17 2448.5 21 2173.3 23 1908.03 8 1718.79 6 1281.96 35 1047.38 34 980.064 36 | 17 37 | 10 21 2632.48 16 2428 6 2343.57 18 2250.23 20 2149.75 7 1779.42 22 1380.25 36 957.046 5 878.398 15 789.068 38 | 18 39 | 10 17 2219.15 20 2173.02 6 1802.39 19 1575.77 5 1564.81 21 1160.13 37 827.951 16 660.317 7 589.484 36 559.983 40 | 19 41 | 10 20 1828.97 18 1564.63 37 1474.35 17 685.249 38 620.304 36 613.42 21 572.77 39 499.123 5 427.597 6 368.651 42 | 20 43 | 10 37 2569.8 21 2569.79 36 2258.33 18 2186.71 17 2130.67 19 1865.06 39 1049.03 35 996.122 16 799.808 40 778.721 44 | 21 45 | 10 36 2704.59 35 2639.69 17 2638.19 20 2605.43 22 2604.26 16 2158.25 37 1446.49 34 1239.25 18 1178.24 40 1128.57 46 | 22 47 | 10 23 3232.68 34 3175.15 35 2831.09 16 2712.51 21 2632.19 15 2033.39 33 1712.67 17 1393.86 36 1290.96 24 1195.33 48 | 23 49 | 10 24 3710.9 33 3603.07 22 3244.2 15 3190.62 34 3086.49 14 2220.11 32 2100 16 1917.1 35 1359.79 25 1356.71 50 | 24 51 | 10 25 3844.6 32 3750.75 23 3710.6 14 3609.09 33 3091.04 15 2559.24 31 2423.71 13 2109.36 26 1440.58 34 1410.03 52 | 25 53 | 10 26 3951.74 31 3888.57 24 3833.07 13 3667.35 14 3208.21 32 2993.46 30 2681.52 12 1900.23 45 1484.03 27 1462.88 54 | 26 55 | 10 30 4033.35 27 3970.47 25 3925.25 13 3686.34 12 3595.59 29 2943.87 31 2917 14 1556.34 11 1554.75 46 1503.84 56 | 27 57 | 10 29 4027.84 26 3929.94 12 3875.58 11 3085.03 28 2908.6 30 2792.67 13 1878.42 25 1438.55 47 1425.2 10 1290.25 58 | 28 59 | 10 29 3687.02 48 3209.13 27 2872.86 47 2014.53 30 1361.95 11 1273.6 26 1062.85 12 840.841 46 672.985 31 271.952 60 | 29 61 | 10 27 4029.43 30 3909.55 28 3739.93 47 3695.23 48 3135.87 26 2910.97 46 2229.55 12 1479.16 31 1430.26 11 1144.56 62 | 30 63 | 10 26 4029.86 29 3953.72 31 3811.12 46 3630.46 47 3105.96 27 2824.43 25 2657.89 45 2347.75 32 1459.11 12 1429.62 64 | 31 65 | 10 25 3882.21 30 3841.88 32 3808.5 45 3649.82 46 3000.67 26 2939.94 24 2409.93 44 2381.3 13 1467.59 29 1459.56 66 | 32 67 | 10 31 3826.5 24 3744.14 33 3613.24 44 3552.04 25 3004.6 45 2884.59 43 2393.34 23 2095.27 30 1478.6 14 1420.78 68 | 33 69 | 10 32 3618.11 23 3598.1 34 3530.53 43 3462.37 24 3091.53 44 2608.08 42 2426 22 1717.94 31 1407.65 25 1324.78 70 | 34 71 | 10 33 3523.37 42 3356.55 35 3210.34 22 3178.85 23 3079.03 43 2396.45 41 2386.86 24 1408.02 32 1301.34 21 1256.45 72 | 35 73 | 10 34 3187.88 41 3106.44 36 2866.04 22 2817.74 21 2654.87 40 2416.98 42 2137.81 23 1346.86 33 1150.33 16 1044.66 74 | 36 75 | 10 40 2910.7 35 2832.66 21 2689.96 37 2641.43 39 2349.53 20 2280.46 41 1787.97 22 1268.49 34 981.636 17 954.229 76 | 37 77 | 10 39 2678.55 36 2602.5 20 2558.22 38 1854.56 40 1611.7 19 1498.88 21 1419.51 35 902.641 18 826.803 17 680.253 78 | 38 79 | 10 39 2189.15 37 1834.05 40 824.669 36 771.589 19 622.648 20 590.632 21 190.621 41 157.673 35 155.716 18 134.943 80 | 39 81 | 10 40 2741.73 37 2690.66 36 2322.38 38 2228 20 1046.1 41 983.275 35 883.261 21 693.084 19 509.504 42 193.016 82 | 40 83 | 10 36 2918.14 41 2852.62 39 2782.6 35 2392.96 37 1641.45 21 1124.3 42 1056.48 34 877.946 38 853.944 20 788.701 84 | 41 85 | 10 35 3111.05 42 3049.71 40 2885.36 34 2371.02 36 1813.69 43 1164.71 22 1126.9 39 1011.26 21 906.536 33 903.238 86 | 42 87 | 10 34 3356.98 43 3183 41 3070.54 33 2421.77 35 2155.08 44 1278.41 23 1183.52 22 1147.07 40 1077.08 32 899.646 88 | 43 89 | 10 33 3461.24 44 3380.74 42 3188.7 34 2400.6 32 2399.09 45 1359.37 23 1314.08 41 1176.12 24 1159.62 31 901.556 90 | 44 91 | 10 32 3550.81 45 3510.16 43 3373.11 33 2602.33 31 2395.93 24 1410.43 46 1386.31 42 1279 25 1095.24 34 968.44 92 | 45 93 | 10 31 3650.09 46 3555.09 44 3491.15 32 2868.39 30 2373.59 25 1485.37 47 1405.28 43 1349.54 33 1104.77 26 1046.81 94 | 46 95 | 10 30 3635.64 47 3562.17 45 3524.17 31 2976.82 29 2264.04 26 1508.87 44 1367.41 48 1352.1 32 1211.24 25 1102.17 96 | 47 97 | 10 29 3705.31 46 3519.76 48 3450.48 30 3074.77 28 2054.63 27 1434.57 45 1377.34 31 1268.23 26 1223.83 25 471.111 98 | 48 99 | 10 47 3401.95 28 3224.84 29 3101.16 46 1317.1 30 1306.7 27 1235.07 26 537.731 31 291.919 45 276.869 11 258.856 100 | -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_test_all.txt: -------------------------------------------------------------------------------- 1 | scan29 2 | scan1 3 | scan2 4 | scan7 5 | scan8 6 | scan21 7 | scan30 8 | scan31 9 | scan34 10 | scan38 11 | scan39 12 | scan40 13 | scan41 14 | scan45 15 | scan51 16 | scan55 17 | scan56 18 | scan57 19 | scan58 20 | scan63 21 | scan82 22 | scan83 23 | scan103 24 | scan110 25 | scan111 26 | scan112 27 | scan113 28 | scan114 29 | scan115 30 | scan116 31 | scan117 -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_test_ground.txt: -------------------------------------------------------------------------------- 1 | scan29 0 2 | scan1 0 3 | scan2 0 4 | scan7 0 5 | scan8 0 6 | scan21 0 7 | scan30 0 8 | scan31 0 9 | scan34 0 10 | scan38 0 11 | scan39 0 12 | scan40 0 13 | scan41 0 14 | scan45 0 15 | scan51 0 16 | scan55 1 17 | scan56 1 18 | scan57 1 19 | scan58 1 20 | scan63 0 21 | scan82 0 22 | scan83 0 23 | scan103 0 24 | scan110 2 25 | scan111 2 26 | scan112 2 27 | scan113 2 28 | scan114 2 29 | scan115 2 30 | scan116 2 31 | scan117 2 -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_train_all.txt: -------------------------------------------------------------------------------- 1 | scan3 2 | scan4 3 | scan5 4 | scan6 5 | scan9 6 | scan10 7 | scan11 8 | scan12 9 | scan13 10 | scan14 11 | scan15 12 | scan16 13 | scan17 14 | scan18 15 | scan19 16 | scan20 17 | scan22 18 | scan23 19 | scan24 20 | scan28 21 | scan32 22 | scan33 23 | scan35 24 | scan36 25 | scan37 26 | scan42 27 | scan43 28 | scan44 29 | scan46 30 | scan47 31 | scan48 32 | scan49 33 | scan50 34 | scan52 35 | scan53 36 | scan59 37 | scan60 38 | scan61 39 | scan62 40 | scan64 41 | scan65 42 | scan66 43 | scan67 44 | scan68 45 | scan69 46 | scan70 47 | scan71 48 | scan72 49 | scan74 50 | scan75 51 | scan76 52 | scan77 53 | scan84 54 | scan85 55 | scan86 56 | scan87 57 | scan88 58 | scan89 59 | scan90 60 | scan91 61 | scan92 62 | scan93 63 | scan94 64 | scan95 65 | scan96 66 | scan97 67 | scan98 68 | scan99 69 | scan100 70 | scan101 71 | scan102 72 | scan104 73 | scan105 74 | scan106 75 | scan107 76 | scan108 77 | scan109 78 | scan118 79 | scan119 80 | scan120 81 | scan121 82 | scan122 83 | scan123 84 | scan124 85 | scan125 86 | scan126 87 | scan127 88 | scan128 -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_train_all_bk.txt: -------------------------------------------------------------------------------- 1 | scan3 2 | -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_train_ground.txt: -------------------------------------------------------------------------------- 1 | scan3 0 2 | scan4 0 3 | scan5 0 4 | scan6 0 5 | scan9 0 6 | scan10 0 7 | scan11 0 8 | scan12 0 9 | scan13 0 10 | scan14 0 11 | scan15 0 12 | scan16 0 13 | scan17 0 14 | scan18 0 15 | scan19 0 16 | scan20 0 17 | scan22 0 18 | scan23 0 19 | scan24 0 20 | scan28 0 21 | scan32 0 22 | scan33 0 23 | scan35 0 24 | scan36 0 25 | scan37 0 26 | scan42 0 27 | scan43 0 28 | scan44 0 29 | scan46 0 30 | scan47 0 31 | scan48 0 32 | scan49 0 33 | scan50 0 34 | scan52 0 35 | scan53 0 36 | scan59 0 37 | scan60 0 38 | scan61 0 39 | scan62 0 40 | scan64 0 41 | scan65 1 42 | scan66 1 43 | scan67 1 44 | scan68 1 45 | scan69 1 46 | scan70 1 47 | scan71 1 48 | scan72 1 49 | scan74 0 50 | scan75 0 51 | scan76 0 52 | scan77 0 53 | scan84 0 54 | scan85 1 55 | scan86 1 56 | scan87 1 57 | scan88 1 58 | scan89 1 59 | scan90 1 60 | scan91 1 61 | scan92 1 62 | scan93 0 63 | scan94 0 64 | scan95 0 65 | scan96 0 66 | scan97 0 67 | scan98 0 68 | scan99 0 69 | scan100 0 70 | scan101 0 71 | scan102 0 72 | scan104 0 73 | scan105 0 74 | scan106 1 75 | scan107 1 76 | scan108 1 77 | scan109 1 78 | scan118 1 79 | scan119 1 80 | scan120 1 81 | scan121 1 82 | scan122 1 83 | scan123 1 84 | scan124 1 85 | scan125 1 86 | scan126 1 87 | scan127 1 88 | scan128 1 -------------------------------------------------------------------------------- /data/dtu_configs/lists/dtu_val_all.txt: -------------------------------------------------------------------------------- 1 | scan1 2 | scan8 3 | scan21 4 | scan30 5 | scan31 6 | scan34 7 | scan38 8 | scan40 9 | scan41 10 | scan45 11 | scan55 12 | scan63 13 | scan82 14 | scan103 15 | scan110 16 | scan114 -------------------------------------------------------------------------------- /data/dtu_configs/pairs.th: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/data/dtu_configs/pairs.th -------------------------------------------------------------------------------- /data/fitplane.py: -------------------------------------------------------------------------------- 1 | from skspatial.objects import Plane 2 | from skspatial.objects import Points 3 | from skspatial.plotting import plot_3d 4 | from plyfile import PlyData, PlyElement 5 | import matplotlib.pyplot as plt 6 | 7 | import numpy as np 8 | # points = Points([[0, 0, 0], [1, 3, 5], [-5, 6, 3], [3, 6, 7], [-2, 6, 7]]) 9 | # plydata = PlyData.read("/home/xharlie/user_space/codes/testNr/checkpoints/fdtu_tryy/points/sample.ply") 10 | plydata = PlyData.read("/home/xharlie/user_space/codes/testNr/checkpoints/fdtu_normcam2_confcolordir_KNN8_LRelu_grid800_scan115_wbg_dmsk/points/light_brown_sample.ply") 11 | vertex_data = plydata['vertex'].data # numpy array with fields ['x', 'y', 'z'] 12 | pts = np.zeros([vertex_data.size, 3]) 13 | color = np.zeros_like(pts) 14 | pts[:, 0] = vertex_data['x'] 15 | pts[:, 1] = vertex_data['y'] 16 | pts[:, 2] = vertex_data['z'] 17 | # print(vertex_data) 18 | color[:, 0] = vertex_data['red'] 19 | color[:, 1] = vertex_data['green'] 20 | color[:, 2] = vertex_data['blue'] 21 | 22 | points = Points(pts) 23 | 24 | 25 | plane = Plane.best_fit(points) 26 | print("plane", plane, pts.shape) 27 | print("plane", plane.point, plane.normal) 28 | print("color average", np.mean(color, axis=0)) 29 | 30 | coord=plane.point 31 | coeff=plane.normal 32 | 33 | 34 | # Plane(point=Point([-0.49666997, 0.52160616, 3.6239593 ]), normal=Vector([-0.11364093, 0.38778102, 0.91471942])) (15565, 3) 35 | 36 | # a(x − x0) + b(y − y0) + c(z − z0) = 0 37 | 38 | 39 | r=8 40 | 41 | # a,b,c = coeff[0], coeff[1], coeff[2] 42 | # x0,y0,z0=coord[0],coord[1],coord[2], 43 | # xy = r * np.random.rand(int(1e5),2) - r/2 44 | # z = (a*(xy[...,0]-x0) + b*(xy[...,1]-y0))/(-c) + z0 45 | # gen_pnts = np.stack([xy[...,0], xy[...,1], z], axis=-1) 46 | # 47 | # np.savetxt('/home/xharlie/user_space/codes/testNr/checkpoints/fdtu_tryy/points/planes_white.txt', gen_pnts, delimiter=';') 48 | 49 | 50 | 51 | 52 | # plane Plane(point=Point([ 0.20770223, -0.74818161, 3.98697683]), normal=Vector([-0.11165793, 0.3806543 , 0.91795142])) (14801, 3) 53 | # plane [ 0.20770223 -0.74818161 3.98697683] [-0.11165793 0.3806543 0.91795142] 54 | # color average [150.72447808 99.68367002 63.40976961] 55 | 56 | a,b,c = coeff[0], coeff[1], coeff[2] 57 | x0,y0,z0=coord[0],coord[1],coord[2], 58 | xy = r * np.random.rand(int(1e5),2) - r/2 59 | z = (a*(xy[...,0]-x0) + b*(xy[...,1]-y0))/(-c) + z0 60 | gen_pnts = np.stack([xy[...,0], xy[...,1], z], axis=-1) 61 | color = np.ones_like(gen_pnts) * np.mean(color, axis=0, keepdims=True) 62 | gen_pnts = np.concatenate([gen_pnts, color], axis=-1) 63 | np.savetxt('/home/xharlie/user_space/codes/testNr/checkpoints/fdtu_normcam2_confcolordir_KNN8_LRelu_grid800_scan115_wbg_dmsk/points/planes_light_brown.txt', gen_pnts, delimiter=';') 64 | 65 | 66 | 67 | 68 | # plane Plane(point=Point([-0.04889537, -0.84123057, 4.03164617]), normal=Vector([-0.11154823, 0.3783277 , 0.91892608])) (30712, 3) 69 | # plane [-0.04889537 -0.84123057 4.03164617] [-0.11154823 0.3783277 0.91892608] 70 | 71 | # a,b,c = coeff[0], coeff[1], coeff[2] 72 | # x0,y0,z0=coord[0],coord[1],coord[2], 73 | # xy = r * np.random.rand(int(1e5),2) - r/2 74 | # z = (a*(xy[...,0]-x0) + b*(xy[...,1]-y0))/(-c) + z0 75 | # gen_pnts = np.stack([xy[...,0], xy[...,1], z], axis=-1) 76 | # color = np.ones_like(gen_pnts) * np.mean(color, axis=0, keepdims=True) 77 | # gen_pnts = np.concatenate([gen_pnts, color], axis=-1) 78 | # np.savetxt('/home/xharlie/user_space/codes/testNr/checkpoints/fdtu_normcam2_confcolordir_KNN8_LRelu_grid800_scan115_wbg_dmsk/points/planes_brown.txt', gen_pnts, delimiter=';') 79 | 80 | 81 | 82 | 83 | # gen_points = Points(gen_pnts) 84 | 85 | # fig = plt.figure() 86 | # ax = fig.add_subplot(111, projection='3d') 87 | # plot_3d( 88 | # gen_points.plotter(c='k', s=50, depthshade=False), 89 | # plane.plotter(alpha=0.2, lims_x=(-5, 5), lims_y=(-5, 5)), 90 | # ) 91 | # 92 | # plt.show() -------------------------------------------------------------------------------- /data/load_blender.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | import imageio 4 | import json 5 | import torch 6 | import pickle, random 7 | 8 | # trans_t = lambda t : tf.convert_to_tensor([ 9 | # [1,0,0,0], 10 | # [0,1,0,0], 11 | # [0,0,1,t], 12 | # [0,0,0,1], 13 | # ], dtype=tf.float32) 14 | # 15 | # rot_phi = lambda phi : tf.convert_to_tensor([ 16 | # [1,0,0,0], 17 | # [0,tf.cos(phi),-tf.sin(phi),0], 18 | # [0,tf.sin(phi), tf.cos(phi),0], 19 | # [0,0,0,1], 20 | # ], dtype=tf.float32) 21 | # 22 | # rot_theta = lambda th : tf.convert_to_tensor([ 23 | # [tf.cos(th),0,-tf.sin(th),0], 24 | # [0,1,0,0], 25 | # [tf.sin(th),0, tf.cos(th),0], 26 | # [0,0,0,1], 27 | # ], dtype=tf.float32) 28 | 29 | trans_t = lambda t : np.asarray([ 30 | [1,0,0,0], 31 | [0,1,0,0], 32 | [0,0,1,t], 33 | [0,0,0,1], 34 | ], dtype=np.float32) 35 | 36 | rot_phi = lambda phi : np.asarray([ 37 | [1,0,0,0], 38 | [0,np.cos(phi),-np.sin(phi),0], 39 | [0,np.sin(phi), np.cos(phi),0], 40 | [0,0,0,1], 41 | ], dtype=np.float32) 42 | 43 | rot_theta = lambda th : np.asarray([ 44 | [np.cos(th),0,-np.sin(th),0], 45 | [0,1,0,0], 46 | [np.sin(th),0, np.cos(th),0], 47 | [0,0,0,1], 48 | ], dtype=np.float32) 49 | 50 | 51 | def pose_spherical(theta, phi, radius): 52 | c2w = trans_t(radius) 53 | c2w = rot_phi(phi/180.*np.pi) @ c2w 54 | c2w = rot_theta(theta/180.*np.pi) @ c2w 55 | c2w = np.array([[-1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]]) @ c2w 56 | return c2w 57 | 58 | 59 | blender2opencv = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]) 60 | 61 | 62 | def load_blender_data(basedir, splits, half_res=False, testskip=1): 63 | splits = ['train', 'val', 'test'] if splits is None else splits 64 | metas = {} 65 | for s in splits: 66 | with open(os.path.join(basedir, 'transforms_{}.json'.format(s)), 'r') as fp: 67 | metas[s] = json.load(fp) 68 | 69 | all_imgs = [] 70 | all_poses = [] 71 | counts = [0] 72 | for s in splits: 73 | meta = metas[s] 74 | imgs = [] 75 | poses = [] 76 | if s=='train' or testskip==0: 77 | skip = 1 78 | else: 79 | skip = testskip 80 | 81 | for frame in meta['frames'][::skip]: 82 | fname = os.path.join(basedir, frame['file_path'] + '.png') 83 | imgs.append(imageio.imread(fname)) 84 | poses.append(np.array(frame['transform_matrix']) @ blender2opencv) 85 | 86 | imgs = (np.array(imgs) / 255.).astype(np.float32) # keep all 4 channels (RGBA) 87 | poses = np.array(poses).astype(np.float32) 88 | counts.append(counts[-1] + imgs.shape[0]) 89 | all_imgs.append(imgs) 90 | all_poses.append(poses) 91 | 92 | i_split = [np.arange(counts[i], counts[i+1]) for i in range(len(splits))] 93 | 94 | imgs = np.concatenate(all_imgs, 0) 95 | poses = np.concatenate(all_poses, 0) 96 | 97 | H, W = imgs[0].shape[:2] 98 | camera_angle_x = float(meta['camera_angle_x']) 99 | focal = .5 * W / np.tan(.5 * camera_angle_x) 100 | 101 | stride = 20 102 | render_poses = np.stack([pose_spherical(angle, -30.0, 4.0) for angle in np.linspace(-180, 180, stride+1)[:-1]],0) 103 | 104 | if half_res: 105 | imgs = tf.image.resize_area(imgs, [400, 400]).numpy() 106 | H = H//2 107 | W = W//2 108 | focal = focal/2. 109 | 110 | intrinsic = np.asarray([[focal, 0, W/2], 111 | [0, focal, H/2], 112 | [0,0,1]]) 113 | return imgs, poses, render_poses, [H, W, focal], i_split, intrinsic 114 | 115 | 116 | def load_blender_cloud(point_path, point_num): 117 | point_norms = None 118 | with open(point_path, 'rb') as f: 119 | print("point_file_path ################", point_path) 120 | all_infos = pickle.load(f) 121 | point_xyz = all_infos["point_xyz"] 122 | if "point_face_normal" in all_infos: 123 | point_norms = all_infos["point_face_normal"] 124 | print("surface point cloud ",len(point_xyz), "mean pos:", np.mean(point_xyz, axis=0), "min pos:",np.min(point_xyz, axis=0), "mean max:",np.max(point_xyz, axis=0)) 125 | if point_num < len(point_xyz): 126 | inds = np.asarray(random.choices(range(len(point_xyz)), k=point_num)) 127 | point_norms = point_norms[inds, :] if point_norms is not None else None 128 | return point_xyz[inds, :], point_norms 129 | else: 130 | return point_xyz, point_norms 131 | -------------------------------------------------------------------------------- /data/nerf_synth_configs/list/lego360_init_pairs.txt: -------------------------------------------------------------------------------- 1 | 26,42,0 2 | 26,42,41 3 | 75,64,41 4 | 41,64,42 5 | 0,1,42 6 | 42,41,89 7 | 89,98,42 8 | 72,74,17 9 | 52,53,90 10 | 10,8,53 -------------------------------------------------------------------------------- /data/nerf_synth_configs/list/lego_finetune_init_pairs.txt: -------------------------------------------------------------------------------- 1 | 16 2 | 6 3 | 33,43 4 | 33 5 | 43,49 6 | 43 7 | 49,20 8 | 49 9 | 43,30 10 | 20 11 | 33,46 12 | 17 13 | 25,19 14 | 25 15 | 17,59 16 | 59 17 | 25,30 18 | 19 19 | 13,17 20 | 46 21 | 48,20 22 | 48 23 | 46,37 24 | 13 25 | 19,55 26 | 30 27 | 37,59 28 | 37 29 | 30,49 30 | 55 31 | 65,13 32 | 65 33 | 55,46 -------------------------------------------------------------------------------- /data/nerf_synth_configs/list/lego_finetune_init_pairs_final.txt: -------------------------------------------------------------------------------- 1 | 16,25 2 | 6 3 | 33,43 4 | 33 5 | 43,49 6 | 43 7 | 49,20 8 | 49 9 | 43,30 10 | 20 11 | 33,46 12 | 17 13 | 25,19 14 | 25 15 | 17,59 16 | 59 17 | 25,30 18 | 19 19 | 13,17 20 | 46 21 | 48,20 22 | 48 23 | 46,37 24 | 13 25 | 19,55 26 | 30 27 | 37,59 28 | 37 29 | 30,49 30 | 55 31 | 65,13 32 | 65 33 | 55,46 34 | 13 35 | 20,65 36 | 65 37 | 55,13 38 | 65 39 | 20,55 40 | 65 41 | 48 42 | 48 43 | 37 44 | 37 45 | 48,20 46 | 49 47 | 37,48 48 | 37 49 | 48 50 | 37 51 | 48,46 -------------------------------------------------------------------------------- /dev_scripts/ete/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrCheckpoint="../checkpoints" 4 | nrDataRoot="../data_src" 5 | name='dtu_dgt_d012_img0123_conf_agg2_32_dirclr20' 6 | 7 | resume_iter=latest 8 | data_root="${nrDataRoot}/dtu" 9 | load_points=0 10 | feedforward=1 11 | vox_res=0 #800 12 | 13 | ref_vid=0 14 | bgmodel="no" #"plane" 15 | depth_occ=0 16 | depth_vid="012" 17 | trgt_id=3 18 | manual_depth_view=0 # use mvsnet pytorch 19 | init_view_num=3 20 | pre_d_est="${nrCheckpoint}/MVSNet/model_000015.ckpt" 21 | manual_std_depth=0.0 22 | depth_conf_thresh=0.1 23 | geo_cnsst_num=0 24 | appr_feature_str0="imgfeat_0_0123 dir_0 point_conf" 25 | appr_feature_str1="imgfeat_1_0123 dir_1 point_conf" 26 | appr_feature_str2="imgfeat_2_0123 dir_2 point_conf" 27 | appr_feature_str3="dir_3 point_conf" 28 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 29 | point_dir_mode="1" # 0 for only at features, 1 for color branch 30 | point_color_mode="1" # 0 for only at features, 1 for color branch 31 | 32 | agg_feat_xyz_mode="None" 33 | agg_alpha_xyz_mode="None" 34 | agg_color_xyz_mode="None" 35 | feature_init_method="rand" #"rand" # "zeros" 36 | agg_axis_weight=" 1. 1. 1." 37 | agg_dist_pers=20 38 | radius_limit_scale=4 39 | depth_limit_scale=0 40 | vscale=" 2 2 2 " 41 | kernel_size=" 5 5 5 " 42 | query_size=" 3 3 3 " 43 | vsize=" 0.002 0.002 0.002 " #" 0.005 0.005 0.005 " 44 | wcoord_query=1 45 | z_depth_dim=400 46 | max_o=400000 #2000000 47 | SR=40 48 | K=8 49 | P=20 #120 50 | NN=2 51 | 52 | act_type="LeakyReLU" 53 | 54 | agg_intrp_order=2 55 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 56 | weight_xyz_freq=2 57 | weight_feat_dim=8 58 | 59 | point_features_dim=32 60 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 61 | 62 | which_agg_model="viewmlp" 63 | apply_pnt_mask=1 64 | shading_feature_mlp_layer0=1 #2 65 | shading_feature_mlp_layer1=2 #2 66 | shading_feature_mlp_layer2=0 #1 67 | shading_feature_mlp_layer3=2 #1 68 | shading_alpha_mlp_layer=1 69 | shading_color_mlp_layer=4 70 | shading_feature_num=256 71 | dist_xyz_freq=5 72 | num_feat_freqs=3 73 | dist_xyz_deno=0 74 | 75 | 76 | raydist_mode_unit=1 77 | dataset_name='dtu' 78 | pin_data_in_memory=1 79 | model='mvs_points_volumetric' 80 | near_plane=2.0 81 | far_plane=6.0 82 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 83 | domain_size='1' 84 | dir_norm=0 85 | 86 | which_tonemap_func="off" #"gamma" # 87 | which_render_func='radiance' 88 | which_blend_func='alpha' 89 | out_channels=4 90 | 91 | num_pos_freqs=10 92 | num_viewdir_freqs=4 #6 93 | 94 | random_sample='random' 95 | random_sample_size=70 # 32 * 32 = 1024 96 | batch_size=1 97 | lr=0.0005 # 0.0005 #0.00015 98 | lr_policy="iter_exponential_decay" 99 | lr_decay_iters=500000 100 | gpu_ids='1' 101 | checkpoints_dir="${nrCheckpoint}/init" 102 | resume_dir="${checkpoints_dir}/${name}" 103 | 104 | save_iter_freq=30184 105 | save_point_freq=30184 #30184 #1 106 | maximum_step=250000 #800000 107 | niter=10000 #1000000 108 | niter_decay=10000 #250000 109 | n_threads=2 110 | train_and_test=0 #1 111 | test_freq=30184 #30184 #30184 #50000 112 | print_freq=40 113 | test_num_step=15 114 | zero_epsilon=1e-3 115 | 116 | visual_items='coarse_raycolor ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor gt_image gt_image_ray_masked ray_depth_masked_gt_image ' 117 | color_loss_weights="0.0 1.0" 118 | color_loss_items='ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor' 119 | test_color_loss_items='coarse_raycolor ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor' 120 | 121 | bg_color="black" 122 | split="train" 123 | 124 | cd run 125 | python3 train.py \ 126 | --experiment $name \ 127 | --data_root $data_root \ 128 | --dataset_name $dataset_name \ 129 | --model $model \ 130 | --which_render_func $which_render_func \ 131 | --which_blend_func $which_blend_func \ 132 | --out_channels $out_channels \ 133 | --num_pos_freqs $num_pos_freqs \ 134 | --num_viewdir_freqs $num_viewdir_freqs \ 135 | --random_sample $random_sample \ 136 | --random_sample_size $random_sample_size \ 137 | --batch_size $batch_size \ 138 | --maximum_step $maximum_step \ 139 | --lr $lr \ 140 | --lr_policy $lr_policy \ 141 | --lr_decay_iters $lr_decay_iters \ 142 | --gpu_ids $gpu_ids \ 143 | --checkpoints_dir $checkpoints_dir \ 144 | --save_iter_freq $save_iter_freq \ 145 | --niter $niter \ 146 | --niter_decay $niter_decay \ 147 | --n_threads $n_threads \ 148 | --pin_data_in_memory $pin_data_in_memory \ 149 | --train_and_test $train_and_test \ 150 | --test_freq $test_freq \ 151 | --test_num_step $test_num_step \ 152 | --test_color_loss_items $test_color_loss_items \ 153 | --print_freq $print_freq \ 154 | --bg_color $bg_color \ 155 | --split $split \ 156 | --which_ray_generation $which_ray_generation \ 157 | --near_plane $near_plane \ 158 | --far_plane $far_plane \ 159 | --dir_norm $dir_norm \ 160 | --which_tonemap_func $which_tonemap_func \ 161 | --load_points $load_points \ 162 | --resume_dir $resume_dir \ 163 | --resume_iter $resume_iter \ 164 | --feature_init_method $feature_init_method \ 165 | --agg_axis_weight $agg_axis_weight \ 166 | --agg_distance_kernel $agg_distance_kernel \ 167 | --radius_limit_scale $radius_limit_scale \ 168 | --depth_limit_scale $depth_limit_scale \ 169 | --vscale $vscale \ 170 | --kernel_size $kernel_size \ 171 | --SR $SR \ 172 | --K $K \ 173 | --P $P \ 174 | --NN $NN \ 175 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 176 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 177 | --agg_color_xyz_mode $agg_color_xyz_mode \ 178 | --save_point_freq $save_point_freq \ 179 | --raydist_mode_unit $raydist_mode_unit \ 180 | --agg_dist_pers $agg_dist_pers \ 181 | --agg_intrp_order $agg_intrp_order \ 182 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 183 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 184 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 185 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 186 | --shading_feature_num $shading_feature_num \ 187 | --dist_xyz_freq $dist_xyz_freq \ 188 | --shpnt_jitter $shpnt_jitter \ 189 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 190 | --shading_color_mlp_layer $shading_color_mlp_layer \ 191 | --which_agg_model $which_agg_model \ 192 | --num_feat_freqs $num_feat_freqs \ 193 | --dist_xyz_deno $dist_xyz_deno \ 194 | --apply_pnt_mask $apply_pnt_mask \ 195 | --point_features_dim $point_features_dim \ 196 | --color_loss_items $color_loss_items \ 197 | --color_loss_weights $color_loss_weights \ 198 | --feedforward $feedforward \ 199 | --trgt_id $trgt_id \ 200 | --depth_vid $depth_vid \ 201 | --ref_vid $ref_vid \ 202 | --manual_depth_view $manual_depth_view \ 203 | --pre_d_est $pre_d_est \ 204 | --depth_occ $depth_occ \ 205 | --manual_std_depth $manual_std_depth \ 206 | --visual_items $visual_items \ 207 | --appr_feature_str0 $appr_feature_str0 \ 208 | --appr_feature_str1 $appr_feature_str1 \ 209 | --appr_feature_str2 $appr_feature_str2 \ 210 | --appr_feature_str3 $appr_feature_str3 \ 211 | --act_type $act_type \ 212 | --point_conf_mode $point_conf_mode \ 213 | --point_dir_mode $point_dir_mode \ 214 | --point_color_mode $point_color_mode \ 215 | --depth_conf_thresh $depth_conf_thresh \ 216 | --geo_cnsst_num $geo_cnsst_num \ 217 | --bgmodel $bgmodel \ 218 | --vox_res $vox_res \ 219 | --vsize $vsize \ 220 | --wcoord_query $wcoord_query \ 221 | --max_o $max_o \ 222 | --debug 223 | 224 | -------------------------------------------------------------------------------- /dev_scripts/ete/dtu_dgt_d012_img0123_conf_color_dir_agg2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrCheckpoint="../checkpoints/init" 4 | nrDataRoot="../data_src" 5 | name='dtu_dgt_d012_img0123_conf_color_dir_agg2' 6 | 7 | resume_iter=latest 8 | data_root="${nrDataRoot}/dtu" 9 | 10 | load_points=0 11 | feedforward=1 12 | vox_res=0 #800 13 | 14 | ref_vid=0 15 | bgmodel="no" #"plane" 16 | depth_occ=0 17 | depth_vid="012" 18 | trgt_id=3 19 | manual_depth_view=0 # use mvsnet pytorch 20 | init_view_num=3 21 | pre_d_est="${nrCheckpoint}/MVSNet/model_000015.ckpt" 22 | manual_std_depth=0.0 23 | depth_conf_thresh=0.1 24 | geo_cnsst_num=0 25 | appr_feature_str0="imgfeat_0_0123 dir_0 point_conf" 26 | appr_feature_str1="imgfeat_1_0123 dir_1 point_conf" 27 | appr_feature_str2="imgfeat_2_0123 dir_2 point_conf" 28 | appr_feature_str3="dir_3 point_conf" 29 | point_conf_mode="01" # 0 for only at features, 1 for multi at weight 30 | point_dir_mode="01" # 0 for only at features, 1 for color branch 31 | point_color_mode="01" # 0 for only at features, 1 for color branch 32 | 33 | agg_feat_xyz_mode="None" 34 | agg_alpha_xyz_mode="None" 35 | agg_color_xyz_mode="None" 36 | feature_init_method="rand" #"rand" # "zeros" 37 | agg_axis_weight=" 1. 1. 1." 38 | agg_dist_pers=20 39 | radius_limit_scale=0 40 | depth_limit_scale=0 41 | vscale=" 2 2 1 " 42 | kernel_size=" 3 3 3 " 43 | SR=40 44 | K=8 45 | P=20 46 | NN=2 47 | 48 | agg_intrp_order=2 49 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 50 | weight_xyz_freq=2 51 | weight_feat_dim=8 52 | 53 | point_features_dim=63 54 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 55 | 56 | which_agg_model="viewmlp" 57 | apply_pnt_mask=1 58 | shading_feature_mlp_layer1=2 #2 59 | shading_feature_mlp_layer2=0 #1 60 | shading_feature_mlp_layer3=2 #1 61 | shading_alpha_mlp_layer=1 62 | shading_color_mlp_layer=4 63 | shading_feature_num=256 64 | dist_xyz_freq=5 65 | num_feat_freqs=3 66 | dist_xyz_deno=0 67 | 68 | 69 | raydist_mode_unit=1 70 | dataset_name='dtu' 71 | pin_data_in_memory=1 72 | model='mvs_points_volumetric' 73 | near_plane=2.0 74 | far_plane=6.0 75 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 76 | domain_size='1' 77 | dir_norm=0 78 | 79 | which_tonemap_func="off" #"gamma" # 80 | which_render_func='radiance' 81 | which_blend_func='alpha' 82 | out_channels=4 83 | 84 | num_pos_freqs=10 85 | num_viewdir_freqs=4 #6 86 | 87 | random_sample='random' 88 | 89 | random_sample_size=48 # 32 * 32 = 1024 90 | batch_size=1 91 | 92 | lr=0.0005 # 0.0005 #0.00015 93 | lr_policy="iter_exponential_decay" 94 | lr_decay_iters=500000 95 | 96 | gpu_ids='3' 97 | 98 | checkpoints_dir="${nrCheckpoint}/init" 99 | resume_dir="${checkpoints_dir}/${name}" 100 | 101 | save_iter_freq=30184 102 | save_point_freq=30184 #30184 #1 103 | maximum_step=250000 #800000 104 | 105 | niter=10000 #1000000 106 | niter_decay=10000 #250000 107 | n_threads=2 108 | 109 | train_and_test=0 #1 110 | test_num=1 #10 111 | test_freq=30184 #30184 #30184 #50000 112 | print_freq=40 113 | test_num_step=15 114 | 115 | zero_epsilon=1e-3 116 | 117 | visual_items='coarse_raycolor ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor gt_image gt_image_ray_masked ray_depth_masked_gt_image ' 118 | 119 | color_loss_weights="0.0 1.0" 120 | color_loss_items='ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor' 121 | test_color_loss_items='coarse_raycolor ray_masked_coarse_raycolor ray_depth_masked_coarse_raycolor' 122 | 123 | act_type="LeakyReLU" 124 | 125 | bg_color="black" 126 | split="train" 127 | 128 | cd run 129 | python3 train.py \ 130 | --experiment $name \ 131 | --data_root $data_root \ 132 | --dataset_name $dataset_name \ 133 | --model $model \ 134 | --which_render_func $which_render_func \ 135 | --which_blend_func $which_blend_func \ 136 | --out_channels $out_channels \ 137 | --num_pos_freqs $num_pos_freqs \ 138 | --num_viewdir_freqs $num_viewdir_freqs \ 139 | --random_sample $random_sample \ 140 | --random_sample_size $random_sample_size \ 141 | --batch_size $batch_size \ 142 | --maximum_step $maximum_step \ 143 | --lr $lr \ 144 | --lr_policy $lr_policy \ 145 | --lr_decay_iters $lr_decay_iters \ 146 | --gpu_ids $gpu_ids \ 147 | --checkpoints_dir $checkpoints_dir \ 148 | --save_iter_freq $save_iter_freq \ 149 | --niter $niter \ 150 | --niter_decay $niter_decay \ 151 | --n_threads $n_threads \ 152 | --pin_data_in_memory $pin_data_in_memory \ 153 | --train_and_test $train_and_test \ 154 | --test_num $test_num \ 155 | --test_freq $test_freq \ 156 | --test_num_step $test_num_step \ 157 | --test_color_loss_items $test_color_loss_items \ 158 | --print_freq $print_freq \ 159 | --bg_color $bg_color \ 160 | --split $split \ 161 | --which_ray_generation $which_ray_generation \ 162 | --near_plane $near_plane \ 163 | --far_plane $far_plane \ 164 | --dir_norm $dir_norm \ 165 | --which_tonemap_func $which_tonemap_func \ 166 | --load_points $load_points \ 167 | --resume_dir $resume_dir \ 168 | --resume_iter $resume_iter \ 169 | --feature_init_method $feature_init_method \ 170 | --agg_axis_weight $agg_axis_weight \ 171 | --agg_distance_kernel $agg_distance_kernel \ 172 | --radius_limit_scale $radius_limit_scale \ 173 | --depth_limit_scale $depth_limit_scale \ 174 | --vscale $vscale \ 175 | --kernel_size $kernel_size \ 176 | --SR $SR \ 177 | --K $K \ 178 | --P $P \ 179 | --NN $NN \ 180 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 181 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 182 | --agg_color_xyz_mode $agg_color_xyz_mode \ 183 | --save_point_freq $save_point_freq \ 184 | --raydist_mode_unit $raydist_mode_unit \ 185 | --agg_dist_pers $agg_dist_pers \ 186 | --agg_intrp_order $agg_intrp_order \ 187 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 188 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 189 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 190 | --shading_feature_num $shading_feature_num \ 191 | --dist_xyz_freq $dist_xyz_freq \ 192 | --shpnt_jitter $shpnt_jitter \ 193 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 194 | --shading_color_mlp_layer $shading_color_mlp_layer \ 195 | --which_agg_model $which_agg_model \ 196 | --num_feat_freqs $num_feat_freqs \ 197 | --dist_xyz_deno $dist_xyz_deno \ 198 | --apply_pnt_mask $apply_pnt_mask \ 199 | --point_features_dim $point_features_dim \ 200 | --color_loss_items $color_loss_items \ 201 | --color_loss_weights $color_loss_weights \ 202 | --feedforward $feedforward \ 203 | --trgt_id $trgt_id \ 204 | --depth_vid $depth_vid \ 205 | --ref_vid $ref_vid \ 206 | --manual_depth_view $manual_depth_view \ 207 | --pre_d_est $pre_d_est \ 208 | --depth_occ $depth_occ \ 209 | --manual_std_depth $manual_std_depth \ 210 | --visual_items $visual_items \ 211 | --appr_feature_str0 $appr_feature_str0 \ 212 | --appr_feature_str1 $appr_feature_str1 \ 213 | --appr_feature_str2 $appr_feature_str2 \ 214 | --appr_feature_str3 $appr_feature_str3 \ 215 | --act_type $act_type \ 216 | --point_conf_mode $point_conf_mode \ 217 | --point_dir_mode $point_dir_mode \ 218 | --point_color_mode $point_color_mode \ 219 | --depth_conf_thresh $depth_conf_thresh \ 220 | --geo_cnsst_num $geo_cnsst_num \ 221 | --bgmodel $bgmodel \ 222 | --vox_res $vox_res \ 223 | --debug 224 | 225 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/chair_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='chair' 5 | 6 | resume_iter=200000 # 20000 7 | 8 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 9 | scan="chair" 10 | 11 | normview=0 12 | bgmodel="no" #"plane" 13 | trgt_id=0 14 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 15 | point_dir_mode="1" # 0 for only at features, 1 for color branch 16 | point_color_mode="1" # 0 for only at features, 1 for color branch 17 | 18 | agg_feat_xyz_mode="None" 19 | agg_alpha_xyz_mode="None" 20 | agg_color_xyz_mode="None" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | alpha_range=0 26 | 27 | vscale=" 2 2 2 " 28 | kernel_size=" 3 3 3 " 29 | query_size=" 3 3 3 " 30 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 31 | wcoord_query=1 32 | z_depth_dim=400 33 | max_o=410000 #2000000 34 | ranges=" -0.721 -0.695 -0.995 0.658 0.706 1.050 " 35 | SR=80 36 | K=8 37 | P=12 #120 38 | NN=2 39 | 40 | act_type="LeakyReLU" 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | 63 | raydist_mode_unit=1 64 | dataset_name='nerf_synth360_ft' 65 | pin_data_in_memory=1 66 | model='mvs_points_volumetric' 67 | near_plane=2.0 68 | far_plane=6.0 69 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 70 | domain_size='1' 71 | dir_norm=0 72 | 73 | which_tonemap_func="off" 74 | which_render_func='radiance' 75 | which_blend_func='alpha' 76 | out_channels=4 77 | 78 | num_pos_freqs=10 79 | num_viewdir_freqs=4 #6 80 | 81 | random_sample='random' 82 | random_sample_size=60 #94 #48 # 32 * 32 = 1024 83 | batch_size=1 84 | gpu_ids='0' 85 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 86 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 87 | 88 | n_threads=1 89 | test_num_step=1 90 | 91 | zero_epsilon=1e-3 92 | visual_items=' coarse_raycolor gt_image ' 93 | color_loss_weights=" 1.0 0.0 0.0 " 94 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 95 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 96 | 97 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 98 | split="train" 99 | cd run 100 | 101 | python3 test_ft.py \ 102 | --experiment $name \ 103 | --scan $scan \ 104 | --data_root $data_root \ 105 | --dataset_name $dataset_name \ 106 | --model $model \ 107 | --which_render_func $which_render_func \ 108 | --which_blend_func $which_blend_func \ 109 | --out_channels $out_channels \ 110 | --num_pos_freqs $num_pos_freqs \ 111 | --num_viewdir_freqs $num_viewdir_freqs \ 112 | --random_sample $random_sample \ 113 | --random_sample_size $random_sample_size \ 114 | --batch_size $batch_size \ 115 | --gpu_ids $gpu_ids \ 116 | --checkpoints_dir $checkpoints_dir \ 117 | --n_threads $n_threads \ 118 | --pin_data_in_memory $pin_data_in_memory \ 119 | --test_num_step $test_num_step \ 120 | --test_color_loss_items $test_color_loss_items \ 121 | --bg_color $bg_color \ 122 | --split $split \ 123 | --which_ray_generation $which_ray_generation \ 124 | --near_plane $near_plane \ 125 | --far_plane $far_plane \ 126 | --dir_norm $dir_norm \ 127 | --which_tonemap_func $which_tonemap_func \ 128 | --resume_dir $resume_dir \ 129 | --resume_iter $resume_iter \ 130 | --agg_axis_weight $agg_axis_weight \ 131 | --agg_distance_kernel $agg_distance_kernel \ 132 | --radius_limit_scale $radius_limit_scale \ 133 | --depth_limit_scale $depth_limit_scale \ 134 | --vscale $vscale \ 135 | --kernel_size $kernel_size \ 136 | --SR $SR \ 137 | --K $K \ 138 | --P $P \ 139 | --NN $NN \ 140 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 141 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 142 | --agg_color_xyz_mode $agg_color_xyz_mode \ 143 | --raydist_mode_unit $raydist_mode_unit \ 144 | --agg_dist_pers $agg_dist_pers \ 145 | --agg_intrp_order $agg_intrp_order \ 146 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 147 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 148 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 149 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 150 | --shading_feature_num $shading_feature_num \ 151 | --dist_xyz_freq $dist_xyz_freq \ 152 | --shpnt_jitter $shpnt_jitter \ 153 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 154 | --shading_color_mlp_layer $shading_color_mlp_layer \ 155 | --which_agg_model $which_agg_model \ 156 | --color_loss_weights $color_loss_weights \ 157 | --num_feat_freqs $num_feat_freqs \ 158 | --dist_xyz_deno $dist_xyz_deno \ 159 | --apply_pnt_mask $apply_pnt_mask \ 160 | --point_features_dim $point_features_dim \ 161 | --color_loss_items $color_loss_items \ 162 | --trgt_id $trgt_id \ 163 | --visual_items $visual_items \ 164 | --bgmodel $bgmodel \ 165 | --act_type $act_type \ 166 | --point_conf_mode $point_conf_mode \ 167 | --point_dir_mode $point_dir_mode \ 168 | --point_color_mode $point_color_mode \ 169 | --normview $normview \ 170 | --alpha_range $alpha_range \ 171 | --ranges $ranges \ 172 | --vsize $vsize \ 173 | --wcoord_query $wcoord_query \ 174 | --max_o $max_o \ 175 | --debug 176 | 177 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/drums_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='drums' 5 | 6 | resume_iter=200000 # 20000 7 | 8 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 9 | scan="drums" 10 | normview=0 11 | 12 | bgmodel="no" #"plane" 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | feature_init_method="rand" #"rand" # "zeros" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | alpha_range=0 26 | 27 | vscale=" 2 2 2 " 28 | kernel_size=" 3 3 3 " 29 | query_size=" 3 3 3 " 30 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 31 | wcoord_query=1 32 | z_depth_dim=400 33 | max_o=400000 #2000000 34 | ranges=" -1.126 -0.746 -0.492 1.122 0.962 0.939 " 35 | SR=80 36 | K=8 37 | P=10 #120 38 | NN=2 39 | 40 | act_type="LeakyReLU" 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | raydist_mode_unit=1 63 | dataset_name='nerf_synth360_ft' 64 | pin_data_in_memory=1 65 | model='mvs_points_volumetric' 66 | near_plane=2.0 67 | far_plane=6.0 68 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 69 | domain_size='1' 70 | dir_norm=0 71 | 72 | which_tonemap_func="off" 73 | which_render_func='radiance' 74 | which_blend_func='alpha' 75 | out_channels=4 76 | 77 | num_pos_freqs=10 78 | num_viewdir_freqs=4 #6 79 | 80 | random_sample='random' 81 | random_sample_size=60 #48 # 32 * 32 = 1024 82 | batch_size=1 83 | 84 | gpu_ids='1' 85 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 86 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 87 | 88 | save_iter_freq=10000 89 | save_point_freq=10000 #301840 #1 90 | maximum_step=200000 #300000 #800000 91 | n_threads=1 92 | 93 | test_num_step=1 94 | visual_items=' coarse_raycolor gt_image ' 95 | 96 | color_loss_weights=" 1.0 0.0 0.0 " 97 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 98 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 99 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 100 | split="train" 101 | 102 | cd run 103 | 104 | 105 | python3 test_ft.py \ 106 | --experiment $name \ 107 | --scan $scan \ 108 | --data_root $data_root \ 109 | --dataset_name $dataset_name \ 110 | --model $model \ 111 | --which_render_func $which_render_func \ 112 | --which_blend_func $which_blend_func \ 113 | --out_channels $out_channels \ 114 | --num_pos_freqs $num_pos_freqs \ 115 | --num_viewdir_freqs $num_viewdir_freqs \ 116 | --random_sample $random_sample \ 117 | --random_sample_size $random_sample_size \ 118 | --batch_size $batch_size \ 119 | --maximum_step $maximum_step \ 120 | --gpu_ids $gpu_ids \ 121 | --checkpoints_dir $checkpoints_dir \ 122 | --save_iter_freq $save_iter_freq \ 123 | --n_threads $n_threads \ 124 | --pin_data_in_memory $pin_data_in_memory \ 125 | --test_num_step $test_num_step \ 126 | --test_color_loss_items $test_color_loss_items \ 127 | --bg_color $bg_color \ 128 | --split $split \ 129 | --which_ray_generation $which_ray_generation \ 130 | --near_plane $near_plane \ 131 | --far_plane $far_plane \ 132 | --dir_norm $dir_norm \ 133 | --which_tonemap_func $which_tonemap_func \ 134 | --resume_dir $resume_dir \ 135 | --resume_iter $resume_iter \ 136 | --feature_init_method $feature_init_method \ 137 | --agg_axis_weight $agg_axis_weight \ 138 | --agg_distance_kernel $agg_distance_kernel \ 139 | --radius_limit_scale $radius_limit_scale \ 140 | --depth_limit_scale $depth_limit_scale \ 141 | --vscale $vscale \ 142 | --kernel_size $kernel_size \ 143 | --SR $SR \ 144 | --K $K \ 145 | --P $P \ 146 | --NN $NN \ 147 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 148 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 149 | --agg_color_xyz_mode $agg_color_xyz_mode \ 150 | --save_point_freq $save_point_freq \ 151 | --raydist_mode_unit $raydist_mode_unit \ 152 | --agg_dist_pers $agg_dist_pers \ 153 | --agg_intrp_order $agg_intrp_order \ 154 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 155 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 156 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 157 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 158 | --shading_feature_num $shading_feature_num \ 159 | --dist_xyz_freq $dist_xyz_freq \ 160 | --shpnt_jitter $shpnt_jitter \ 161 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 162 | --shading_color_mlp_layer $shading_color_mlp_layer \ 163 | --which_agg_model $which_agg_model \ 164 | --color_loss_weights $color_loss_weights \ 165 | --num_feat_freqs $num_feat_freqs \ 166 | --dist_xyz_deno $dist_xyz_deno \ 167 | --apply_pnt_mask $apply_pnt_mask \ 168 | --point_features_dim $point_features_dim \ 169 | --color_loss_items $color_loss_items \ 170 | --visual_items $visual_items \ 171 | --bgmodel $bgmodel \ 172 | --act_type $act_type \ 173 | --point_conf_mode $point_conf_mode \ 174 | --point_dir_mode $point_dir_mode \ 175 | --point_color_mode $point_color_mode \ 176 | --normview $normview \ 177 | --alpha_range $alpha_range \ 178 | --ranges $ranges \ 179 | --vsize $vsize \ 180 | --wcoord_query $wcoord_query \ 181 | --max_o $max_o \ 182 | --debug 183 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/ficus_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='ficus' 5 | 6 | resume_iter=200000 # 20000 7 | 8 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 9 | scan="ficus" 10 | 11 | normview=0 12 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 13 | point_dir_mode="1" # 0 for only at features, 1 for color branch 14 | point_color_mode="1" # 0 for only at features, 1 for color branch 15 | 16 | agg_feat_xyz_mode="None" 17 | agg_alpha_xyz_mode="None" 18 | agg_color_xyz_mode="None" 19 | feature_init_method="rand" #"rand" # "zeros" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=0 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=290000 #2000000 33 | ranges=" -0.377 -0.858 -1.034 0.555 0.578 1.141 " 34 | SR=80 35 | K=8 36 | P=12 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | raydist_mode_unit=1 62 | dataset_name='nerf_synth360_ft' 63 | pin_data_in_memory=1 64 | model='mvs_points_volumetric' 65 | near_plane=2.0 66 | far_plane=6.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | 81 | random_sample_size=60 #48 # 32 * 32 = 1024 82 | batch_size=1 83 | 84 | gpu_ids='2' 85 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 86 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 87 | n_threads=1 88 | test_num_step=1 89 | 90 | visual_items=' coarse_raycolor gt_image ' 91 | color_loss_weights=" 1.0 0.0 0.0 " 92 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 93 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 94 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 95 | split="train" 96 | 97 | cd run 98 | 99 | python3 test_ft.py \ 100 | --experiment $name \ 101 | --scan $scan \ 102 | --data_root $data_root \ 103 | --dataset_name $dataset_name \ 104 | --model $model \ 105 | --which_render_func $which_render_func \ 106 | --which_blend_func $which_blend_func \ 107 | --out_channels $out_channels \ 108 | --num_pos_freqs $num_pos_freqs \ 109 | --num_viewdir_freqs $num_viewdir_freqs \ 110 | --random_sample $random_sample \ 111 | --random_sample_size $random_sample_size \ 112 | --batch_size $batch_size \ 113 | --gpu_ids $gpu_ids \ 114 | --checkpoints_dir $checkpoints_dir \ 115 | --n_threads $n_threads \ 116 | --pin_data_in_memory $pin_data_in_memory \ 117 | --test_num_step $test_num_step \ 118 | --test_color_loss_items $test_color_loss_items \ 119 | --bg_color $bg_color \ 120 | --split $split \ 121 | --which_ray_generation $which_ray_generation \ 122 | --near_plane $near_plane \ 123 | --far_plane $far_plane \ 124 | --dir_norm $dir_norm \ 125 | --which_tonemap_func $which_tonemap_func \ 126 | --resume_dir $resume_dir \ 127 | --resume_iter $resume_iter \ 128 | --feature_init_method $feature_init_method \ 129 | --agg_axis_weight $agg_axis_weight \ 130 | --agg_distance_kernel $agg_distance_kernel \ 131 | --radius_limit_scale $radius_limit_scale \ 132 | --depth_limit_scale $depth_limit_scale \ 133 | --vscale $vscale \ 134 | --kernel_size $kernel_size \ 135 | --SR $SR \ 136 | --K $K \ 137 | --P $P \ 138 | --NN $NN \ 139 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 140 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 141 | --agg_color_xyz_mode $agg_color_xyz_mode \ 142 | --raydist_mode_unit $raydist_mode_unit \ 143 | --agg_dist_pers $agg_dist_pers \ 144 | --agg_intrp_order $agg_intrp_order \ 145 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 146 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 147 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 148 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 149 | --shading_feature_num $shading_feature_num \ 150 | --dist_xyz_freq $dist_xyz_freq \ 151 | --shpnt_jitter $shpnt_jitter \ 152 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 153 | --shading_color_mlp_layer $shading_color_mlp_layer \ 154 | --which_agg_model $which_agg_model \ 155 | --color_loss_weights $color_loss_weights \ 156 | --num_feat_freqs $num_feat_freqs \ 157 | --dist_xyz_deno $dist_xyz_deno \ 158 | --apply_pnt_mask $apply_pnt_mask \ 159 | --point_features_dim $point_features_dim \ 160 | --color_loss_items $color_loss_items \ 161 | --visual_items $visual_items \ 162 | --act_type $act_type \ 163 | --point_conf_mode $point_conf_mode \ 164 | --point_dir_mode $point_dir_mode \ 165 | --point_color_mode $point_color_mode \ 166 | --normview $normview \ 167 | --alpha_range $alpha_range \ 168 | --ranges $ranges \ 169 | --vsize $vsize \ 170 | --wcoord_query $wcoord_query \ 171 | --max_o $max_o \ 172 | --debug 173 | 174 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/hotdog_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='hotdog' 5 | 6 | resume_iter=200000 # 20000 7 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 8 | scan="hotdog" 9 | 10 | normview=0 11 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 12 | point_dir_mode="1" # 0 for only at features, 1 for color branch 13 | point_color_mode="1" # 0 for only at features, 1 for color branch 14 | 15 | agg_feat_xyz_mode="None" 16 | agg_alpha_xyz_mode="None" 17 | agg_color_xyz_mode="None" 18 | feature_init_method="rand" #"rand" # "zeros" 19 | agg_axis_weight=" 1. 1. 1." 20 | agg_dist_pers=20 21 | radius_limit_scale=4 22 | depth_limit_scale=0 23 | alpha_range=0 24 | vscale=" 2 2 2 " 25 | kernel_size=" 3 3 3 " 26 | query_size=" 3 3 3 " 27 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 28 | wcoord_query=1 29 | z_depth_dim=400 30 | max_o=1000000 #2000000 31 | ranges=" -1.198 -1.286 -0.190 1.198 1.110 0.312 " 32 | SR=80 33 | K=8 34 | P=9 #120 35 | NN=2 36 | 37 | 38 | act_type="LeakyReLU" 39 | 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | 62 | raydist_mode_unit=1 63 | dataset_name='nerf_synth360_ft' 64 | pin_data_in_memory=1 65 | model='mvs_points_volumetric' 66 | near_plane=2.0 67 | far_plane=6.0 68 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 69 | domain_size='1' 70 | dir_norm=0 71 | 72 | which_tonemap_func="off" #"gamma" # 73 | which_render_func='radiance' 74 | which_blend_func='alpha' 75 | out_channels=4 76 | 77 | num_pos_freqs=10 78 | num_viewdir_freqs=4 #6 79 | 80 | random_sample='random' 81 | 82 | random_sample_size=60 #48 # 32 * 32 = 1024 83 | batch_size=1 84 | 85 | gpu_ids='1' 86 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 87 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 88 | n_threads=1 89 | 90 | test_num_step=1 91 | visual_items=' coarse_raycolor gt_image ' 92 | color_loss_weights=" 1.0 0.0 0.0 " 93 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 94 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 95 | 96 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 97 | split="train" 98 | 99 | cd run 100 | 101 | python3 test_ft.py \ 102 | --experiment $name \ 103 | --scan $scan \ 104 | --data_root $data_root \ 105 | --dataset_name $dataset_name \ 106 | --model $model \ 107 | --which_render_func $which_render_func \ 108 | --which_blend_func $which_blend_func \ 109 | --out_channels $out_channels \ 110 | --num_pos_freqs $num_pos_freqs \ 111 | --num_viewdir_freqs $num_viewdir_freqs \ 112 | --random_sample $random_sample \ 113 | --random_sample_size $random_sample_size \ 114 | --batch_size $batch_size \ 115 | --gpu_ids $gpu_ids \ 116 | --checkpoints_dir $checkpoints_dir \ 117 | --n_threads $n_threads \ 118 | --pin_data_in_memory $pin_data_in_memory \ 119 | --test_num_step $test_num_step \ 120 | --test_color_loss_items $test_color_loss_items \ 121 | --bg_color $bg_color \ 122 | --split $split \ 123 | --which_ray_generation $which_ray_generation \ 124 | --near_plane $near_plane \ 125 | --far_plane $far_plane \ 126 | --dir_norm $dir_norm \ 127 | --which_tonemap_func $which_tonemap_func \ 128 | --resume_dir $resume_dir \ 129 | --resume_iter $resume_iter \ 130 | --feature_init_method $feature_init_method \ 131 | --agg_axis_weight $agg_axis_weight \ 132 | --agg_distance_kernel $agg_distance_kernel \ 133 | --radius_limit_scale $radius_limit_scale \ 134 | --depth_limit_scale $depth_limit_scale \ 135 | --vscale $vscale \ 136 | --kernel_size $kernel_size \ 137 | --SR $SR \ 138 | --K $K \ 139 | --P $P \ 140 | --NN $NN \ 141 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 142 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 143 | --agg_color_xyz_mode $agg_color_xyz_mode \ 144 | --raydist_mode_unit $raydist_mode_unit \ 145 | --agg_dist_pers $agg_dist_pers \ 146 | --agg_intrp_order $agg_intrp_order \ 147 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 148 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 149 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 150 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 151 | --shading_feature_num $shading_feature_num \ 152 | --dist_xyz_freq $dist_xyz_freq \ 153 | --shpnt_jitter $shpnt_jitter \ 154 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 155 | --shading_color_mlp_layer $shading_color_mlp_layer \ 156 | --which_agg_model $which_agg_model \ 157 | --color_loss_weights $color_loss_weights \ 158 | --num_feat_freqs $num_feat_freqs \ 159 | --dist_xyz_deno $dist_xyz_deno \ 160 | --apply_pnt_mask $apply_pnt_mask \ 161 | --point_features_dim $point_features_dim \ 162 | --color_loss_items $color_loss_items \ 163 | --visual_items $visual_items \ 164 | --act_type $act_type \ 165 | --point_conf_mode $point_conf_mode \ 166 | --point_dir_mode $point_dir_mode \ 167 | --point_color_mode $point_color_mode \ 168 | --normview $normview \ 169 | --alpha_range $alpha_range \ 170 | --ranges $ranges \ 171 | --vsize $vsize \ 172 | --wcoord_query $wcoord_query \ 173 | --max_o $max_o \ 174 | --debug -------------------------------------------------------------------------------- /dev_scripts/w_n360/lego_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='lego' 5 | 6 | resume_iter=200000 # 20000 7 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 8 | scan="lego" 9 | 10 | normview=0 11 | 12 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 13 | point_dir_mode="1" # 0 for only at features, 1 for color branch 14 | point_color_mode="1" # 0 for only at features, 1 for color branch 15 | 16 | agg_feat_xyz_mode="None" 17 | agg_alpha_xyz_mode="None" 18 | agg_color_xyz_mode="None" 19 | feature_init_method="rand" #"rand" # "zeros" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=0 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=830000 #2000000 33 | ranges=" -0.638 -1.141 -0.346 0.634 1.149 1.141 " 34 | SR=80 35 | K=8 36 | P=9 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | 63 | raydist_mode_unit=1 64 | dataset_name='nerf_synth360_ft' 65 | pin_data_in_memory=1 66 | model='mvs_points_volumetric' 67 | near_plane=2.0 68 | far_plane=6.0 69 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 70 | domain_size='1' 71 | dir_norm=0 72 | 73 | which_tonemap_func="off" #"gamma" # 74 | which_render_func='radiance' 75 | which_blend_func='alpha' 76 | out_channels=4 77 | 78 | num_pos_freqs=10 79 | num_viewdir_freqs=4 #6 80 | 81 | random_sample='random' 82 | 83 | random_sample_size=60 #48 # 32 * 32 = 1024 84 | batch_size=1 85 | 86 | gpu_ids='3' 87 | 88 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 89 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 90 | 91 | test_num_step=1 92 | visual_items=' coarse_raycolor gt_image ' 93 | color_loss_weights=" 1.0 0.0 0.0 " 94 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 95 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 96 | 97 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 98 | split="train" 99 | 100 | cd run 101 | 102 | python3 test_ft.py \ 103 | --experiment $name \ 104 | --scan $scan \ 105 | --data_root $data_root \ 106 | --dataset_name $dataset_name \ 107 | --model $model \ 108 | --which_render_func $which_render_func \ 109 | --which_blend_func $which_blend_func \ 110 | --out_channels $out_channels \ 111 | --num_pos_freqs $num_pos_freqs \ 112 | --num_viewdir_freqs $num_viewdir_freqs \ 113 | --random_sample $random_sample \ 114 | --random_sample_size $random_sample_size \ 115 | --batch_size $batch_size \ 116 | --gpu_ids $gpu_ids \ 117 | --checkpoints_dir $checkpoints_dir \ 118 | --pin_data_in_memory $pin_data_in_memory \ 119 | --test_num_step $test_num_step \ 120 | --test_color_loss_items $test_color_loss_items \ 121 | --bg_color $bg_color \ 122 | --split $split \ 123 | --which_ray_generation $which_ray_generation \ 124 | --near_plane $near_plane \ 125 | --far_plane $far_plane \ 126 | --dir_norm $dir_norm \ 127 | --which_tonemap_func $which_tonemap_func \ 128 | --resume_dir $resume_dir \ 129 | --resume_iter $resume_iter \ 130 | --feature_init_method $feature_init_method \ 131 | --agg_axis_weight $agg_axis_weight \ 132 | --agg_distance_kernel $agg_distance_kernel \ 133 | --radius_limit_scale $radius_limit_scale \ 134 | --depth_limit_scale $depth_limit_scale \ 135 | --vscale $vscale \ 136 | --kernel_size $kernel_size \ 137 | --SR $SR \ 138 | --K $K \ 139 | --P $P \ 140 | --NN $NN \ 141 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 142 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 143 | --agg_color_xyz_mode $agg_color_xyz_mode \ 144 | --raydist_mode_unit $raydist_mode_unit \ 145 | --agg_dist_pers $agg_dist_pers \ 146 | --agg_intrp_order $agg_intrp_order \ 147 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 148 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 149 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 150 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 151 | --shading_feature_num $shading_feature_num \ 152 | --dist_xyz_freq $dist_xyz_freq \ 153 | --shpnt_jitter $shpnt_jitter \ 154 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 155 | --shading_color_mlp_layer $shading_color_mlp_layer \ 156 | --which_agg_model $which_agg_model \ 157 | --color_loss_weights $color_loss_weights \ 158 | --num_feat_freqs $num_feat_freqs \ 159 | --dist_xyz_deno $dist_xyz_deno \ 160 | --apply_pnt_mask $apply_pnt_mask \ 161 | --point_features_dim $point_features_dim \ 162 | --color_loss_items $color_loss_items \ 163 | --visual_items $visual_items \ 164 | --act_type $act_type \ 165 | --point_conf_mode $point_conf_mode \ 166 | --point_dir_mode $point_dir_mode \ 167 | --point_color_mode $point_color_mode \ 168 | --normview $normview \ 169 | --alpha_range $alpha_range \ 170 | --ranges $ranges \ 171 | --vsize $vsize \ 172 | --wcoord_query $wcoord_query \ 173 | --max_o $max_o \ 174 | --debug 175 | 176 | done 177 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/materials_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='materials' 5 | 6 | resume_iter=200000 # 20000 7 | 8 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 9 | scan="materials" 10 | 11 | normview=0 12 | 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | feature_init_method="rand" #"rand" # "zeros" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | alpha_range=0 26 | 27 | vscale=" 2 2 2 " 28 | kernel_size=" 3 3 3 " 29 | query_size=" 3 3 3 " 30 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 31 | wcoord_query=1 32 | z_depth_dim=400 33 | max_o=930000 #2000000 34 | ranges=" -1.123 -0.759 -0.232 1.072 0.986 0.200 " 35 | SR=80 36 | K=8 37 | P=9 #120 38 | NN=2 39 | 40 | act_type="LeakyReLU" 41 | 42 | agg_intrp_order=2 43 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 44 | weight_xyz_freq=2 45 | weight_feat_dim=8 46 | 47 | point_features_dim=32 48 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 49 | 50 | which_agg_model="viewmlp" 51 | apply_pnt_mask=1 52 | shading_feature_mlp_layer0=1 #2 53 | shading_feature_mlp_layer1=2 #2 54 | shading_feature_mlp_layer2=0 #1 55 | shading_feature_mlp_layer3=2 #1 56 | shading_alpha_mlp_layer=1 57 | shading_color_mlp_layer=4 58 | shading_feature_num=256 59 | dist_xyz_freq=5 60 | num_feat_freqs=3 61 | dist_xyz_deno=0 62 | 63 | 64 | raydist_mode_unit=1 65 | dataset_name='nerf_synth360_ft' 66 | pin_data_in_memory=1 67 | model='mvs_points_volumetric' 68 | near_plane=2.0 69 | far_plane=6.0 70 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 71 | domain_size='1' 72 | dir_norm=0 73 | 74 | which_tonemap_func="off" 75 | which_render_func='radiance' 76 | which_blend_func='alpha' 77 | out_channels=4 78 | 79 | num_pos_freqs=10 80 | num_viewdir_freqs=4 #6 81 | 82 | random_sample='random' 83 | random_sample_size=60 #48 # 32 * 32 = 1024 84 | batch_size=1 85 | 86 | gpu_ids='2' 87 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 88 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 89 | 90 | n_threads=1 91 | test_num_step=1 92 | visual_items=' coarse_raycolor gt_image ' 93 | 94 | color_loss_weights=" 1.0 0.0 0.0 " 95 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 96 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 97 | 98 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 99 | split="train" 100 | 101 | cd run 102 | 103 | python3 test_ft.py \ 104 | --experiment $name \ 105 | --scan $scan \ 106 | --data_root $data_root \ 107 | --dataset_name $dataset_name \ 108 | --model $model \ 109 | --which_render_func $which_render_func \ 110 | --which_blend_func $which_blend_func \ 111 | --out_channels $out_channels \ 112 | --num_pos_freqs $num_pos_freqs \ 113 | --num_viewdir_freqs $num_viewdir_freqs \ 114 | --random_sample $random_sample \ 115 | --random_sample_size $random_sample_size \ 116 | --batch_size $batch_size \ 117 | --gpu_ids $gpu_ids \ 118 | --checkpoints_dir $checkpoints_dir \ 119 | --n_threads $n_threads \ 120 | --pin_data_in_memory $pin_data_in_memory \ 121 | --test_num_step $test_num_step \ 122 | --test_color_loss_items $test_color_loss_items \ 123 | --bg_color $bg_color \ 124 | --split $split \ 125 | --which_ray_generation $which_ray_generation \ 126 | --near_plane $near_plane \ 127 | --far_plane $far_plane \ 128 | --dir_norm $dir_norm \ 129 | --which_tonemap_func $which_tonemap_func \ 130 | --resume_dir $resume_dir \ 131 | --resume_iter $resume_iter \ 132 | --feature_init_method $feature_init_method \ 133 | --agg_axis_weight $agg_axis_weight \ 134 | --agg_distance_kernel $agg_distance_kernel \ 135 | --radius_limit_scale $radius_limit_scale \ 136 | --depth_limit_scale $depth_limit_scale \ 137 | --vscale $vscale \ 138 | --kernel_size $kernel_size \ 139 | --SR $SR \ 140 | --K $K \ 141 | --P $P \ 142 | --NN $NN \ 143 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 144 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 145 | --agg_color_xyz_mode $agg_color_xyz_mode \ 146 | --raydist_mode_unit $raydist_mode_unit \ 147 | --agg_dist_pers $agg_dist_pers \ 148 | --agg_intrp_order $agg_intrp_order \ 149 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 150 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 151 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 152 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 153 | --shading_feature_num $shading_feature_num \ 154 | --dist_xyz_freq $dist_xyz_freq \ 155 | --shpnt_jitter $shpnt_jitter \ 156 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 157 | --shading_color_mlp_layer $shading_color_mlp_layer \ 158 | --which_agg_model $which_agg_model \ 159 | --color_loss_weights $color_loss_weights \ 160 | --num_feat_freqs $num_feat_freqs \ 161 | --dist_xyz_deno $dist_xyz_deno \ 162 | --apply_pnt_mask $apply_pnt_mask \ 163 | --point_features_dim $point_features_dim \ 164 | --color_loss_items $color_loss_items \ 165 | --visual_items $visual_items \ 166 | --act_type $act_type \ 167 | --point_conf_mode $point_conf_mode \ 168 | --point_dir_mode $point_dir_mode \ 169 | --point_color_mode $point_color_mode \ 170 | --normview $normview \ 171 | --alpha_range $alpha_range \ 172 | --ranges $ranges \ 173 | --vsize $vsize \ 174 | --wcoord_query $wcoord_query \ 175 | --max_o $max_o \ 176 | --debug 177 | 178 | done 179 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/mic_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='mic' 5 | 6 | resume_iter=200000 # 20000 7 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 8 | scan="mic" 9 | 10 | normview=0 11 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 12 | point_dir_mode="1" # 0 for only at features, 1 for color branch 13 | point_color_mode="1" # 0 for only at features, 1 for color branch 14 | 15 | agg_feat_xyz_mode="None" 16 | agg_alpha_xyz_mode="None" 17 | agg_color_xyz_mode="None" 18 | feature_init_method="rand" #"rand" # "zeros" 19 | agg_axis_weight=" 1. 1. 1." 20 | agg_dist_pers=20 21 | radius_limit_scale=4 22 | depth_limit_scale=0 23 | alpha_range=0 24 | 25 | vscale=" 2 2 2 " 26 | kernel_size=" 3 3 3 " 27 | query_size=" 3 3 3 " 28 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 29 | wcoord_query=1 30 | z_depth_dim=400 31 | max_o=300000 #2000000 32 | ranges=" -1.252 -0.910 -0.742 0.767 1.082 1.151 " 33 | SR=80 34 | K=8 35 | P=9 #120 36 | NN=2 37 | act_type="LeakyReLU" 38 | 39 | agg_intrp_order=2 40 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 41 | weight_xyz_freq=2 42 | weight_feat_dim=8 43 | 44 | point_features_dim=32 45 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 46 | 47 | which_agg_model="viewmlp" 48 | apply_pnt_mask=1 49 | shading_feature_mlp_layer0=1 #2 50 | shading_feature_mlp_layer1=2 #2 51 | shading_feature_mlp_layer2=0 #1 52 | shading_feature_mlp_layer3=2 #1 53 | shading_alpha_mlp_layer=1 54 | shading_color_mlp_layer=4 55 | shading_feature_num=256 56 | dist_xyz_freq=5 57 | num_feat_freqs=3 58 | dist_xyz_deno=0 59 | 60 | 61 | raydist_mode_unit=1 62 | dataset_name='nerf_synth360_ft' 63 | pin_data_in_memory=1 64 | model='mvs_points_volumetric' 65 | near_plane=2.0 66 | far_plane=6.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | random_sample_size=110 #48 # 32 * 32 = 1024 81 | 82 | batch_size=1 83 | gpu_ids='3' 84 | 85 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 86 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 87 | n_threads=1 88 | test_num_step=1 89 | visual_items=' coarse_raycolor gt_image ' 90 | color_loss_weights=" 1.0 0.0 0.0 " 91 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 92 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 93 | 94 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 95 | split="train" 96 | 97 | cd run 98 | 99 | python3 test_ft.py \ 100 | --experiment $name \ 101 | --scan $scan \ 102 | --data_root $data_root \ 103 | --dataset_name $dataset_name \ 104 | --model $model \ 105 | --which_render_func $which_render_func \ 106 | --which_blend_func $which_blend_func \ 107 | --out_channels $out_channels \ 108 | --num_pos_freqs $num_pos_freqs \ 109 | --num_viewdir_freqs $num_viewdir_freqs \ 110 | --random_sample $random_sample \ 111 | --random_sample_size $random_sample_size \ 112 | --batch_size $batch_size \ 113 | --gpu_ids $gpu_ids \ 114 | --checkpoints_dir $checkpoints_dir \ 115 | --n_threads $n_threads \ 116 | --pin_data_in_memory $pin_data_in_memory \ 117 | --test_num_step $test_num_step \ 118 | --test_color_loss_items $test_color_loss_items \ 119 | --bg_color $bg_color \ 120 | --split $split \ 121 | --which_ray_generation $which_ray_generation \ 122 | --near_plane $near_plane \ 123 | --far_plane $far_plane \ 124 | --dir_norm $dir_norm \ 125 | --which_tonemap_func $which_tonemap_func \ 126 | --resume_dir $resume_dir \ 127 | --resume_iter $resume_iter \ 128 | --feature_init_method $feature_init_method \ 129 | --agg_axis_weight $agg_axis_weight \ 130 | --agg_distance_kernel $agg_distance_kernel \ 131 | --radius_limit_scale $radius_limit_scale \ 132 | --depth_limit_scale $depth_limit_scale \ 133 | --vscale $vscale \ 134 | --kernel_size $kernel_size \ 135 | --SR $SR \ 136 | --K $K \ 137 | --P $P \ 138 | --NN $NN \ 139 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 140 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 141 | --agg_color_xyz_mode $agg_color_xyz_mode \ 142 | --raydist_mode_unit $raydist_mode_unit \ 143 | --agg_dist_pers $agg_dist_pers \ 144 | --agg_intrp_order $agg_intrp_order \ 145 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 146 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 147 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 148 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 149 | --shading_feature_num $shading_feature_num \ 150 | --dist_xyz_freq $dist_xyz_freq \ 151 | --shpnt_jitter $shpnt_jitter \ 152 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 153 | --shading_color_mlp_layer $shading_color_mlp_layer \ 154 | --which_agg_model $which_agg_model \ 155 | --color_loss_weights $color_loss_weights \ 156 | --num_feat_freqs $num_feat_freqs \ 157 | --dist_xyz_deno $dist_xyz_deno \ 158 | --apply_pnt_mask $apply_pnt_mask \ 159 | --point_features_dim $point_features_dim \ 160 | --color_loss_items $color_loss_items \ 161 | --visual_items $visual_items \ 162 | --act_type $act_type \ 163 | --point_conf_mode $point_conf_mode \ 164 | --point_dir_mode $point_dir_mode \ 165 | --point_color_mode $point_color_mode \ 166 | --normview $normview \ 167 | --alpha_range $alpha_range \ 168 | --ranges $ranges \ 169 | --vsize $vsize \ 170 | --wcoord_query $wcoord_query \ 171 | --max_o $max_o \ 172 | --debug 173 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/ship_all_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='ship_all' 5 | 6 | resume_iter=200000 # 20000 7 | data_root="${nrDataRoot}/nerf/nerf_synthetic_colmap/" 8 | scan="ship" 9 | 10 | normview=0 11 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 12 | point_dir_mode="1" # 0 for only at features, 1 for color branch 13 | point_color_mode="1" # 0 for only at features, 1 for color branch 14 | 15 | agg_feat_xyz_mode="None" 16 | agg_alpha_xyz_mode="None" 17 | agg_color_xyz_mode="None" 18 | feature_init_method="rand" #"rand" # "zeros" 19 | agg_axis_weight=" 1. 1. 1." 20 | agg_dist_pers=20 21 | radius_limit_scale=4 22 | depth_limit_scale=0 23 | alpha_range=0 24 | 25 | vscale=" 2 2 2 " 26 | kernel_size=" 3 3 3 " 27 | query_size=" 3 3 3 " 28 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 29 | wcoord_query=1 30 | z_depth_dim=400 31 | max_o=1300000 #2000000 32 | ranges=" -1.277 -1.300 -0.550 1.371 1.349 0.729 " 33 | SR=80 34 | K=8 35 | P=6 #120 36 | NN=2 37 | 38 | act_type="LeakyReLU" 39 | agg_intrp_order=2 40 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 41 | weight_xyz_freq=2 42 | weight_feat_dim=8 43 | 44 | point_features_dim=32 45 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 46 | 47 | which_agg_model="viewmlp" 48 | apply_pnt_mask=1 49 | shading_feature_mlp_layer0=1 #2 50 | shading_feature_mlp_layer1=2 #2 51 | shading_feature_mlp_layer2=0 #1 52 | shading_feature_mlp_layer3=2 #1 53 | shading_alpha_mlp_layer=1 54 | shading_color_mlp_layer=4 55 | shading_feature_num=256 56 | dist_xyz_freq=5 57 | num_feat_freqs=3 58 | dist_xyz_deno=0 59 | 60 | 61 | raydist_mode_unit=1 62 | dataset_name='nerf_synth360_ft' 63 | pin_data_in_memory=1 64 | model='mvs_points_volumetric' 65 | near_plane=2.0 66 | far_plane=6.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | random_sample_size=52 #48 # 32 * 32 = 1024 81 | 82 | batch_size=1 83 | gpu_ids='1' 84 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 85 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 86 | comb_file="${checkpoints_dir}/ship/points/step-0200-0.txt" 87 | 88 | n_threads=1 89 | test_num_step=1 90 | visual_items=' coarse_raycolor gt_image ' 91 | 92 | color_loss_weights=" 1.0 0.0 0.0 " 93 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 94 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 95 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 96 | split="train" 97 | 98 | cd run 99 | 100 | 101 | python3 test_ft.py \ 102 | --experiment $name \ 103 | --scan $scan \ 104 | --data_root $data_root \ 105 | --dataset_name $dataset_name \ 106 | --model $model \ 107 | --which_render_func $which_render_func \ 108 | --which_blend_func $which_blend_func \ 109 | --out_channels $out_channels \ 110 | --num_pos_freqs $num_pos_freqs \ 111 | --num_viewdir_freqs $num_viewdir_freqs \ 112 | --random_sample $random_sample \ 113 | --random_sample_size $random_sample_size \ 114 | --batch_size $batch_size \ 115 | --gpu_ids $gpu_ids \ 116 | --checkpoints_dir $checkpoints_dir \ 117 | --n_threads $n_threads \ 118 | --pin_data_in_memory $pin_data_in_memory \ 119 | --test_num_step $test_num_step \ 120 | --test_color_loss_items $test_color_loss_items \ 121 | --bg_color $bg_color \ 122 | --split $split \ 123 | --which_ray_generation $which_ray_generation \ 124 | --near_plane $near_plane \ 125 | --far_plane $far_plane \ 126 | --dir_norm $dir_norm \ 127 | --which_tonemap_func $which_tonemap_func \ 128 | --resume_dir $resume_dir \ 129 | --resume_iter $resume_iter \ 130 | --feature_init_method $feature_init_method \ 131 | --agg_axis_weight $agg_axis_weight \ 132 | --agg_distance_kernel $agg_distance_kernel \ 133 | --radius_limit_scale $radius_limit_scale \ 134 | --depth_limit_scale $depth_limit_scale \ 135 | --vscale $vscale \ 136 | --kernel_size $kernel_size \ 137 | --SR $SR \ 138 | --K $K \ 139 | --P $P \ 140 | --NN $NN \ 141 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 142 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 143 | --agg_color_xyz_mode $agg_color_xyz_mode \ 144 | --raydist_mode_unit $raydist_mode_unit \ 145 | --agg_dist_pers $agg_dist_pers \ 146 | --agg_intrp_order $agg_intrp_order \ 147 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 148 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 149 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 150 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 151 | --shading_feature_num $shading_feature_num \ 152 | --dist_xyz_freq $dist_xyz_freq \ 153 | --shpnt_jitter $shpnt_jitter \ 154 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 155 | --shading_color_mlp_layer $shading_color_mlp_layer \ 156 | --which_agg_model $which_agg_model \ 157 | --color_loss_weights $color_loss_weights \ 158 | --num_feat_freqs $num_feat_freqs \ 159 | --dist_xyz_deno $dist_xyz_deno \ 160 | --apply_pnt_mask $apply_pnt_mask \ 161 | --point_features_dim $point_features_dim \ 162 | --color_loss_items $color_loss_items \ 163 | --visual_items $visual_items \ 164 | --act_type $act_type \ 165 | --point_conf_mode $point_conf_mode \ 166 | --point_dir_mode $point_dir_mode \ 167 | --point_color_mode $point_color_mode \ 168 | --normview $normview \ 169 | --alpha_range $alpha_range \ 170 | --ranges $ranges \ 171 | --vsize $vsize \ 172 | --wcoord_query $wcoord_query \ 173 | --max_o $max_o \ 174 | --comb_file $comb_file \ 175 | --debug 176 | 177 | -------------------------------------------------------------------------------- /dev_scripts/w_n360/ship_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='ship' 5 | 6 | resume_iter=200000 # 20000 7 | 8 | data_root="${nrDataRoot}/nerf/nerf_synthetic/" 9 | scan="ship" 10 | 11 | normview=0 12 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 13 | point_dir_mode="1" # 0 for only at features, 1 for color branch 14 | point_color_mode="1" # 0 for only at features, 1 for color branch 15 | 16 | agg_feat_xyz_mode="None" 17 | agg_alpha_xyz_mode="None" 18 | agg_color_xyz_mode="None" 19 | feature_init_method="rand" #"rand" # "zeros" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=0 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.004 0.004 0.004 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=1500000 #2000000 33 | ranges=" -1.277 -1.300 -0.550 1.371 1.349 0.729 " 34 | SR=80 35 | K=8 36 | P=10 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | raydist_mode_unit=1 62 | dataset_name='nerf_synth360_ft' 63 | pin_data_in_memory=1 64 | model='mvs_points_volumetric' 65 | near_plane=2.0 66 | far_plane=6.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | random_sample_size=60 #48 # 32 * 32 = 1024 81 | 82 | batch_size=1 83 | gpu_ids='0' 84 | checkpoints_dir="${nrCheckpoint}/nerfsynth/" 85 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 86 | n_threads=1 87 | 88 | test_num_step=1 89 | 90 | visual_items=' coarse_raycolor gt_image ' 91 | color_loss_weights=" 1.0 0.0 0.0 " 92 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 93 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 94 | 95 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 96 | split="train" 97 | 98 | cd run 99 | 100 | python3 test_ft.py \ 101 | --experiment $name \ 102 | --scan $scan \ 103 | --data_root $data_root \ 104 | --dataset_name $dataset_name \ 105 | --model $model \ 106 | --which_render_func $which_render_func \ 107 | --which_blend_func $which_blend_func \ 108 | --out_channels $out_channels \ 109 | --num_pos_freqs $num_pos_freqs \ 110 | --num_viewdir_freqs $num_viewdir_freqs \ 111 | --random_sample $random_sample \ 112 | --random_sample_size $random_sample_size \ 113 | --batch_size $batch_size \ 114 | --gpu_ids $gpu_ids \ 115 | --checkpoints_dir $checkpoints_dir \ 116 | --n_threads $n_threads \ 117 | --pin_data_in_memory $pin_data_in_memory \ 118 | --test_num_step $test_num_step \ 119 | --test_color_loss_items $test_color_loss_items \ 120 | --bg_color $bg_color \ 121 | --split $split \ 122 | --which_ray_generation $which_ray_generation \ 123 | --near_plane $near_plane \ 124 | --far_plane $far_plane \ 125 | --dir_norm $dir_norm \ 126 | --which_tonemap_func $which_tonemap_func \ 127 | --resume_dir $resume_dir \ 128 | --resume_iter $resume_iter \ 129 | --feature_init_method $feature_init_method \ 130 | --agg_axis_weight $agg_axis_weight \ 131 | --agg_distance_kernel $agg_distance_kernel \ 132 | --radius_limit_scale $radius_limit_scale \ 133 | --depth_limit_scale $depth_limit_scale \ 134 | --vscale $vscale \ 135 | --kernel_size $kernel_size \ 136 | --SR $SR \ 137 | --K $K \ 138 | --P $P \ 139 | --NN $NN \ 140 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 141 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 142 | --agg_color_xyz_mode $agg_color_xyz_mode \ 143 | --raydist_mode_unit $raydist_mode_unit \ 144 | --agg_dist_pers $agg_dist_pers \ 145 | --agg_intrp_order $agg_intrp_order \ 146 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 147 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 148 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 149 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 150 | --shading_feature_num $shading_feature_num \ 151 | --dist_xyz_freq $dist_xyz_freq \ 152 | --shpnt_jitter $shpnt_jitter \ 153 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 154 | --shading_color_mlp_layer $shading_color_mlp_layer \ 155 | --which_agg_model $which_agg_model \ 156 | --color_loss_weights $color_loss_weights \ 157 | --num_feat_freqs $num_feat_freqs \ 158 | --dist_xyz_deno $dist_xyz_deno \ 159 | --apply_pnt_mask $apply_pnt_mask \ 160 | --point_features_dim $point_features_dim \ 161 | --color_loss_items $color_loss_items \ 162 | --visual_items $visual_items \ 163 | --act_type $act_type \ 164 | --point_conf_mode $point_conf_mode \ 165 | --point_dir_mode $point_dir_mode \ 166 | --point_color_mode $point_color_mode \ 167 | --normview $normview \ 168 | --alpha_range $alpha_range \ 169 | --ranges $ranges \ 170 | --vsize $vsize \ 171 | --wcoord_query $wcoord_query \ 172 | --max_o $max_o \ 173 | --debug 174 | -------------------------------------------------------------------------------- /dev_scripts/w_scannet_etf/scene101.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrCheckpoint="../checkpoints" 4 | nrDataRoot="../data_src" 5 | name='scene101' 6 | 7 | resume_iter=200000 # 20000 #latest 8 | data_root="${nrDataRoot}/scannet/scans/" 9 | scan="scene0101_04" 10 | 11 | normview=0 12 | edge_filter=10 # pixels crop out at image edge 13 | 14 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 15 | point_dir_mode="1" # 0 for only at features, 1 for color branch 16 | point_color_mode="1" # 0 for only at features, 1 for color branch 17 | 18 | agg_feat_xyz_mode="None" 19 | agg_alpha_xyz_mode="None" 20 | agg_color_xyz_mode="None" 21 | feature_init_method="rand" #"rand" # "zeros" 22 | agg_axis_weight=" 1. 1. 1." 23 | agg_dist_pers=20 24 | radius_limit_scale=4 25 | depth_limit_scale=0 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.008 0.008 0.008 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=2000000 33 | ranges=" -10.0 -10.0 -10.0 10.0 10.0 10.0 " 34 | SR=24 35 | K=8 36 | P=30 37 | NN=2 38 | 39 | 40 | act_type="LeakyReLU" 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="passfunc" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | 63 | raydist_mode_unit=1 64 | dataset_name='scannet_ft' 65 | pin_data_in_memory=1 66 | model='mvs_points_volumetric' 67 | near_plane=0.1 68 | far_plane=8.0 69 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 70 | domain_size='1' 71 | dir_norm=0 72 | 73 | which_tonemap_func="off" #"gamma" # 74 | which_render_func='radiance' 75 | which_blend_func='alpha' 76 | out_channels=4 77 | 78 | num_pos_freqs=10 79 | num_viewdir_freqs=4 #6 80 | 81 | random_sample='random' 82 | random_sample_size=56 # 32 * 32 = 1024 83 | 84 | batch_size=1 85 | gpu_ids='0' 86 | checkpoints_dir="${nrCheckpoint}/scannet/" 87 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 88 | test_num_step=1 89 | 90 | visual_items='coarse_raycolor gt_image ' 91 | 92 | color_loss_weights=" 1.0 0.0 0.0 " 93 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 94 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 95 | 96 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 97 | split="train" 98 | 99 | cd run 100 | 101 | python3 test_ft.py \ 102 | --experiment $name \ 103 | --scan $scan \ 104 | --data_root $data_root \ 105 | --dataset_name $dataset_name \ 106 | --model $model \ 107 | --which_render_func $which_render_func \ 108 | --which_blend_func $which_blend_func \ 109 | --out_channels $out_channels \ 110 | --num_pos_freqs $num_pos_freqs \ 111 | --num_viewdir_freqs $num_viewdir_freqs \ 112 | --random_sample $random_sample \ 113 | --random_sample_size $random_sample_size \ 114 | --batch_size $batch_size \ 115 | --gpu_ids $gpu_ids \ 116 | --checkpoints_dir $checkpoints_dir \ 117 | --pin_data_in_memory $pin_data_in_memory \ 118 | --test_num_step $test_num_step \ 119 | --test_color_loss_items $test_color_loss_items \ 120 | --bg_color $bg_color \ 121 | --split $split \ 122 | --which_ray_generation $which_ray_generation \ 123 | --near_plane $near_plane \ 124 | --far_plane $far_plane \ 125 | --dir_norm $dir_norm \ 126 | --which_tonemap_func $which_tonemap_func \ 127 | --resume_dir $resume_dir \ 128 | --resume_iter $resume_iter \ 129 | --feature_init_method $feature_init_method \ 130 | --agg_axis_weight $agg_axis_weight \ 131 | --agg_distance_kernel $agg_distance_kernel \ 132 | --radius_limit_scale $radius_limit_scale \ 133 | --depth_limit_scale $depth_limit_scale \ 134 | --vscale $vscale \ 135 | --kernel_size $kernel_size \ 136 | --SR $SR \ 137 | --K $K \ 138 | --P $P \ 139 | --NN $NN \ 140 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 141 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 142 | --agg_color_xyz_mode $agg_color_xyz_mode \ 143 | --raydist_mode_unit $raydist_mode_unit \ 144 | --agg_dist_pers $agg_dist_pers \ 145 | --agg_intrp_order $agg_intrp_order \ 146 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 147 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 148 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 149 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 150 | --shading_feature_num $shading_feature_num \ 151 | --dist_xyz_freq $dist_xyz_freq \ 152 | --shpnt_jitter $shpnt_jitter \ 153 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 154 | --shading_color_mlp_layer $shading_color_mlp_layer \ 155 | --which_agg_model $which_agg_model \ 156 | --color_loss_weights $color_loss_weights \ 157 | --num_feat_freqs $num_feat_freqs \ 158 | --dist_xyz_deno $dist_xyz_deno \ 159 | --apply_pnt_mask $apply_pnt_mask \ 160 | --point_features_dim $point_features_dim \ 161 | --color_loss_items $color_loss_items \ 162 | --visual_items $visual_items \ 163 | --act_type $act_type \ 164 | --point_conf_mode $point_conf_mode \ 165 | --point_dir_mode $point_dir_mode \ 166 | --point_color_mode $point_color_mode \ 167 | --normview $normview \ 168 | --edge_filter $edge_filter \ 169 | --vsize $vsize \ 170 | --wcoord_query $wcoord_query \ 171 | --ranges $ranges \ 172 | --z_depth_dim $z_depth_dim \ 173 | --max_o $max_o \ 174 | --query_size $query_size \ 175 | --debug 176 | -------------------------------------------------------------------------------- /dev_scripts/w_scannet_etf/scene101_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrCheckpoint="../checkpoints" 4 | nrDataRoot="../data_src" 5 | name='scene101' 6 | 7 | resume_iter=200000 # 20000 #latest 8 | 9 | data_root="${nrDataRoot}/scannet/scans/" 10 | scan="scene0101_04" 11 | normview=0 12 | edge_filter=10 # pixels crop out at image edge 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | feature_init_method="rand" #"rand" # "zeros" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | vscale=" 2 2 2 " 26 | kernel_size=" 3 3 3 " 27 | query_size=" 3 3 3 " 28 | vsize=" 0.008 0.008 0.008 " #" 0.005 0.005 0.005 " 29 | wcoord_query=1 30 | z_depth_dim=400 31 | max_o=2000000 32 | ranges=" -10.0 -10.0 -10.0 10.0 10.0 10.0 " 33 | SR=24 34 | K=8 35 | P=30 36 | NN=2 37 | 38 | act_type="LeakyReLU" 39 | agg_intrp_order=2 40 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 41 | weight_xyz_freq=2 42 | weight_feat_dim=8 43 | 44 | point_features_dim=32 45 | shpnt_jitter="passfunc" #"uniform" # uniform gaussian 46 | 47 | which_agg_model="viewmlp" 48 | apply_pnt_mask=1 49 | shading_feature_mlp_layer0=1 #2 50 | shading_feature_mlp_layer1=2 #2 51 | shading_feature_mlp_layer2=0 #1 52 | shading_feature_mlp_layer3=2 #1 53 | shading_alpha_mlp_layer=1 54 | shading_color_mlp_layer=4 55 | shading_feature_num=256 56 | dist_xyz_freq=5 57 | num_feat_freqs=3 58 | dist_xyz_deno=0 59 | 60 | 61 | raydist_mode_unit=1 62 | dataset_name='scannet_ft' 63 | pin_data_in_memory=1 64 | model='mvs_points_volumetric' 65 | near_plane=0.1 66 | far_plane=8.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | random_sample_size=56 # 32 * 32 = 1024 81 | batch_size=1 82 | 83 | gpu_ids='0' 84 | checkpoints_dir="${nrCheckpoint}/scannet/" 85 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 86 | 87 | test_num_step=1 88 | visual_items='coarse_raycolor gt_image ' 89 | color_loss_weights=" 1.0 0.0 0.0 " 90 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 91 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 92 | 93 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 94 | split="train" 95 | cd run 96 | 97 | python3 test_ft.py \ 98 | --experiment $name \ 99 | --scan $scan \ 100 | --data_root $data_root \ 101 | --dataset_name $dataset_name \ 102 | --model $model \ 103 | --which_render_func $which_render_func \ 104 | --which_blend_func $which_blend_func \ 105 | --out_channels $out_channels \ 106 | --num_pos_freqs $num_pos_freqs \ 107 | --num_viewdir_freqs $num_viewdir_freqs \ 108 | --random_sample $random_sample \ 109 | --random_sample_size $random_sample_size \ 110 | --batch_size $batch_size \ 111 | --gpu_ids $gpu_ids \ 112 | --checkpoints_dir $checkpoints_dir \ 113 | --pin_data_in_memory $pin_data_in_memory \ 114 | --test_num_step $test_num_step \ 115 | --test_color_loss_items $test_color_loss_items \ 116 | --bg_color $bg_color \ 117 | --split $split \ 118 | --which_ray_generation $which_ray_generation \ 119 | --near_plane $near_plane \ 120 | --far_plane $far_plane \ 121 | --dir_norm $dir_norm \ 122 | --which_tonemap_func $which_tonemap_func \ 123 | --resume_dir $resume_dir \ 124 | --resume_iter $resume_iter \ 125 | --feature_init_method $feature_init_method \ 126 | --agg_axis_weight $agg_axis_weight \ 127 | --agg_distance_kernel $agg_distance_kernel \ 128 | --radius_limit_scale $radius_limit_scale \ 129 | --depth_limit_scale $depth_limit_scale \ 130 | --vscale $vscale \ 131 | --kernel_size $kernel_size \ 132 | --SR $SR \ 133 | --K $K \ 134 | --P $P \ 135 | --NN $NN \ 136 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 137 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 138 | --agg_color_xyz_mode $agg_color_xyz_mode \ 139 | --raydist_mode_unit $raydist_mode_unit \ 140 | --agg_dist_pers $agg_dist_pers \ 141 | --agg_intrp_order $agg_intrp_order \ 142 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 143 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 144 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 145 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 146 | --shading_feature_num $shading_feature_num \ 147 | --dist_xyz_freq $dist_xyz_freq \ 148 | --shpnt_jitter $shpnt_jitter \ 149 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 150 | --shading_color_mlp_layer $shading_color_mlp_layer \ 151 | --which_agg_model $which_agg_model \ 152 | --color_loss_weights $color_loss_weights \ 153 | --num_feat_freqs $num_feat_freqs \ 154 | --dist_xyz_deno $dist_xyz_deno \ 155 | --apply_pnt_mask $apply_pnt_mask \ 156 | --point_features_dim $point_features_dim \ 157 | --color_loss_items $color_loss_items \ 158 | --visual_items $visual_items \ 159 | --act_type $act_type \ 160 | --point_conf_mode $point_conf_mode \ 161 | --point_dir_mode $point_dir_mode \ 162 | --point_color_mode $point_color_mode \ 163 | --normview $normview \ 164 | --edge_filter $edge_filter \ 165 | --vsize $vsize \ 166 | --wcoord_query $wcoord_query \ 167 | --ranges $ranges \ 168 | --z_depth_dim $z_depth_dim \ 169 | --max_o $max_o \ 170 | --query_size $query_size \ 171 | --debug 172 | 173 | -------------------------------------------------------------------------------- /dev_scripts/w_scannet_etf/scene241_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nrCheckpoint="../checkpoints" 4 | nrDataRoot="../data_src" 5 | name='scene241' 6 | 7 | resume_iter=200000 # 20000 #latest 8 | data_root="${nrDataRoot}/scannet/scans/" 9 | scan="scene0241_01" 10 | normview=0 11 | edge_filter=10 # pixels crop out at image edge 12 | 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | feature_init_method="rand" #"rand" # "zeros" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | vscale=" 2 2 2 " 26 | kernel_size=" 3 3 3 " 27 | query_size=" 3 3 3 " 28 | vsize=" 0.008 0.008 0.008 " #" 0.005 0.005 0.005 " 29 | wcoord_query=1 30 | z_depth_dim=400 31 | max_o=610000 32 | ranges=" -10.0 -10.0 -10.0 10.0 10.0 10.0 " 33 | SR=24 34 | K=8 35 | P=26 36 | NN=2 37 | 38 | 39 | act_type="LeakyReLU" 40 | 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="passfunc" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | 63 | raydist_mode_unit=1 64 | dataset_name='scannet_ft' 65 | pin_data_in_memory=1 66 | model='mvs_points_volumetric' 67 | near_plane=0.1 68 | far_plane=8.0 69 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 70 | domain_size='1' 71 | dir_norm=0 72 | 73 | which_tonemap_func="off" #"gamma" # 74 | which_render_func='radiance' 75 | which_blend_func='alpha' 76 | out_channels=4 77 | 78 | num_pos_freqs=10 79 | num_viewdir_freqs=4 #6 80 | 81 | random_sample='random' 82 | random_sample_size=56 # 32 * 32 = 1024 83 | 84 | batch_size=1 85 | 86 | plr=0.002 87 | lr=0.0005 # 0.0005 #0.00015 88 | lr_policy="iter_exponential_decay" 89 | lr_decay_iters=1000000 90 | lr_decay_exp=0.1 91 | 92 | gpu_ids='2' 93 | 94 | checkpoints_dir="${nrCheckpoint}/scannet/" 95 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 96 | 97 | test_num_step=1 98 | visual_items='coarse_raycolor gt_image ' 99 | color_loss_weights=" 1.0 0.0 0.0 " 100 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 101 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 102 | 103 | 104 | 105 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 106 | split="train" 107 | 108 | cd run 109 | 110 | python3 test_ft.py \ 111 | --experiment $name \ 112 | --scan $scan \ 113 | --data_root $data_root \ 114 | --dataset_name $dataset_name \ 115 | --model $model \ 116 | --which_render_func $which_render_func \ 117 | --which_blend_func $which_blend_func \ 118 | --out_channels $out_channels \ 119 | --num_pos_freqs $num_pos_freqs \ 120 | --num_viewdir_freqs $num_viewdir_freqs \ 121 | --random_sample $random_sample \ 122 | --random_sample_size $random_sample_size \ 123 | --batch_size $batch_size \ 124 | --gpu_ids $gpu_ids \ 125 | --checkpoints_dir $checkpoints_dir \ 126 | --pin_data_in_memory $pin_data_in_memory \ 127 | --test_num_step $test_num_step \ 128 | --test_color_loss_items $test_color_loss_items \ 129 | --bg_color $bg_color \ 130 | --split $split \ 131 | --which_ray_generation $which_ray_generation \ 132 | --near_plane $near_plane \ 133 | --far_plane $far_plane \ 134 | --dir_norm $dir_norm \ 135 | --which_tonemap_func $which_tonemap_func \ 136 | --resume_dir $resume_dir \ 137 | --resume_iter $resume_iter \ 138 | --feature_init_method $feature_init_method \ 139 | --agg_axis_weight $agg_axis_weight \ 140 | --agg_distance_kernel $agg_distance_kernel \ 141 | --radius_limit_scale $radius_limit_scale \ 142 | --depth_limit_scale $depth_limit_scale \ 143 | --vscale $vscale \ 144 | --kernel_size $kernel_size \ 145 | --SR $SR \ 146 | --K $K \ 147 | --P $P \ 148 | --NN $NN \ 149 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 150 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 151 | --agg_color_xyz_mode $agg_color_xyz_mode \ 152 | --raydist_mode_unit $raydist_mode_unit \ 153 | --agg_dist_pers $agg_dist_pers \ 154 | --agg_intrp_order $agg_intrp_order \ 155 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 156 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 157 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 158 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 159 | --shading_feature_num $shading_feature_num \ 160 | --dist_xyz_freq $dist_xyz_freq \ 161 | --shpnt_jitter $shpnt_jitter \ 162 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 163 | --shading_color_mlp_layer $shading_color_mlp_layer \ 164 | --which_agg_model $which_agg_model \ 165 | --color_loss_weights $color_loss_weights \ 166 | --num_feat_freqs $num_feat_freqs \ 167 | --dist_xyz_deno $dist_xyz_deno \ 168 | --apply_pnt_mask $apply_pnt_mask \ 169 | --point_features_dim $point_features_dim \ 170 | --color_loss_items $color_loss_items \ 171 | --visual_items $visual_items \ 172 | --act_type $act_type \ 173 | --point_conf_mode $point_conf_mode \ 174 | --point_dir_mode $point_dir_mode \ 175 | --point_color_mode $point_color_mode \ 176 | --normview $normview \ 177 | --edge_filter $edge_filter \ 178 | --vsize $vsize \ 179 | --wcoord_query $wcoord_query \ 180 | --ranges $ranges \ 181 | --z_depth_dim $z_depth_dim \ 182 | --max_o $max_o \ 183 | --query_size $query_size \ 184 | --debug -------------------------------------------------------------------------------- /dev_scripts/w_tt_ft/barn_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='barn' 5 | 6 | resume_iter=200000 # 20000 #latest 7 | data_root="${nrDataRoot}/TanksAndTemple/" 8 | scan="Barn" 9 | 10 | normview=0 11 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 12 | point_dir_mode="1" # 0 for only at features, 1 for color branch 13 | point_color_mode="1" # 0 for only at features, 1 for color branch 14 | mvs_img_wh=" 1088 640 " 15 | img_wh=" 1088 640 " 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=1 25 | 26 | vscale=" 3 3 3 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.003 0.003 0.003 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=1500000 #2000000 33 | ranges=" -2.05965 -0.48064 -2.23660 1.78036 0.6094 1.28341 " 34 | SR=40 35 | K=8 36 | P=11 37 | NN=2 38 | 39 | 40 | act_type="LeakyReLU" 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | raydist_mode_unit=1 62 | dataset_name='tt_ft' 63 | pin_data_in_memory=0 64 | model='mvs_points_volumetric' 65 | near_plane=0.0 66 | far_plane=4.5 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | num_pos_freqs=10 76 | num_viewdir_freqs=4 #6 77 | random_sample='random' 78 | random_sample_size=48 #48 # 32 * 32 = 1024 79 | 80 | batch_size=1 81 | gpu_ids='2' 82 | 83 | checkpoints_dir="${nrCheckpoint}/tanksntemples/" 84 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 85 | test_num_step=1 86 | visual_items=' coarse_raycolor gt_image ' 87 | 88 | color_loss_weights=" 1.0 0.0 0.0 " 89 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 90 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 91 | 92 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 93 | split="train" 94 | 95 | cd run 96 | 97 | python3 test_ft.py \ 98 | --experiment $name \ 99 | --scan $scan \ 100 | --data_root $data_root \ 101 | --dataset_name $dataset_name \ 102 | --model $model \ 103 | --which_render_func $which_render_func \ 104 | --which_blend_func $which_blend_func \ 105 | --out_channels $out_channels \ 106 | --num_pos_freqs $num_pos_freqs \ 107 | --num_viewdir_freqs $num_viewdir_freqs \ 108 | --random_sample $random_sample \ 109 | --random_sample_size $random_sample_size \ 110 | --batch_size $batch_size \ 111 | --gpu_ids $gpu_ids \ 112 | --checkpoints_dir $checkpoints_dir \ 113 | --pin_data_in_memory $pin_data_in_memory \ 114 | --test_num_step $test_num_step \ 115 | --test_color_loss_items $test_color_loss_items \ 116 | --bg_color $bg_color \ 117 | --split $split \ 118 | --which_ray_generation $which_ray_generation \ 119 | --near_plane $near_plane \ 120 | --far_plane $far_plane \ 121 | --dir_norm $dir_norm \ 122 | --which_tonemap_func $which_tonemap_func \ 123 | --resume_dir $resume_dir \ 124 | --resume_iter $resume_iter \ 125 | --agg_axis_weight $agg_axis_weight \ 126 | --agg_distance_kernel $agg_distance_kernel \ 127 | --radius_limit_scale $radius_limit_scale \ 128 | --depth_limit_scale $depth_limit_scale \ 129 | --vscale $vscale \ 130 | --kernel_size $kernel_size \ 131 | --SR $SR \ 132 | --K $K \ 133 | --P $P \ 134 | --NN $NN \ 135 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 136 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 137 | --agg_color_xyz_mode $agg_color_xyz_mode \ 138 | --raydist_mode_unit $raydist_mode_unit \ 139 | --agg_dist_pers $agg_dist_pers \ 140 | --agg_intrp_order $agg_intrp_order \ 141 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 142 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 143 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 144 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 145 | --shading_feature_num $shading_feature_num \ 146 | --dist_xyz_freq $dist_xyz_freq \ 147 | --shpnt_jitter $shpnt_jitter \ 148 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 149 | --shading_color_mlp_layer $shading_color_mlp_layer \ 150 | --which_agg_model $which_agg_model \ 151 | --color_loss_weights $color_loss_weights \ 152 | --num_feat_freqs $num_feat_freqs \ 153 | --dist_xyz_deno $dist_xyz_deno \ 154 | --apply_pnt_mask $apply_pnt_mask \ 155 | --point_features_dim $point_features_dim \ 156 | --color_loss_items $color_loss_items \ 157 | --visual_items $visual_items \ 158 | --act_type $act_type \ 159 | --point_conf_mode $point_conf_mode \ 160 | --point_dir_mode $point_dir_mode \ 161 | --point_color_mode $point_color_mode \ 162 | --normview $normview \ 163 | --alpha_range $alpha_range \ 164 | --ranges $ranges \ 165 | --mvs_img_wh $mvs_img_wh \ 166 | --img_wh $img_wh \ 167 | --vsize $vsize \ 168 | --wcoord_query $wcoord_query \ 169 | --max_o $max_o \ 170 | --debug 171 | 172 | -------------------------------------------------------------------------------- /dev_scripts/w_tt_ft/caterpillar_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='caterpillar' 5 | 6 | resume_iter=200000 # 20000 #latest 7 | data_root="${nrDataRoot}/TanksAndTemple/" 8 | scan="Caterpillar" 9 | 10 | normview=0 11 | mvs_img_wh=" 1088 640 " 12 | img_wh=" 1088 640 " 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=1 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.002 0.002 0.002 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=1800000 #2000000 33 | ranges=" -1.3345 -0.8172 -0.9727 0.9255 0.7428 1.3273 " 34 | SR=40 35 | K=8 36 | P=10 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | point_features_dim=32 45 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 46 | 47 | which_agg_model="viewmlp" 48 | apply_pnt_mask=1 49 | shading_feature_mlp_layer0=1 #2 50 | shading_feature_mlp_layer1=2 #2 51 | shading_feature_mlp_layer2=0 #1 52 | shading_feature_mlp_layer3=2 #1 53 | shading_alpha_mlp_layer=1 54 | shading_color_mlp_layer=4 55 | shading_feature_num=256 56 | dist_xyz_freq=5 57 | num_feat_freqs=3 58 | dist_xyz_deno=0 59 | 60 | raydist_mode_unit=1 61 | dataset_name='tt_ft' 62 | pin_data_in_memory=0 63 | model='mvs_points_volumetric' 64 | near_plane=0.0 65 | far_plane=3.0 66 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 67 | domain_size='1' 68 | dir_norm=0 69 | 70 | which_tonemap_func="off" #"gamma" # 71 | which_render_func='radiance' 72 | which_blend_func='alpha' 73 | out_channels=4 74 | 75 | num_pos_freqs=10 76 | num_viewdir_freqs=4 #6 77 | 78 | random_sample='random' 79 | random_sample_size=56 #48 # 32 * 32 = 1024 80 | batch_size=1 81 | gpu_ids='3' 82 | checkpoints_dir="${nrCheckpoint}/tanksntemples/" 83 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 84 | 85 | test_num_step=1 86 | visual_items=' coarse_raycolor gt_image ' 87 | color_loss_weights=" 1.0 0.0 0.0 " 88 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 89 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 90 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 91 | split="train" 92 | 93 | cd run 94 | 95 | python3 test_ft.py \ 96 | --experiment $name \ 97 | --scan $scan \ 98 | --data_root $data_root \ 99 | --dataset_name $dataset_name \ 100 | --model $model \ 101 | --which_render_func $which_render_func \ 102 | --which_blend_func $which_blend_func \ 103 | --out_channels $out_channels \ 104 | --num_pos_freqs $num_pos_freqs \ 105 | --num_viewdir_freqs $num_viewdir_freqs \ 106 | --random_sample $random_sample \ 107 | --random_sample_size $random_sample_size \ 108 | --batch_size $batch_size \ 109 | --gpu_ids $gpu_ids \ 110 | --checkpoints_dir $checkpoints_dir \ 111 | --pin_data_in_memory $pin_data_in_memory \ 112 | --test_num_step $test_num_step \ 113 | --test_color_loss_items $test_color_loss_items \ 114 | --bg_color $bg_color \ 115 | --split $split \ 116 | --which_ray_generation $which_ray_generation \ 117 | --near_plane $near_plane \ 118 | --far_plane $far_plane \ 119 | --dir_norm $dir_norm \ 120 | --which_tonemap_func $which_tonemap_func \ 121 | --resume_dir $resume_dir \ 122 | --resume_iter $resume_iter \ 123 | --agg_axis_weight $agg_axis_weight \ 124 | --agg_distance_kernel $agg_distance_kernel \ 125 | --radius_limit_scale $radius_limit_scale \ 126 | --depth_limit_scale $depth_limit_scale \ 127 | --vscale $vscale \ 128 | --kernel_size $kernel_size \ 129 | --SR $SR \ 130 | --K $K \ 131 | --P $P \ 132 | --NN $NN \ 133 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 134 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 135 | --agg_color_xyz_mode $agg_color_xyz_mode \ 136 | --raydist_mode_unit $raydist_mode_unit \ 137 | --agg_dist_pers $agg_dist_pers \ 138 | --agg_intrp_order $agg_intrp_order \ 139 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 140 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 141 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 142 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 143 | --shading_feature_num $shading_feature_num \ 144 | --dist_xyz_freq $dist_xyz_freq \ 145 | --shpnt_jitter $shpnt_jitter \ 146 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 147 | --shading_color_mlp_layer $shading_color_mlp_layer \ 148 | --which_agg_model $which_agg_model \ 149 | --color_loss_weights $color_loss_weights \ 150 | --num_feat_freqs $num_feat_freqs \ 151 | --dist_xyz_deno $dist_xyz_deno \ 152 | --apply_pnt_mask $apply_pnt_mask \ 153 | --point_features_dim $point_features_dim \ 154 | --color_loss_items $color_loss_items \ 155 | --visual_items $visual_items \ 156 | --act_type $act_type \ 157 | --point_conf_mode $point_conf_mode \ 158 | --point_dir_mode $point_dir_mode \ 159 | --point_color_mode $point_color_mode \ 160 | --normview $normview \ 161 | --alpha_range $alpha_range \ 162 | --ranges $ranges \ 163 | --mvs_img_wh $mvs_img_wh \ 164 | --img_wh $img_wh \ 165 | --vsize $vsize \ 166 | --wcoord_query $wcoord_query \ 167 | --max_o $max_o \ 168 | --debug -------------------------------------------------------------------------------- /dev_scripts/w_tt_ft/family_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='family' 5 | 6 | resume_iter=200000 # 20000 #latest 7 | data_root="${nrDataRoot}/TanksAndTemple/" 8 | scan="Family" 9 | normview=0 10 | mvs_img_wh=" 1088 640 " 11 | img_wh=" 1088 640 " 12 | 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=1 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 3 3 3 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.001 0.001 0.001 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=800000 #2000000 33 | ranges=" -0.31397 -0.20539 -0.33925 0.26604 0.37462 0.24076 " 34 | SR=40 35 | K=8 36 | P=32 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | raydist_mode_unit=1 62 | dataset_name='tt_ft' 63 | pin_data_in_memory=0 64 | model='mvs_points_volumetric' 65 | near_plane=0.0 66 | far_plane=1.0 67 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 68 | domain_size='1' 69 | dir_norm=0 70 | 71 | which_tonemap_func="off" #"gamma" # 72 | which_render_func='radiance' 73 | which_blend_func='alpha' 74 | out_channels=4 75 | 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | 79 | random_sample='random' 80 | random_sample_size=68 #48 # 32 * 32 = 1024 81 | batch_size=1 82 | 83 | gpu_ids='2' 84 | checkpoints_dir="${nrCheckpoint}/tanksntemples/" 85 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 86 | test_num_step=1 87 | visual_items=' coarse_raycolor gt_image ' 88 | color_loss_weights=" 1.0 0.0 0.0 " 89 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 90 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 91 | 92 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 93 | split="train" 94 | 95 | cd run 96 | 97 | python3 test_ft.py \ 98 | --experiment $name \ 99 | --scan $scan \ 100 | --data_root $data_root \ 101 | --dataset_name $dataset_name \ 102 | --model $model \ 103 | --which_render_func $which_render_func \ 104 | --which_blend_func $which_blend_func \ 105 | --out_channels $out_channels \ 106 | --num_pos_freqs $num_pos_freqs \ 107 | --num_viewdir_freqs $num_viewdir_freqs \ 108 | --random_sample $random_sample \ 109 | --random_sample_size $random_sample_size \ 110 | --batch_size $batch_size \ 111 | --gpu_ids $gpu_ids \ 112 | --checkpoints_dir $checkpoints_dir \ 113 | --pin_data_in_memory $pin_data_in_memory \ 114 | --test_num_step $test_num_step \ 115 | --test_color_loss_items $test_color_loss_items \ 116 | --bg_color $bg_color \ 117 | --split $split \ 118 | --which_ray_generation $which_ray_generation \ 119 | --near_plane $near_plane \ 120 | --far_plane $far_plane \ 121 | --dir_norm $dir_norm \ 122 | --which_tonemap_func $which_tonemap_func \ 123 | --resume_dir $resume_dir \ 124 | --resume_iter $resume_iter \ 125 | --agg_axis_weight $agg_axis_weight \ 126 | --agg_distance_kernel $agg_distance_kernel \ 127 | --radius_limit_scale $radius_limit_scale \ 128 | --depth_limit_scale $depth_limit_scale \ 129 | --vscale $vscale \ 130 | --kernel_size $kernel_size \ 131 | --SR $SR \ 132 | --K $K \ 133 | --P $P \ 134 | --NN $NN \ 135 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 136 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 137 | --agg_color_xyz_mode $agg_color_xyz_mode \ 138 | --raydist_mode_unit $raydist_mode_unit \ 139 | --agg_dist_pers $agg_dist_pers \ 140 | --agg_intrp_order $agg_intrp_order \ 141 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 142 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 143 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 144 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 145 | --shading_feature_num $shading_feature_num \ 146 | --dist_xyz_freq $dist_xyz_freq \ 147 | --shpnt_jitter $shpnt_jitter \ 148 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 149 | --shading_color_mlp_layer $shading_color_mlp_layer \ 150 | --which_agg_model $which_agg_model \ 151 | --color_loss_weights $color_loss_weights \ 152 | --num_feat_freqs $num_feat_freqs \ 153 | --dist_xyz_deno $dist_xyz_deno \ 154 | --apply_pnt_mask $apply_pnt_mask \ 155 | --point_features_dim $point_features_dim \ 156 | --color_loss_items $color_loss_items \ 157 | --visual_items $visual_items \ 158 | --act_type $act_type \ 159 | --point_conf_mode $point_conf_mode \ 160 | --point_dir_mode $point_dir_mode \ 161 | --point_color_mode $point_color_mode \ 162 | --normview $normview \ 163 | --alpha_range $alpha_range \ 164 | --mvs_img_wh $mvs_img_wh \ 165 | --img_wh $img_wh \ 166 | --vsize $vsize \ 167 | --wcoord_query $wcoord_query \ 168 | --max_o $max_o \ 169 | --ranges $ranges \ 170 | --debug -------------------------------------------------------------------------------- /dev_scripts/w_tt_ft/ignatius_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='ignatius' 5 | 6 | resume_iter=200000 # 20000 #latest 7 | data_root="${nrDataRoot}/TanksAndTemple/" 8 | scan="Ignatius" 9 | 10 | normview=0 11 | mvs_img_wh=" 1088 640 " 12 | img_wh=" 1088 640 " 13 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 14 | point_dir_mode="1" # 0 for only at features, 1 for color branch 15 | point_color_mode="1" # 0 for only at features, 1 for color branch 16 | 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | feature_init_method="rand" #"rand" # "zeros" 21 | agg_axis_weight=" 1. 1. 1." 22 | agg_dist_pers=20 23 | radius_limit_scale=4 24 | depth_limit_scale=0 25 | alpha_range=1 26 | 27 | vscale=" 2 2 2 " 28 | kernel_size=" 5 5 5 " 29 | query_size=" 3 3 3 " 30 | vsize=" 0.002 0.002 0.002 " #" 0.005 0.005 0.005 " 31 | wcoord_query=1 32 | z_depth_dim=400 33 | max_o=1050000 #2000000 34 | ranges=" -0.4767 -0.5928 -0.5274 0.5833 0.7872 0.5326 " 35 | SR=40 36 | K=8 37 | P=18 #120 38 | NN=2 39 | 40 | act_type="LeakyReLU" 41 | agg_intrp_order=2 42 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 43 | weight_xyz_freq=2 44 | weight_feat_dim=8 45 | 46 | point_features_dim=32 47 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 48 | 49 | which_agg_model="viewmlp" 50 | apply_pnt_mask=1 51 | shading_feature_mlp_layer0=1 #2 52 | shading_feature_mlp_layer1=2 #2 53 | shading_feature_mlp_layer2=0 #1 54 | shading_feature_mlp_layer3=2 #1 55 | shading_alpha_mlp_layer=1 56 | shading_color_mlp_layer=4 57 | shading_feature_num=256 58 | dist_xyz_freq=5 59 | num_feat_freqs=3 60 | dist_xyz_deno=0 61 | 62 | raydist_mode_unit=1 63 | dataset_name='tt_ft' 64 | pin_data_in_memory=0 65 | model='mvs_points_volumetric' 66 | near_plane=0.0 67 | far_plane=3.2 68 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 69 | domain_size='1' 70 | dir_norm=0 71 | 72 | which_tonemap_func="off" #"gamma" # 73 | which_render_func='radiance' 74 | which_blend_func='alpha' 75 | out_channels=4 76 | 77 | num_pos_freqs=10 78 | num_viewdir_freqs=4 #6 79 | 80 | random_sample='random' 81 | random_sample_size=56 #48 # 32 * 32 = 1024 82 | 83 | batch_size=1 84 | gpu_ids='1' 85 | 86 | checkpoints_dir="${nrCheckpoint}/tanksntemples/" 87 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 88 | 89 | test_num_step=1 90 | 91 | visual_items=' coarse_raycolor gt_image ' 92 | color_loss_weights=" 1.0 0.0 0.0 " 93 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 94 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 95 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 96 | split="train" 97 | 98 | cd run 99 | 100 | python3 test_ft.py \ 101 | --experiment $name \ 102 | --scan $scan \ 103 | --data_root $data_root \ 104 | --dataset_name $dataset_name \ 105 | --model $model \ 106 | --which_render_func $which_render_func \ 107 | --which_blend_func $which_blend_func \ 108 | --out_channels $out_channels \ 109 | --num_pos_freqs $num_pos_freqs \ 110 | --num_viewdir_freqs $num_viewdir_freqs \ 111 | --random_sample $random_sample \ 112 | --random_sample_size $random_sample_size \ 113 | --batch_size $batch_size \ 114 | --gpu_ids $gpu_ids \ 115 | --checkpoints_dir $checkpoints_dir \ 116 | --pin_data_in_memory $pin_data_in_memory \ 117 | --test_num_step $test_num_step \ 118 | --test_color_loss_items $test_color_loss_items \ 119 | --bg_color $bg_color \ 120 | --split $split \ 121 | --which_ray_generation $which_ray_generation \ 122 | --near_plane $near_plane \ 123 | --far_plane $far_plane \ 124 | --dir_norm $dir_norm \ 125 | --which_tonemap_func $which_tonemap_func \ 126 | --resume_dir $resume_dir \ 127 | --resume_iter $resume_iter \ 128 | --feature_init_method $feature_init_method \ 129 | --agg_axis_weight $agg_axis_weight \ 130 | --agg_distance_kernel $agg_distance_kernel \ 131 | --radius_limit_scale $radius_limit_scale \ 132 | --depth_limit_scale $depth_limit_scale \ 133 | --vscale $vscale \ 134 | --kernel_size $kernel_size \ 135 | --SR $SR \ 136 | --K $K \ 137 | --P $P \ 138 | --NN $NN \ 139 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 140 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 141 | --agg_color_xyz_mode $agg_color_xyz_mode \ 142 | --raydist_mode_unit $raydist_mode_unit \ 143 | --agg_dist_pers $agg_dist_pers \ 144 | --agg_intrp_order $agg_intrp_order \ 145 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 146 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 147 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 148 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 149 | --shading_feature_num $shading_feature_num \ 150 | --dist_xyz_freq $dist_xyz_freq \ 151 | --shpnt_jitter $shpnt_jitter \ 152 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 153 | --shading_color_mlp_layer $shading_color_mlp_layer \ 154 | --which_agg_model $which_agg_model \ 155 | --color_loss_weights $color_loss_weights \ 156 | --num_feat_freqs $num_feat_freqs \ 157 | --dist_xyz_deno $dist_xyz_deno \ 158 | --apply_pnt_mask $apply_pnt_mask \ 159 | --point_features_dim $point_features_dim \ 160 | --color_loss_items $color_loss_items \ 161 | --visual_items $visual_items \ 162 | --act_type $act_type \ 163 | --point_conf_mode $point_conf_mode \ 164 | --point_dir_mode $point_dir_mode \ 165 | --point_color_mode $point_color_mode \ 166 | --normview $normview \ 167 | --alpha_range $alpha_range \ 168 | --mvs_img_wh $mvs_img_wh \ 169 | --img_wh $img_wh \ 170 | --vsize $vsize \ 171 | --wcoord_query $wcoord_query \ 172 | --max_o $max_o \ 173 | --ranges $ranges \ 174 | --debug 175 | -------------------------------------------------------------------------------- /dev_scripts/w_tt_ft/truck_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | nrCheckpoint="../checkpoints" 3 | nrDataRoot="../data_src" 4 | name='truck' 5 | 6 | resume_iter=200000 # 20000 #latest 7 | data_root="${nrDataRoot}/TanksAndTemple/" 8 | scan="Truck" 9 | 10 | normview=0 11 | mvs_img_wh=" 1088 640 " 12 | img_wh=" 1088 640 " 13 | 14 | point_conf_mode="1" # 0 for only at features, 1 for multi at weight 15 | point_dir_mode="1" # 0 for only at features, 1 for color branch 16 | point_color_mode="1" # 0 for only at features, 1 for color branch 17 | agg_feat_xyz_mode="None" 18 | agg_alpha_xyz_mode="None" 19 | agg_color_xyz_mode="None" 20 | agg_axis_weight=" 1. 1. 1." 21 | agg_dist_pers=20 22 | radius_limit_scale=4 23 | depth_limit_scale=0 24 | alpha_range=1 25 | 26 | vscale=" 2 2 2 " 27 | kernel_size=" 5 5 5 " 28 | query_size=" 3 3 3 " 29 | vsize=" 0.002 0.002 0.002 " #" 0.005 0.005 0.005 " 30 | wcoord_query=1 31 | z_depth_dim=400 32 | max_o=1600000 #2000000 33 | ranges=" -1.125 -0.598 -1.052 0.795 0.203 1.029 " 34 | SR=40 35 | K=8 36 | P=10 #120 37 | NN=2 38 | 39 | act_type="LeakyReLU" 40 | agg_intrp_order=2 41 | agg_distance_kernel="linear" #"avg" #"feat_intrp" 42 | weight_xyz_freq=2 43 | weight_feat_dim=8 44 | 45 | point_features_dim=32 46 | shpnt_jitter="uniform" #"uniform" # uniform gaussian 47 | 48 | which_agg_model="viewmlp" 49 | apply_pnt_mask=1 50 | shading_feature_mlp_layer0=1 #2 51 | shading_feature_mlp_layer1=2 #2 52 | shading_feature_mlp_layer2=0 #1 53 | shading_feature_mlp_layer3=2 #1 54 | shading_alpha_mlp_layer=1 55 | shading_color_mlp_layer=4 56 | shading_feature_num=256 57 | dist_xyz_freq=5 58 | num_feat_freqs=3 59 | dist_xyz_deno=0 60 | 61 | 62 | raydist_mode_unit=1 63 | dataset_name='tt_ft' 64 | pin_data_in_memory=0 65 | model='mvs_points_volumetric' 66 | near_plane=0.0 67 | far_plane=3.5 68 | which_ray_generation='near_far_linear' #'nerf_near_far_linear' # 69 | domain_size='1' 70 | dir_norm=0 71 | 72 | which_tonemap_func="off" #"gamma" # 73 | which_render_func='radiance' 74 | which_blend_func='alpha' 75 | out_channels=4 76 | num_pos_freqs=10 77 | num_viewdir_freqs=4 #6 78 | random_sample='random' 79 | random_sample_size=56 #48 # 32 * 32 = 1024 80 | batch_size=1 81 | gpu_ids='0' 82 | 83 | checkpoints_dir="${nrCheckpoint}/tanksntemples/" 84 | resume_dir="${nrCheckpoint}/init/dtu_dgt_d012_img0123_conf_agg2_32_dirclr20" 85 | n_threads=1 86 | test_num_step=1 87 | visual_items=' coarse_raycolor gt_image ' 88 | color_loss_weights=" 1.0 0.0 0.0 " 89 | color_loss_items='ray_masked_coarse_raycolor ray_miss_coarse_raycolor coarse_raycolor' 90 | test_color_loss_items='coarse_raycolor ray_miss_coarse_raycolor ray_masked_coarse_raycolor' 91 | 92 | bg_color="white" #"0.0,0.0,0.0,1.0,1.0,1.0" 93 | split="train" 94 | 95 | cd run 96 | 97 | python3 test_ft.py \ 98 | --experiment $name \ 99 | --scan $scan \ 100 | --data_root $data_root \ 101 | --dataset_name $dataset_name \ 102 | --model $model \ 103 | --which_render_func $which_render_func \ 104 | --which_blend_func $which_blend_func \ 105 | --out_channels $out_channels \ 106 | --num_pos_freqs $num_pos_freqs \ 107 | --num_viewdir_freqs $num_viewdir_freqs \ 108 | --random_sample $random_sample \ 109 | --random_sample_size $random_sample_size \ 110 | --batch_size $batch_size \ 111 | --gpu_ids $gpu_ids \ 112 | --checkpoints_dir $checkpoints_dir \ 113 | --n_threads $n_threads \ 114 | --pin_data_in_memory $pin_data_in_memory \ 115 | --test_num_step $test_num_step \ 116 | --test_color_loss_items $test_color_loss_items \ 117 | --bg_color $bg_color \ 118 | --split $split \ 119 | --which_ray_generation $which_ray_generation \ 120 | --near_plane $near_plane \ 121 | --far_plane $far_plane \ 122 | --dir_norm $dir_norm \ 123 | --which_tonemap_func $which_tonemap_func \ 124 | --resume_dir $resume_dir \ 125 | --resume_iter $resume_iter \ 126 | --agg_axis_weight $agg_axis_weight \ 127 | --agg_distance_kernel $agg_distance_kernel \ 128 | --radius_limit_scale $radius_limit_scale \ 129 | --depth_limit_scale $depth_limit_scale \ 130 | --vscale $vscale \ 131 | --kernel_size $kernel_size \ 132 | --SR $SR \ 133 | --K $K \ 134 | --P $P \ 135 | --NN $NN \ 136 | --agg_feat_xyz_mode $agg_feat_xyz_mode \ 137 | --agg_alpha_xyz_mode $agg_alpha_xyz_mode \ 138 | --agg_color_xyz_mode $agg_color_xyz_mode \ 139 | --raydist_mode_unit $raydist_mode_unit \ 140 | --agg_dist_pers $agg_dist_pers \ 141 | --agg_intrp_order $agg_intrp_order \ 142 | --shading_feature_mlp_layer0 $shading_feature_mlp_layer0 \ 143 | --shading_feature_mlp_layer1 $shading_feature_mlp_layer1 \ 144 | --shading_feature_mlp_layer2 $shading_feature_mlp_layer2 \ 145 | --shading_feature_mlp_layer3 $shading_feature_mlp_layer3 \ 146 | --shading_feature_num $shading_feature_num \ 147 | --dist_xyz_freq $dist_xyz_freq \ 148 | --shpnt_jitter $shpnt_jitter \ 149 | --shading_alpha_mlp_layer $shading_alpha_mlp_layer \ 150 | --shading_color_mlp_layer $shading_color_mlp_layer \ 151 | --which_agg_model $which_agg_model \ 152 | --color_loss_weights $color_loss_weights \ 153 | --num_feat_freqs $num_feat_freqs \ 154 | --dist_xyz_deno $dist_xyz_deno \ 155 | --apply_pnt_mask $apply_pnt_mask \ 156 | --point_features_dim $point_features_dim \ 157 | --color_loss_items $color_loss_items \ 158 | --visual_items $visual_items \ 159 | --act_type $act_type \ 160 | --point_conf_mode $point_conf_mode \ 161 | --point_dir_mode $point_dir_mode \ 162 | --point_color_mode $point_color_mode \ 163 | --normview $normview \ 164 | --alpha_range $alpha_range \ 165 | --mvs_img_wh $mvs_img_wh \ 166 | --img_wh $img_wh \ 167 | --vsize $vsize \ 168 | --wcoord_query $wcoord_query \ 169 | --max_o $max_o \ 170 | --debug 171 | -------------------------------------------------------------------------------- /images/Adobe-Logos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/images/Adobe-Logos.png -------------------------------------------------------------------------------- /images/USC-Logos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/images/USC-Logos.png -------------------------------------------------------------------------------- /images/pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/images/pipeline.png -------------------------------------------------------------------------------- /images/youtube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/images/youtube.png -------------------------------------------------------------------------------- /models/__init__.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | from models.base_model import BaseModel 3 | 4 | 5 | def find_model_class_by_name(model_name): 6 | # Given the option --model [modelname], 7 | # the file "models/modelname_model.py" 8 | # will be imported. 9 | model_filename = "models." + model_name + "_model" 10 | modellib = importlib.import_module(model_filename) 11 | 12 | # In the file, the class called ModelNameModel() will 13 | # be instantiated. It has to be a subclass of BaseModel, 14 | # and it is case-insensitive. 15 | model = None 16 | target_model_name = model_name.replace('_', '') + 'model' 17 | for name, cls in modellib.__dict__.items(): 18 | if name.lower() == target_model_name.lower() \ 19 | and issubclass(cls, BaseModel): 20 | model = cls 21 | 22 | if model is None: 23 | print( 24 | "In %s.py, there should be a subclass of BaseModel with class name that matches %s in lowercase." 25 | % (model_filename, target_model_name)) 26 | exit(0) 27 | 28 | return model 29 | 30 | 31 | def get_option_setter(model_name): 32 | model_class = find_model_class_by_name(model_name) 33 | return model_class.modify_commandline_options 34 | 35 | 36 | def create_model(opt): 37 | model = find_model_class_by_name(opt.model) 38 | instance = model() 39 | instance.initialize(opt) 40 | print("model [{}] was created".format(instance.name())) 41 | return instance 42 | -------------------------------------------------------------------------------- /models/aggregators/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/models/aggregators/__init__.py -------------------------------------------------------------------------------- /models/base_model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import nn 3 | import os 4 | from .helpers.networks import get_scheduler 5 | 6 | 7 | class BaseModel: 8 | @staticmethod 9 | def modify_commandline_options(parser, is_train): 10 | return parser 11 | 12 | def name(self): 13 | return self.__class__.__name__ 14 | 15 | def initialize(self, opt): 16 | self.opt = opt 17 | self.gpu_ids = opt.gpu_ids 18 | self.is_train = opt.is_train 19 | self.device = torch.device('cuda:{}'.format(self.gpu_ids[0]) if self. 20 | gpu_ids else torch.device('cpu')) 21 | self.save_dir = os.path.join(opt.checkpoints_dir, opt.name) 22 | torch.backends.cudnn.benchmark = True 23 | 24 | self.loss_names = [] # losses to report 25 | self.model_names = [] # models that will be used 26 | self.visual_names = [] # visuals to show at test time 27 | 28 | def set_input(self, input: dict): 29 | self.input = input 30 | 31 | def forward(self): 32 | '''Run the forward pass. Read from self.input, set self.output''' 33 | raise NotImplementedError() 34 | 35 | def setup(self, opt): 36 | '''Creates schedulers if train, Load and print networks if resume''' 37 | if self.is_train: 38 | self.schedulers = [ 39 | get_scheduler(optim, opt) for optim in self.optimizers 40 | ] 41 | if not self.is_train or opt.resume_dir: 42 | print("opt.resume_iter!!!!!!!!!", opt.resume_iter) 43 | self.load_networks(opt.resume_iter) 44 | self.print_networks(opt.verbose) 45 | 46 | def eval(self): 47 | '''turn on eval mode''' 48 | for net in self.get_networks(): 49 | net.eval() 50 | 51 | def train(self): 52 | for net in self.get_networks(): 53 | net.train() 54 | 55 | def test(self): 56 | with torch.no_grad(): 57 | self.forward() 58 | 59 | def get_networks(self) -> [nn.Module]: 60 | ret = [] 61 | for name in self.model_names: 62 | assert isinstance(name, str) 63 | net = getattr(self, 'net_{}'.format(name)) 64 | assert isinstance(net, nn.Module) 65 | ret.append(net) 66 | return ret 67 | 68 | def get_current_visuals(self, data=None): 69 | ret = {} 70 | for name in self.visual_names: 71 | assert isinstance(name, str) 72 | if name not in ["gt_image_ray_masked", "ray_depth_masked_gt_image", "ray_depth_masked_coarse_raycolor", "ray_masked_coarse_raycolor"]: 73 | ret[name] = getattr(self, name) 74 | if "coarse_raycolor" not in self.visual_names: 75 | ret["coarse_raycolor"] = getattr(self, "coarse_raycolor") 76 | return ret 77 | 78 | def get_current_losses(self): 79 | ret = {} 80 | for name in self.loss_names: 81 | assert isinstance(name, str) 82 | ret[name] = getattr(self, 'loss_' + name) 83 | return ret 84 | 85 | def save_networks(self, epoch, other_states={}, back_gpu=True): 86 | for name, net in zip(self.model_names, self.get_networks()): 87 | save_filename = '{}_net_{}.pth'.format(epoch, name) 88 | save_path = os.path.join(self.save_dir, save_filename) 89 | 90 | try: 91 | if isinstance(net, nn.DataParallel): 92 | net = net.module 93 | net.cpu() 94 | torch.save(net.state_dict(), save_path) 95 | if back_gpu: 96 | net.cuda() 97 | except Exception as e: 98 | print("savenet:", e) 99 | 100 | save_filename = '{}_states.pth'.format(epoch) 101 | save_path = os.path.join(self.save_dir, save_filename) 102 | torch.save(other_states, save_path) 103 | 104 | def load_networks(self, epoch): 105 | for name, net in zip(self.model_names, self.get_networks()): 106 | print('loading pth') 107 | assert isinstance(name, str) 108 | load_filename = '{}_net_{}.pth'.format(epoch, name) 109 | print("loading epoch, name", epoch, name) 110 | load_path = os.path.join(self.opt.resume_dir, load_filename) 111 | 112 | if not os.path.isfile(load_path): 113 | print('cannot load', load_path) 114 | continue 115 | 116 | state_dict = torch.load(load_path, map_location=self.device) 117 | if isinstance(net, nn.DataParallel): 118 | net = net.module 119 | 120 | net.load_state_dict(state_dict, strict=False) 121 | 122 | 123 | def print_networks(self, verbose): 124 | print('------------------- Networks -------------------') 125 | for name, net in zip(self.model_names, self.get_networks()): 126 | num_params = 0 127 | for param in net.parameters(): 128 | num_params += param.numel() 129 | if verbose: 130 | print(net) 131 | print('[Network {}] Total number of parameters: {:.3f}M'.format( 132 | name, num_params / 1e6)) 133 | print('------------------------------------------------') 134 | 135 | def set_requires_grad(self, nets, requires_grad): 136 | if not isinstance(nets, list): 137 | nets = [nets] 138 | for net in nets: 139 | if net: 140 | for param in net.parameters(): 141 | param.requires_grad = requires_grad 142 | 143 | def update_learning_rate(self, **kwargs): 144 | for scheduler in self.schedulers: 145 | scheduler.step() 146 | for i, optim in enumerate(self.optimizers): 147 | lr = optim.param_groups[0]['lr'] 148 | if "opt" in kwargs: 149 | opt = kwargs["opt"] 150 | if not opt.lr_policy.startswith("iter") or \ 151 | ("total_steps" in kwargs and kwargs["total_steps"] % opt.print_freq == 0): 152 | print('optimizer {}, learning rate = {:.7f}'.format(i + 1, lr)) 153 | else: 154 | print('optimizer {}, learning rate = {:.7f}'.format(i + 1, lr)) 155 | 156 | 157 | -------------------------------------------------------------------------------- /models/depth_estimators/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/models/depth_estimators/__init__.py -------------------------------------------------------------------------------- /models/depth_estimators/module.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | 5 | 6 | class ConvBnReLU(nn.Module): 7 | def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, pad=1): 8 | super(ConvBnReLU, self).__init__() 9 | self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=pad, bias=False) 10 | self.bn = nn.BatchNorm2d(out_channels) 11 | 12 | def forward(self, x): 13 | return F.relu(self.bn(self.conv(x)), inplace=True) 14 | 15 | 16 | class ConvBn(nn.Module): 17 | def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, pad=1): 18 | super(ConvBn, self).__init__() 19 | self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride=stride, padding=pad, bias=False) 20 | self.bn = nn.BatchNorm2d(out_channels) 21 | 22 | def forward(self, x): 23 | return self.bn(self.conv(x)) 24 | 25 | 26 | class ConvBnReLU3D(nn.Module): 27 | def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, pad=1): 28 | super(ConvBnReLU3D, self).__init__() 29 | self.conv = nn.Conv3d(in_channels, out_channels, kernel_size, stride=stride, padding=pad, bias=False) 30 | self.bn = nn.BatchNorm3d(out_channels) 31 | 32 | def forward(self, x): 33 | return F.relu(self.bn(self.conv(x)), inplace=True) 34 | 35 | 36 | def homo_warping(src_fea, proj, depth_values): 37 | # src_fea: [B, C, H, W] 38 | # src_proj: [B, 4, 4] 39 | # ref_proj: [B, 4, 4] 40 | # depth_values: [B, Ndepth] 41 | # out: [B, C, Ndepth, H, W] 42 | batch, channels = src_fea.shape[0], src_fea.shape[1] 43 | num_depth = depth_values.shape[1] 44 | height, width = src_fea.shape[2], src_fea.shape[3] 45 | 46 | with torch.no_grad(): 47 | rot = proj[:, :3, :3] # [B,3,3] 48 | trans = proj[:, :3, 3:4] # [B,3,1] 49 | 50 | y, x = torch.meshgrid([torch.arange(0, height, dtype=torch.float32, device=src_fea.device), 51 | torch.arange(0, width, dtype=torch.float32, device=src_fea.device)]) 52 | y, x = y.contiguous(), x.contiguous() 53 | y, x = y.view(height * width), x.view(height * width) 54 | xyz = torch.stack((x, y, torch.ones_like(x))) # [3, H*W] 55 | xyz = torch.unsqueeze(xyz, 0).repeat(batch, 1, 1) # [B, 3, H*W] 56 | rot_xyz = torch.matmul(rot, xyz) # [B, 3, H*W] 57 | rot_depth_xyz = rot_xyz.unsqueeze(2).repeat(1, 1, num_depth, 1) * depth_values.view(batch, 1, num_depth, 58 | 1) # [B, 3, Ndepth, H*W] 59 | proj_xyz = rot_depth_xyz + trans.view(batch, 3, 1, 1) # [B, 3, Ndepth, H*W] 60 | proj_xy = proj_xyz[:, :2, :, :] / proj_xyz[:, 2:3, :, :] # [B, 2, Ndepth, H*W] 61 | proj_x_normalized = proj_xy[:, 0, :, :] / ((width - 1) / 2) - 1 62 | proj_y_normalized = proj_xy[:, 1, :, :] / ((height - 1) / 2) - 1 63 | proj_xy = torch.stack((proj_x_normalized, proj_y_normalized), dim=3) # [B, Ndepth, H*W, 2] 64 | grid = proj_xy 65 | 66 | warped_src_fea = F.grid_sample(src_fea, grid.view(batch, num_depth * height, width, 2), mode='bilinear', 67 | padding_mode='zeros') 68 | warped_src_fea = warped_src_fea.view(batch, channels, num_depth, height, width) 69 | 70 | return warped_src_fea 71 | 72 | 73 | def depth_regression(p, depth_values): 74 | # p: probability volume [B, D, H, W] 75 | # depth_values: discrete depth values [B, D] 76 | depth_values = depth_values.view(*depth_values.shape, 1, 1) 77 | depth = torch.sum(p * depth_values, 1) 78 | return depth 79 | 80 | 81 | if __name__ == "__main__": 82 | # some testing code, just IGNORE it 83 | from datasets import find_dataset_def 84 | from torch.utils.data import DataLoader 85 | import numpy as np 86 | import cv2 87 | 88 | MVSDataset = find_dataset_def("dtu_yao") 89 | dataset = MVSDataset("/home/xyguo/dataset/dtu_mvs/processed/mvs_training/dtu/", '../lists/dtu/train.txt', 'train', 90 | 3, 256) 91 | dataloader = DataLoader(dataset, batch_size=2) 92 | item = next(iter(dataloader)) 93 | 94 | imgs = item["imgs"][:, :, :, ::4, ::4].cuda() 95 | proj_matrices = item["proj_matrices"].cuda() 96 | mask = item["mask"].cuda() 97 | depth = item["depth"].cuda() 98 | depth_values = item["depth_values"].cuda() 99 | 100 | imgs = torch.unbind(imgs, 1) 101 | proj_matrices = torch.unbind(proj_matrices, 1) 102 | ref_img, src_imgs = imgs[0], imgs[1:] 103 | ref_proj, src_projs = proj_matrices[0], proj_matrices[1:] 104 | 105 | warped_imgs = homo_warping(src_imgs[0], src_projs[0], ref_proj, depth_values) 106 | 107 | cv2.imwrite('../tmp/ref.png', ref_img.permute([0, 2, 3, 1])[0].detach().cpu().numpy()[:, :, ::-1] * 255) 108 | cv2.imwrite('../tmp/src.png', src_imgs[0].permute([0, 2, 3, 1])[0].detach().cpu().numpy()[:, :, ::-1] * 255) 109 | 110 | for i in range(warped_imgs.shape[2]): 111 | warped_img = warped_imgs[:, :, i, :, :].permute([0, 2, 3, 1]).contiguous() 112 | img_np = warped_img[0].detach().cpu().numpy() 113 | cv2.imwrite('../tmp/tmp{}.png'.format(i), img_np[:, :, ::-1] * 255) 114 | 115 | 116 | # generate gt 117 | def tocpu(x): 118 | return x.detach().cpu().numpy().copy() 119 | 120 | 121 | ref_img = tocpu(ref_img)[0].transpose([1, 2, 0]) 122 | src_imgs = [tocpu(x)[0].transpose([1, 2, 0]) for x in src_imgs] 123 | ref_proj_mat = tocpu(ref_proj)[0] 124 | src_proj_mats = [tocpu(x)[0] for x in src_projs] 125 | mask = tocpu(mask)[0] 126 | depth = tocpu(depth)[0] 127 | depth_values = tocpu(depth_values)[0] 128 | 129 | for i, D in enumerate(depth_values): 130 | height = ref_img.shape[0] 131 | width = ref_img.shape[1] 132 | xx, yy = np.meshgrid(np.arange(0, width), np.arange(0, height)) 133 | print("yy", yy.max(), yy.min()) 134 | yy = yy.reshape([-1]) 135 | xx = xx.reshape([-1]) 136 | X = np.vstack((xx, yy, np.ones_like(xx))) 137 | # D = depth.reshape([-1]) 138 | # print("X", "D", X.shape, D.shape) 139 | 140 | X = np.vstack((X * D, np.ones_like(xx))) 141 | X = np.matmul(np.linalg.inv(ref_proj_mat), X) 142 | X = np.matmul(src_proj_mats[0], X) 143 | X /= X[2] 144 | X = X[:2] 145 | 146 | yy = X[0].reshape([height, width]).astype(np.float32) 147 | xx = X[1].reshape([height, width]).astype(np.float32) 148 | 149 | warped = cv2.remap(src_imgs[0], yy, xx, interpolation=cv2.INTER_LINEAR) 150 | # warped[mask[:, :] < 0.5] = 0 151 | 152 | cv2.imwrite('../tmp/tmp{}_gt.png'.format(i), warped[:, :, ::-1] * 255) 153 | -------------------------------------------------------------------------------- /models/depth_estimators/mvsnet.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | from .module import * 5 | 6 | 7 | class FeatureNet(nn.Module): 8 | def __init__(self): 9 | super(FeatureNet, self).__init__() 10 | self.inplanes = 32 11 | 12 | self.conv0 = ConvBnReLU(3, 8, 3, 1, 1) 13 | self.conv1 = ConvBnReLU(8, 8, 3, 1, 1) 14 | 15 | self.conv2 = ConvBnReLU(8, 16, 5, 2, 2) 16 | self.conv3 = ConvBnReLU(16, 16, 3, 1, 1) 17 | self.conv4 = ConvBnReLU(16, 16, 3, 1, 1) 18 | 19 | self.conv5 = ConvBnReLU(16, 32, 5, 2, 2) 20 | self.conv6 = ConvBnReLU(32, 32, 3, 1, 1) 21 | self.feature = nn.Conv2d(32, 32, 3, 1, 1) 22 | 23 | def forward(self, x): 24 | x = self.conv1(self.conv0(x)) 25 | x = self.conv4(self.conv3(self.conv2(x))) 26 | x = self.feature(self.conv6(self.conv5(x))) 27 | return x 28 | 29 | 30 | class CostRegNet(nn.Module): 31 | def __init__(self): 32 | super(CostRegNet, self).__init__() 33 | self.conv0 = ConvBnReLU3D(32, 8) 34 | 35 | self.conv1 = ConvBnReLU3D(8, 16, stride=2) 36 | self.conv2 = ConvBnReLU3D(16, 16) 37 | 38 | self.conv3 = ConvBnReLU3D(16, 32, stride=2) 39 | self.conv4 = ConvBnReLU3D(32, 32) 40 | 41 | self.conv5 = ConvBnReLU3D(32, 64, stride=2) 42 | self.conv6 = ConvBnReLU3D(64, 64) 43 | 44 | self.conv7 = nn.Sequential( 45 | nn.ConvTranspose3d(64, 32, kernel_size=3, padding=1, output_padding=1, stride=2, bias=False), 46 | nn.BatchNorm3d(32), 47 | nn.ReLU(inplace=True)) 48 | 49 | self.conv9 = nn.Sequential( 50 | nn.ConvTranspose3d(32, 16, kernel_size=3, padding=1, output_padding=1, stride=2, bias=False), 51 | nn.BatchNorm3d(16), 52 | nn.ReLU(inplace=True)) 53 | 54 | self.conv11 = nn.Sequential( 55 | nn.ConvTranspose3d(16, 8, kernel_size=3, padding=1, output_padding=1, stride=2, bias=False), 56 | nn.BatchNorm3d(8), 57 | nn.ReLU(inplace=True)) 58 | 59 | self.prob = nn.Conv3d(8, 1, 3, stride=1, padding=1) 60 | 61 | def forward(self, x): 62 | conv0 = self.conv0(x) 63 | conv2 = self.conv2(self.conv1(conv0)) 64 | conv4 = self.conv4(self.conv3(conv2)) 65 | x = self.conv6(self.conv5(conv4)) 66 | x = conv4 + self.conv7(x) 67 | x = conv2 + self.conv9(x) 68 | x = conv0 + self.conv11(x) 69 | x = self.prob(x) 70 | return x 71 | 72 | 73 | class RefineNet(nn.Module): 74 | def __init__(self): 75 | super(RefineNet, self).__init__() 76 | self.conv1 = ConvBnReLU(4, 32) 77 | self.conv2 = ConvBnReLU(32, 32) 78 | self.conv3 = ConvBnReLU(32, 32) 79 | self.res = ConvBnReLU(32, 1) 80 | 81 | def forward(self, img, depth_init): 82 | concat = F.cat((img, depth_init), dim=1) 83 | depth_residual = self.res(self.conv3(self.conv2(self.conv1(concat)))) 84 | depth_refined = depth_init + depth_residual 85 | return depth_refined 86 | 87 | 88 | class MVSNet(nn.Module): 89 | def __init__(self, refine=False): 90 | super(MVSNet, self).__init__() 91 | self.refine = refine 92 | 93 | self.feature = FeatureNet() 94 | self.cost_regularization = CostRegNet() 95 | if self.refine: 96 | self.refine_network = RefineNet() 97 | 98 | def forward(self, imgs, proj_matrices, depth_values, features=None, prob_only=False): 99 | 100 | imgs = torch.unbind(imgs, 1) 101 | num_depth = depth_values.shape[1] 102 | num_views = len(imgs) 103 | 104 | # step 1. feature extraction 105 | # in: images; out: 32-channel feature maps 106 | if features is None: 107 | features = [self.feature(img) for img in imgs] 108 | 109 | # step 2. differentiable homograph, build cost volume 110 | volume_sum = 0 111 | volume_sq_sum = 0 112 | for vid in range(num_views): 113 | # warpped features 114 | warped_volume = homo_warping(features[vid], proj_matrices[:, vid], depth_values) 115 | if self.training: 116 | volume_sum = volume_sum + warped_volume 117 | volume_sq_sum = volume_sq_sum + warped_volume ** 2 118 | else: 119 | volume_sum += warped_volume 120 | volume_sq_sum += warped_volume.pow_(2) # the memory of warped_volume has been modified 121 | del warped_volume 122 | volume_variance = volume_sq_sum.div_(num_views).sub_(volume_sum.div_(num_views).pow_(2)) 123 | 124 | # step 3. cost volume regularization 125 | cost_reg = self.cost_regularization(volume_variance) 126 | cost_reg = cost_reg.squeeze(1) 127 | prob_volume = F.softmax(cost_reg, dim=1) 128 | if prob_only: 129 | return features, prob_volume, cost_reg 130 | depth = depth_regression(prob_volume, depth_values=depth_values) 131 | 132 | with torch.no_grad(): 133 | # photometric confidence 134 | prob_volume_sum4 = 4 * F.avg_pool3d(F.pad(prob_volume.unsqueeze(1), pad=(0, 0, 0, 0, 1, 2)), (4, 1, 1), stride=1, padding=0).squeeze(1) 135 | depth_index = depth_regression(prob_volume, depth_values=torch.arange(num_depth, device=prob_volume.device, dtype=torch.float)).long() 136 | photometric_confidence = torch.gather(prob_volume_sum4, 1, depth_index.unsqueeze(1)).squeeze(1) 137 | 138 | # step 4. depth map refinement 139 | if not self.refine: 140 | return depth, photometric_confidence, features, prob_volume # {"depth": depth, "photometric_confidence": photometric_confidence} 141 | else: 142 | refined_depth = self.refine_network(torch.cat((imgs[0], depth), 1)) 143 | return {"depth": depth, "refined_depth": refined_depth, "photometric_confidence": photometric_confidence} 144 | 145 | 146 | def mvsnet_loss(depth_est, depth_gt, mask): 147 | mask = mask > 0.5 148 | return F.smooth_l1_loss(depth_est[mask], depth_gt[mask], size_average=True) 149 | -------------------------------------------------------------------------------- /models/helpers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/models/helpers/__init__.py -------------------------------------------------------------------------------- /models/helpers/geometrics.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def homogenize(m): 5 | """Adds homogeneous coordinates to a [..., N,N] matrix, returning [..., N+1, N+1].""" 6 | assert m.shape[-1] == m.shape[-2] # Must be square 7 | n = m.shape[-1] 8 | eye_n_plus_1 = torch.eye(n + 1).cuda().expand(list(m.shape[:-2]) + [-1, -1]) 9 | extra_col = eye_n_plus_1[..., :-1, -1:] 10 | extra_row = eye_n_plus_1[..., -1:, :] 11 | including_col = torch.cat([m, extra_col], dim=-1) 12 | return torch.cat([including_col, extra_row], dim=-2) 13 | 14 | 15 | def compute_world2local_dist(dists, radii, rotations): 16 | """Computes a transformation to the local element frames for encoding.""" 17 | # We assume the center is an XYZ position for this transformation: 18 | # TODO(kgenova) Update this transformation to account for rotation. 19 | # assert len(dists.shape) == 3 20 | # batch_size, element_count = dists.shape[:2] 21 | 22 | # eye_3x3 = torch.eye(3).cuda().expand([batch_size, element_count, -1, -1]) 23 | # eye_4x4 = torch.eye(4).cuda().expand([batch_size, element_count, -1, -1]) 24 | 25 | # Centering transform 26 | # ones = torch.ones([batch_size, element_count, 1, 1]) 27 | dists = dists[..., None] 28 | # tx = torch.cat([eye_3x3, -dists], dim=-1) 29 | # tx = torch.cat([tx, eye_4x4[..., 3:4, :]], dim=-2) # Append last row 30 | 31 | # Compute the inverse rotation: 32 | rotation = roll_pitch_yaw_to_rotation_matrices(rotations) # torch.inverse(roll_pitch_yaw_to_rotation_matrices(rotations)) 33 | # print("rotation", rotation[0,0]) 34 | assert rotation.shape[-2:] == (3, 3) 35 | 36 | # Compute a scale transformation: 37 | diag = 1.0 / (radii + 1e-8) 38 | scale = torch.diag_embed(diag) 39 | 40 | # Apply both transformations and return the transformed points. 41 | tx3x3 = torch.matmul(scale, rotation) 42 | return torch.matmul(tx3x3, dists) #, torch.matmul(homogenize(tx3x3), tx) 43 | 44 | 45 | def roll_pitch_yaw_to_rotation_matrices(roll_pitch_yaw): 46 | """Converts roll-pitch-yaw angles to rotation matrices. 47 | Args: 48 | roll_pitch_yaw: Tensor with shape [..., 3]. The last dimension contains 49 | the roll, pitch, and yaw angles in radians. The resulting matrix 50 | rotates points by first applying roll around the x-axis, then pitch 51 | around the y-axis, then yaw around the z-axis. 52 | Returns: 53 | Tensor with shape [..., 3, 3]. The 3x3 rotation matrices corresponding to 54 | the input roll-pitch-yaw angles. 55 | """ 56 | 57 | cosines = torch.cos(roll_pitch_yaw) 58 | sines = torch.sin(roll_pitch_yaw) 59 | cx, cy, cz = torch.unbind(cosines, dim=-1) 60 | sx, sy, sz = torch.unbind(sines, dim=-1) 61 | # pyformat: disable 62 | rotation = torch.stack( 63 | [cz * cy, cz * sy * sx - sz * cx, cz * sy * cx + sz * sx, 64 | sz * cy, sz * sy * sx + cz * cx, sz * sy * cx - cz * sx, 65 | -sy, cy * sx, cy * cx], dim=-1) 66 | # pyformat: enable 67 | #shape = torch.cat([roll_pitch_yaw.shape[:-1], [3, 3]], axis=0) 68 | shape = list(roll_pitch_yaw.shape[:-1]) + [3, 3] 69 | rotation = torch.reshape(rotation, shape) 70 | return rotation 71 | -------------------------------------------------------------------------------- /models/mvs/renderer.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn.functional as F 3 | from .mvs_utils import normal_vect, index_point_feature, build_color_volume 4 | 5 | def depth2dist(z_vals, cos_angle): 6 | # z_vals: [N_ray N_sample] 7 | device = z_vals.device 8 | dists = z_vals[..., 1:] - z_vals[..., :-1] 9 | dists = torch.cat([dists, torch.Tensor([1e10]).to(device).expand(dists[..., :1].shape)], -1) # [N_rays, N_samples] 10 | dists = dists * cos_angle.unsqueeze(-1) 11 | return dists 12 | 13 | def ndc2dist(ndc_pts, cos_angle): 14 | dists = torch.norm(ndc_pts[:, 1:] - ndc_pts[:, :-1], dim=-1) 15 | dists = torch.cat([dists, 1e10*cos_angle.unsqueeze(-1)], -1) # [N_rays, N_samples] 16 | return dists 17 | 18 | def raw2alpha(sigma, dist, net_type): 19 | 20 | alpha_softmax = F.softmax(sigma, 1) 21 | 22 | alpha = 1. - torch.exp(-sigma) 23 | 24 | T = torch.cumprod(torch.cat([torch.ones(alpha.shape[0], 1).to(alpha.device), 1. - alpha + 1e-10], -1), -1)[:, :-1] 25 | weights = alpha * T # [N_rays, N_samples] 26 | return alpha, weights, alpha_softmax 27 | 28 | def batchify(fn, chunk): 29 | """Constructs a version of 'fn' that applies to smaller batches. 30 | """ 31 | if chunk is None: 32 | return fn 33 | 34 | def ret(inputs, alpha_only): 35 | if alpha_only: 36 | return torch.cat([fn.forward_alpha(inputs[i:i + chunk]) for i in range(0, inputs.shape[0], chunk)], 0) 37 | else: 38 | return torch.cat([fn(inputs[i:i + chunk]) for i in range(0, inputs.shape[0], chunk)], 0) 39 | 40 | return ret 41 | 42 | def run_network_mvs(pts, viewdirs, alpha_feat, fn, embed_fn, embeddirs_fn, netchunk=1024): 43 | """ 44 | Prepares inputs and applies network 'fn'. 45 | """ 46 | 47 | if embed_fn is not None: 48 | pts = embed_fn(pts) 49 | 50 | if alpha_feat is not None: 51 | pts = torch.cat((pts,alpha_feat), dim=-1) 52 | 53 | if viewdirs is not None: 54 | if viewdirs.dim()!=3: 55 | viewdirs = viewdirs[:, None].expand(-1,pts.shape[1],-1) 56 | 57 | if embeddirs_fn is not None: 58 | viewdirs = embeddirs_fn(viewdirs) 59 | pts = torch.cat([pts, viewdirs], -1) 60 | 61 | alpha_only = viewdirs is None 62 | outputs_flat = batchify(fn, netchunk)(pts, alpha_only) 63 | outputs = torch.reshape(outputs_flat, list(pts.shape[:-1]) + [outputs_flat.shape[-1]]) 64 | return outputs 65 | 66 | def raw2outputs(raw, z_vals, dists, white_bkgd=False, net_type='v2'): 67 | """Transforms model's predictions to semantically meaningful values. 68 | Args: 69 | raw: [num_rays, num_samples along ray, 4]. Prediction from model. 70 | z_vals: [num_rays, num_samples along ray]. Integration time. 71 | rays_d: [num_rays, 3]. Direction of each ray. 72 | Returns: 73 | rgb_map: [num_rays, 3]. Estimated RGB color of a ray. 74 | disp_map: [num_rays]. Disparity map. Inverse of depth map. 75 | acc_map: [num_rays]. Sum of weights along each ray. 76 | weights: [num_rays, num_samples]. Weights assigned to each sampled color. 77 | depth_map: [num_rays]. Estimated distance to object. 78 | """ 79 | 80 | device = z_vals.device 81 | 82 | rgb = raw[..., :3] # [N_rays, N_samples, 3] 83 | 84 | alpha, weights, alpha_softmax = raw2alpha(raw[..., 3], dists, net_type) # [N_rays, N_samples] 85 | rgb_map = torch.sum(weights[..., None] * rgb, -2) # [N_rays, 3] 86 | depth_map = torch.sum(weights * z_vals, -1) 87 | 88 | disp_map = 1. / torch.max(1e-10 * torch.ones_like(depth_map, device=device), depth_map / torch.sum(weights, -1)) 89 | acc_map = torch.sum(weights, -1) 90 | 91 | if white_bkgd: 92 | rgb_map = rgb_map + (1. - acc_map[..., None]) 93 | return rgb_map, disp_map, acc_map, weights, depth_map, alpha 94 | 95 | 96 | 97 | def gen_angle_feature(c2ws, rays_pts, rays_dir): 98 | """ 99 | Inputs: 100 | c2ws: [1,v,4,4] 101 | rays_pts: [N_rays, N_samples, 3] 102 | rays_dir: [N_rays, 3] 103 | 104 | Returns: 105 | 106 | """ 107 | N_rays, N_samples = rays_pts.shape[:2] 108 | dirs = normal_vect(rays_pts.unsqueeze(2) - c2ws[:3, :3, 3][None, None]) # [N_rays, N_samples, v, 3] 109 | angle = torch.sum(dirs[:, :, :3] * rays_dir.reshape(N_rays,1,1,3), dim=-1, keepdim=True).reshape(N_rays, N_samples, -1) 110 | return angle 111 | 112 | def gen_dir_feature(w2c_ref, rays_dir): 113 | """ 114 | Inputs: 115 | c2ws: [1,v,4,4] 116 | rays_pts: [N_rays, N_samples, 3] 117 | rays_dir: [N_rays, 3] 118 | 119 | Returns: 120 | 121 | """ 122 | dirs = rays_dir @ w2c_ref[:3,:3].t() # [N_rays, 3] 123 | return dirs 124 | 125 | def gen_pts_feats(imgs, volume_feature, rays_pts, pose_ref, rays_ndc, feat_dim, img_feat=None, img_downscale=1.0, use_color_volume=False, net_type='v0'): 126 | N_rays, N_samples = rays_pts.shape[:2] 127 | if img_feat is not None: 128 | feat_dim += img_feat.shape[1]*img_feat.shape[2] 129 | 130 | if not use_color_volume: 131 | input_feat = torch.empty((N_rays, N_samples, feat_dim), device=imgs.device, dtype=torch.float) 132 | ray_feats = index_point_feature(volume_feature, rays_ndc) if torch.is_tensor(volume_feature) else volume_feature(rays_ndc) 133 | input_feat[..., :8] = ray_feats 134 | input_feat[..., 8:] = build_color_volume(rays_pts, pose_ref, imgs, img_feat, with_mask=True, downscale=img_downscale) 135 | else: 136 | input_feat = index_point_feature(volume_feature, rays_ndc) if torch.is_tensor(volume_feature) else volume_feature(rays_ndc) 137 | return input_feat 138 | 139 | def rendering(args, pose_ref, rays_pts, rays_ndc, depth_candidates, rays_o, rays_dir, 140 | volume_feature=None, imgs=None, network_fn=None, img_feat=None, network_query_fn=None, white_bkgd=False, **kwargs): 141 | 142 | # rays angle 143 | cos_angle = torch.norm(rays_dir, dim=-1) 144 | 145 | 146 | # using direction 147 | if pose_ref is not None: 148 | angle = gen_dir_feature(pose_ref['w2cs'][0], rays_dir/cos_angle.unsqueeze(-1)) # view dir feature 149 | else: 150 | angle = rays_dir/cos_angle.unsqueeze(-1) 151 | 152 | # rays_pts 153 | input_feat = gen_pts_feats(imgs, volume_feature, rays_pts, pose_ref, rays_ndc, args.feat_dim, \ 154 | img_feat, args.img_downscale, args.use_color_volume, args.net_type) 155 | 156 | # rays_ndc = rays_ndc * 2 - 1.0 157 | # network_query_fn = lambda pts, viewdirs, rays_feats, network_fn: run_network_mvs(pts, viewdirs, rays_feats, 158 | # network_fn, 159 | # embed_fn=embed_fn, 160 | # embeddirs_fn=embeddirs_fn, 161 | # netchunk=args.netchunk) 162 | # run_network_mvs 163 | raw = network_query_fn(rays_ndc, angle, input_feat, network_fn) 164 | if raw.shape[-1]>4: 165 | input_feat = torch.cat((input_feat[...,:8],raw[...,4:]), dim=-1) 166 | 167 | dists = depth2dist(depth_candidates, cos_angle) 168 | # dists = ndc2dist(rays_ndc) 169 | rgb_map, disp_map, acc_map, weights, depth_map, alpha = raw2outputs(raw, depth_candidates, dists, white_bkgd,args.net_type) 170 | ret = {} 171 | 172 | return rgb_map, input_feat, weights, depth_map, alpha, ret 173 | 174 | def render_density(network_fn, rays_pts, density_feature, network_query_fn, chunk=1024 * 5): 175 | densities = [] 176 | device = density_feature.device 177 | for i in range(0, rays_pts.shape[0], chunk): 178 | 179 | input_feat = rays_pts[i:i + chunk].to(device) 180 | 181 | density = network_query_fn(input_feat, None, density_feature[i:i + chunk], network_fn) 182 | densities.append(density) 183 | 184 | return torch.cat(densities) -------------------------------------------------------------------------------- /models/neural_points/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/models/neural_points/__init__.py -------------------------------------------------------------------------------- /models/neural_points/cuda/query_worldcoords.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // CUDA forward declarations 6 | 7 | 8 | std::vector woord_query_grid_point_index_cuda( 9 | torch::Tensor pixel_idx_tensor, 10 | torch::Tensor raypos_tensor, 11 | torch::Tensor point_xyz_w_tensor, 12 | torch::Tensor actual_numpoints_tensor, 13 | torch::Tensor kernel_size, 14 | torch::Tensor query_size, 15 | const int SR, 16 | const int K, 17 | const int R, 18 | const int D, 19 | torch::Tensor scaled_vdim, 20 | const int max_o, 21 | const int P, 22 | const float radius_limit, 23 | torch::Tensor ranges, 24 | torch::Tensor scaled_vsize, 25 | const int kMaxThreadsPerBlock, 26 | const int NN); 27 | // C++ interface 28 | 29 | #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor") 30 | #define CHECK_CONTIGUOUS(x) TORCH_CHECK(x.is_contiguous(), #x " must be contiguous") 31 | #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x) 32 | 33 | 34 | std::vector woord_query_grid_point_index( 35 | torch::Tensor pixel_idx_tensor, 36 | torch::Tensor raypos_tensor, 37 | torch::Tensor point_xyz_w_tensor, 38 | torch::Tensor actual_numpoints_tensor, 39 | torch::Tensor kernel_size, 40 | torch::Tensor query_size, 41 | const int SR, 42 | const int K, 43 | const int R, 44 | const int D, 45 | torch::Tensor scaled_vdim, 46 | const int max_o, 47 | const int P, 48 | const float radius_limit, 49 | torch::Tensor ranges, 50 | torch::Tensor scaled_vsize, 51 | const int kMaxThreadsPerBlock, 52 | const int NN){ 53 | // CHECK_INPUT(pixel_idx_tensor); 54 | // CHECK_INPUT(raypos_tensor); 55 | // CHECK_INPUT(point_xyz_w_tensor); 56 | // CHECK_INPUT(actual_numpoints_tensor); 57 | return woord_query_grid_point_index_cuda( 58 | pixel_idx_tensor, 59 | raypos_tensor, 60 | point_xyz_w_tensor, 61 | actual_numpoints_tensor, 62 | kernel_size, 63 | query_size, 64 | SR, 65 | K, 66 | R, 67 | D, 68 | scaled_vdim, 69 | max_o, 70 | P, 71 | radius_limit, 72 | ranges, 73 | scaled_vsize, 74 | kMaxThreadsPerBlock, 75 | NN); 76 | } 77 | 78 | 79 | 80 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 81 | m.def("woord_query_grid_point_index", &woord_query_grid_point_index, "woord_query_grid_point_index world coordinate"); 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /models/neural_points/point_query.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn 3 | import torch.nn.functional as F 4 | import os 5 | import numpy as np 6 | from numpy import dot 7 | from math import sqrt 8 | import matplotlib.pyplot as plt 9 | import pickle 10 | import time 11 | from models.rendering.diff_ray_marching import near_far_linear_ray_generation, near_far_disparity_linear_ray_generation 12 | parent_dir = os.path.dirname(os.path.abspath(__file__)) 13 | 14 | 15 | from torch.utils.cpp_extension import load as load_cuda 16 | 17 | query_worldcoords_cuda = load_cuda( 18 | name='query_worldcoords_cuda', 19 | sources=[ 20 | os.path.join(parent_dir, path) 21 | for path in ['cuda/query_worldcoords.cpp', 'cuda/query_worldcoords.cu']], 22 | verbose=True) 23 | 24 | 25 | class lighting_fast_querier(): 26 | 27 | def __init__(self, device, opt): 28 | 29 | print("querier device", device, device.index) 30 | self.device="cuda" 31 | self.gpu = device.index 32 | self.opt = opt 33 | self.inverse = self.opt.inverse 34 | self.count=0 35 | self.radius_limit_np = np.asarray(self.opt.radius_limit_scale * max(self.opt.vsize[0], self.opt.vsize[1])).astype(np.float32) 36 | self.vscale_np = np.array(self.opt.vscale, dtype=np.int32) 37 | self.scaled_vsize_np = (self.opt.vsize * self.vscale_np).astype(np.float32) 38 | self.scaled_vsize_tensor = torch.as_tensor(self.scaled_vsize_np, device=device) 39 | self.kernel_size = np.asarray(self.opt.kernel_size, dtype=np.int32) 40 | self.kernel_size_tensor = torch.as_tensor(self.kernel_size, device=device) 41 | self.query_size = np.asarray(self.opt.query_size, dtype=np.int32) 42 | self.query_size_tensor = torch.as_tensor(self.query_size, device=device) 43 | 44 | def clean_up(self): 45 | pass 46 | 47 | def get_hyperparameters(self, vsize_np, point_xyz_w_tensor, ranges=None): 48 | ''' 49 | :param l: 50 | :param h: 51 | :param w: 52 | :param zdim: 53 | :param ydim: 54 | :param xdim: 55 | :return: 56 | ''' 57 | min_xyz, max_xyz = torch.min(point_xyz_w_tensor, dim=-2)[0][0], torch.max(point_xyz_w_tensor, dim=-2)[0][0] 58 | ranges_min = torch.as_tensor(ranges[:3], dtype=torch.float32, device=min_xyz.device) 59 | ranges_max = torch.as_tensor(ranges[3:], dtype=torch.float32, device=min_xyz.device) 60 | if ranges is not None: 61 | # print("min_xyz", min_xyz.shape) 62 | # print("max_xyz", max_xyz.shape) 63 | # print("ranges", ranges) 64 | min_xyz, max_xyz = torch.max(torch.stack([min_xyz, ranges_min], dim=0), dim=0)[0], torch.min(torch.stack([max_xyz, ranges_max], dim=0), dim=0)[0] 65 | min_xyz = min_xyz - torch.as_tensor(self.scaled_vsize_np * self.opt.kernel_size / 2, device=min_xyz.device, dtype=torch.float32) 66 | max_xyz = max_xyz + torch.as_tensor(self.scaled_vsize_np * self.opt.kernel_size / 2, device=min_xyz.device, dtype=torch.float32) 67 | 68 | ranges_tensor = torch.cat([min_xyz, max_xyz], dim=-1) 69 | vdim_np = (max_xyz - min_xyz).cpu().numpy() / vsize_np 70 | scaled_vdim_np = np.ceil(vdim_np / self.vscale_np).astype(np.int32) 71 | return ranges_tensor, vsize_np, scaled_vdim_np 72 | 73 | 74 | def query_points(self, pixel_idx_tensor, point_xyz_pers_tensor, point_xyz_w_tensor, actual_numpoints_tensor, h, w, intrinsic, near_depth, far_depth, ray_dirs_tensor, cam_pos_tensor, cam_rot_tensor): 75 | near_depth, far_depth = np.asarray(near_depth).item() , np.asarray(far_depth).item() 76 | ranges_tensor, vsize_np, scaled_vdim_np = self.get_hyperparameters(self.opt.vsize, point_xyz_w_tensor, ranges=self.opt.ranges) 77 | # print("self.opt.ranges", self.opt.ranges, range_gpu, ray_dirs_tensor) 78 | if self.opt.inverse > 0: 79 | raypos_tensor, _, _, _ = near_far_disparity_linear_ray_generation(cam_pos_tensor, ray_dirs_tensor, self.opt.z_depth_dim, near=near_depth, far=far_depth, jitter=0.3 if self.opt.is_train > 0 else 0.) 80 | else: 81 | raypos_tensor, _, _, _ = near_far_linear_ray_generation(cam_pos_tensor, ray_dirs_tensor, self.opt.z_depth_dim, near=near_depth, far=far_depth, jitter=0.3 if self.opt.is_train > 0 else 0.) 82 | 83 | D = raypos_tensor.shape[2] 84 | R = pixel_idx_tensor.reshape(point_xyz_w_tensor.shape[0], -1, 2).shape[1] 85 | 86 | sample_pidx_tensor, sample_loc_w_tensor, ray_mask_tensor = \ 87 | query_worldcoords_cuda.woord_query_grid_point_index(pixel_idx_tensor, raypos_tensor, point_xyz_w_tensor, actual_numpoints_tensor, self.kernel_size_tensor, 88 | self.query_size_tensor, self.opt.SR, self.opt.K, R, D, 89 | torch.as_tensor(scaled_vdim_np,device=self.device), 90 | self.opt.max_o, self.opt.P, self.radius_limit_np, 91 | ranges_tensor, 92 | self.scaled_vsize_tensor, 93 | self.opt.gpu_maxthr, self.opt.NN) 94 | 95 | sample_ray_dirs_tensor = torch.masked_select(ray_dirs_tensor, ray_mask_tensor[..., None]>0).reshape(ray_dirs_tensor.shape[0],-1,3)[...,None,:].expand(-1, -1, self.opt.SR, -1).contiguous() 96 | # print("sample_ray_dirs_tensor", sample_ray_dirs_tensor.shape) 97 | return sample_pidx_tensor, self.w2pers(sample_loc_w_tensor, cam_rot_tensor, cam_pos_tensor), \ 98 | sample_loc_w_tensor, sample_ray_dirs_tensor, ray_mask_tensor, vsize_np, ranges_tensor.cpu().numpy() 99 | 100 | 101 | def w2pers(self, point_xyz_w, camrotc2w, campos): 102 | # point_xyz_pers B X M X 3 103 | xyz_w_shift = point_xyz_w - campos[:, None, :] 104 | xyz_c = torch.sum(xyz_w_shift[..., None,:] * torch.transpose(camrotc2w, 1, 2)[:, None, None,...], dim=-1) 105 | z_pers = xyz_c[..., 2] 106 | x_pers = xyz_c[..., 0] / xyz_c[..., 2] 107 | y_pers = xyz_c[..., 1] / xyz_c[..., 2] 108 | return torch.stack([x_pers, y_pers, z_pers], dim=-1) -------------------------------------------------------------------------------- /models/rendering/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xharlie/pointnerf/1117541468cf2792c272be0fe1e7a0ce7bbceed4/models/rendering/__init__.py -------------------------------------------------------------------------------- /models/rendering/diff_render_func.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import torch.nn.functional as F 4 | import numpy as np 5 | from utils import format as fmt 6 | 7 | 8 | def find_render_function(name): 9 | if name == 'radiance': 10 | return radiance_render 11 | elif name == 'white': 12 | return white_color 13 | raise RuntimeError('Unknown render function: ' + name) 14 | 15 | 16 | def find_blend_function(name): 17 | if name == 'alpha': 18 | return alpha_blend 19 | elif name == 'alpha2': 20 | return alpha2_blend 21 | 22 | raise RuntimeError('Unknown blend function: ' + name) 23 | 24 | 25 | def find_tone_map(name): 26 | if name == 'gamma': 27 | return simple_tone_map 28 | elif name == 'normalize': 29 | return normalize_tone_map 30 | elif name == 'off': 31 | return no_tone_map 32 | 33 | raise RuntimeError('Unknown blend function: ' + name) 34 | 35 | 36 | def alpha_blend(opacity, acc_transmission): 37 | return opacity * acc_transmission 38 | 39 | 40 | def alpha2_blend(opacity, acc_transmission): 41 | ''' 42 | Consider a light collocated with the camera, 43 | multiply the transmission twice to simulate the light in a round trip 44 | ''' 45 | return opacity * acc_transmission * acc_transmission 46 | 47 | 48 | def radiance_render(ray_feature): 49 | return ray_feature[..., 1:4] 50 | 51 | 52 | def white_color(ray_feature): 53 | albedo = ray_feature[..., 1:4].clamp(0., 1.) 54 | return torch.ones_like(albedo) 55 | 56 | 57 | def simple_tone_map(color, gamma=2.2, exposure=1): 58 | return torch.pow(color * exposure + 1e-5, 1 / gamma).clamp_(0, 1) 59 | 60 | def no_tone_map(color, gamma=2.2, exposure=1): 61 | # return color.clamp 62 | return color 63 | 64 | def normalize_tone_map(color): 65 | color = F.normalize(color, dim=-1) 66 | # print(color) 67 | return color * 0.5 + 0.5 68 | -------------------------------------------------------------------------------- /options/__init__.py: -------------------------------------------------------------------------------- 1 | from .train_options import TrainOptions 2 | from .test_options import TestOptions 3 | from .edit_options import EditOptions 4 | -------------------------------------------------------------------------------- /options/base_options.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | from models import find_model_class_by_name 4 | from data import find_dataset_class_by_name 5 | import torch 6 | 7 | 8 | class BaseOptions: 9 | def initialize(self, parser: argparse.ArgumentParser): 10 | #================================ global ================================# 11 | parser.add_argument('--experiment', 12 | type=str, 13 | required=True, 14 | dest='name', 15 | help='name of the experiment') 16 | parser.add_argument( 17 | '--verbose', 18 | action='store_true', 19 | help='if specified, print more debugging information') 20 | parser.add_argument( 21 | '--timestamp', 22 | action='store_true', 23 | help='suffix the experiment name with current timestamp') 24 | 25 | #================================ dataset ================================# 26 | parser.add_argument('--data_root', 27 | type=str, 28 | default=None, 29 | help='path to the dataset storage') 30 | parser.add_argument( 31 | '--dataset_name', 32 | type=str, 33 | default=None, 34 | help='name of dataset, determine which dataset class to use') 35 | parser.add_argument( 36 | '--max_dataset_size', 37 | type=int, 38 | default=float("inf"), 39 | help='Maximum number of samples allowed per dataset.' 40 | 'If the dataset directory contains more than max_dataset_size, only a subset is loaded.' 41 | ) 42 | parser.add_argument('--n_threads', 43 | default=1, 44 | type=int, 45 | help='# threads for loading data') 46 | #================================ MVS ================================# 47 | 48 | parser.add_argument('--geo_cnsst_num', 49 | default=2, 50 | type=int, 51 | help='# threads for loading data') 52 | 53 | 54 | #================================ model ================================# 55 | parser.add_argument('--bgmodel', 56 | default="No", 57 | type=str, 58 | help='No | sphere | plane') 59 | 60 | parser.add_argument( 61 | '--model', 62 | type=str, 63 | required=True, 64 | help='name of model, determine which network model to use') 65 | 66 | #================================ running ================================# 67 | parser.add_argument('--batch_size', 68 | type=int, 69 | default=1, 70 | help='input batch size') 71 | parser.add_argument('--render_only', 72 | type=int, 73 | default=0, 74 | help='1 for render_only dataset') 75 | parser.add_argument('--serial_batches', 76 | type=int, 77 | default=0, 78 | help='feed batches in order without shuffling') 79 | parser.add_argument('--gpu_ids', 80 | type=str, 81 | default='0', 82 | help='gpu ids: e.g. 0 0,1,2, 0,2. use -1 for CPU') 83 | parser.add_argument('--checkpoints_dir', 84 | type=str, 85 | default='./checkpoints', 86 | help='models are saved here') 87 | parser.add_argument('--show_tensorboard', 88 | type=int, 89 | default=0, 90 | help='plot loss curves with tensorboard') 91 | parser.add_argument('--resume_dir', 92 | type=str, 93 | default='', 94 | help='dir of the previous checkpoint') 95 | parser.add_argument('--resume_iter', 96 | type=str, 97 | default='latest', 98 | help='which epoch to resume from') 99 | parser.add_argument('--debug', 100 | action='store_true', 101 | help='indicate a debug run') 102 | parser.add_argument('--vid', 103 | type=int, 104 | default=0, 105 | help='feed batches in order without shuffling') 106 | parser.add_argument('--resample_pnts', 107 | type=int, 108 | default=-1, 109 | help='resample the num. initial points') 110 | parser.add_argument('--inall_img', 111 | type=int, 112 | default=1, 113 | help='all points must in the sight of all camera pose') 114 | parser.add_argument('--test_train', type=int, default=0, help='test on training set for debugging') 115 | 116 | return parser 117 | 118 | def gather_options(self): 119 | parser = argparse.ArgumentParser( 120 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 121 | parser = self.initialize(parser) 122 | 123 | opt, _ = parser.parse_known_args() 124 | 125 | model_name = opt.model 126 | find_model_class_by_name(model_name).modify_commandline_options( 127 | parser, self.is_train) 128 | 129 | dataset_name = opt.dataset_name 130 | if dataset_name is not None: 131 | find_dataset_class_by_name( 132 | dataset_name).modify_commandline_options( 133 | parser, self.is_train) 134 | 135 | self.parser = parser 136 | 137 | return parser.parse_args() 138 | 139 | def print_and_save_options(self, opt): 140 | message = '' 141 | message += '----------------- Options ---------------\n' 142 | for k, v in sorted(vars(opt).items()): 143 | comment = '' 144 | default = self.parser.get_default(k) 145 | if v != default: 146 | comment = '\t[default: {}]'.format(str(default)) 147 | message += '{:>25}: {:<30}{}\n'.format(str(k), str(v), comment) 148 | message += '----------------- End -------------------' 149 | # print(message) 150 | 151 | # if opt.is_train: 152 | # expr_dir = os.path.join(opt.checkpoints_dir, opt.name) 153 | # else: 154 | # expr_dir = os.path.join(opt.resume_dir, opt.name) 155 | expr_dir = os.path.join(opt.checkpoints_dir, opt.name) 156 | 157 | os.makedirs(expr_dir, exist_ok=True) 158 | file_name = os.path.join(expr_dir, 'opt.txt') 159 | with open(file_name, 'wt') as opt_file: 160 | opt_file.write(message) 161 | opt_file.write('\n') 162 | 163 | def parse(self): 164 | opt = self.gather_options() 165 | opt.is_train = self.is_train 166 | 167 | if opt.timestamp: 168 | import datetime 169 | now = datetime.datetime.now().strftime('%y-%m-%d_%H:%M:%S') 170 | opt.name = opt.name + '_' + now 171 | 172 | self.print_and_save_options(opt) 173 | 174 | str_ids = opt.gpu_ids.split(',') 175 | opt.gpu_ids = [ 176 | int(x) for x in opt.gpu_ids.split(',') if x.strip() and int(x) >= 0 177 | ] 178 | if len(opt.gpu_ids) > 0: 179 | torch.cuda.set_device(opt.gpu_ids[0]) 180 | 181 | self.opt = opt 182 | return self.opt 183 | -------------------------------------------------------------------------------- /options/edit_options.py: -------------------------------------------------------------------------------- 1 | from .base_options import BaseOptions 2 | 3 | class EditOptions(BaseOptions): 4 | def initialize(self, parser): 5 | parser = BaseOptions.initialize(self, parser) 6 | self.is_train = False 7 | parser.add_argument('--neural_points_names', 8 | type=str, 9 | nargs='+', 10 | # default=["imgfeat_0_0123", "vol"], 11 | default=["imgfeat_0_0", "vol"], 12 | help="which feature_map") 13 | parser.add_argument('--Transformation_names', 14 | type=str, 15 | nargs='+', 16 | # default=["imgfeat_0_0123", "vol"], 17 | default=["1", "2"], 18 | help="which feature_map") 19 | parser.add_argument('--render_name', 20 | type=str, 21 | # default=["imgfeat_0_0123", "vol"], 22 | default="tryout", 23 | help="which feature_map") 24 | parser.add_argument('--parts_index_names', 25 | type=str, 26 | nargs='+', 27 | # default=["imgfeat_0_0123", "vol"], 28 | default=["1", "2"], 29 | help="which feature_map") 30 | parser.add_argument('--render_stride', 31 | type=int, 32 | default=30, 33 | help='feed batches in order without shuffling') 34 | parser.add_argument('--render_radius', 35 | type=float, 36 | default=4.0, 37 | help='feed batches in order without shuffling') 38 | return parser 39 | -------------------------------------------------------------------------------- /options/test_options.py: -------------------------------------------------------------------------------- 1 | from .base_options import BaseOptions 2 | 3 | class TestOptions(BaseOptions): 4 | def initialize(self, parser): 5 | parser = BaseOptions.initialize(self, parser) 6 | self.is_train = False 7 | parser.add_argument('--test_num', type=int, default=1, help='test num') 8 | parser.add_argument('--test_num_step', type=int, default=1, help='test num') 9 | parser.add_argument('--test_printId', type=int, default=0, help='The first id (offset) when saving.') 10 | return parser 11 | -------------------------------------------------------------------------------- /options/train_options.py: -------------------------------------------------------------------------------- 1 | from .base_options import BaseOptions 2 | 3 | 4 | class TrainOptions(BaseOptions): 5 | def initialize(self, parser): 6 | parser = BaseOptions.initialize(self, parser) 7 | self.is_train = True 8 | 9 | parser.add_argument( 10 | '--print_freq', 11 | type=int, 12 | default=100, 13 | help='frequency of showing training results on console') 14 | 15 | parser.add_argument('--plr', 16 | type=float, 17 | default=0.0005, 18 | help='initial learning rate') 19 | parser.add_argument('--lr', 20 | type=float, 21 | default=0.001, 22 | help='initial learning rate') 23 | parser.add_argument('--lr_policy', 24 | type=str, 25 | default='lambda', 26 | help='learning rate policy: lambda|step|plateau') 27 | parser.add_argument( 28 | '--lr_decay_iters', 29 | type=int, 30 | default=50, 31 | help='multiply by a gamma every lr_decay_iters iterations') 32 | parser.add_argument( 33 | '--lr_decay_exp', 34 | type=float, 35 | default=0.1, 36 | help='multiply by a gamma every lr_decay_iters iterations') 37 | 38 | parser.add_argument('--train_and_test', 39 | type=int, 40 | default=0, 41 | help='train and test at the same time') 42 | parser.add_argument('--test_num', type=int, default=1, help='test num') 43 | parser.add_argument('--test_num_step', type=int, default=1, help='test num') 44 | parser.add_argument('--test_freq', 45 | type=int, 46 | default=500, 47 | help='test frequency') 48 | 49 | parser.add_argument('--maximum_step', 50 | type=int, 51 | default=None, 52 | help='maximum # of training iterations') 53 | parser.add_argument('--niter', 54 | type=int, 55 | default=100, 56 | help='# of iter at starting learning rate') 57 | parser.add_argument( 58 | '--niter_decay', 59 | type=int, 60 | default=100, 61 | help='# of iter to linearly decay learning rate to zero') 62 | 63 | 64 | parser.add_argument('--save_iter_freq', 65 | type=int, 66 | default=100000, 67 | help='saving frequency') 68 | parser.add_argument('--prune_thresh', 69 | type=float, 70 | default=0.1, 71 | help='saving frequency') 72 | parser.add_argument('--prune_iter', 73 | type=int, 74 | default=-1, 75 | help='saving frequency') 76 | parser.add_argument('--prune_max_iter', 77 | type=int, 78 | default=9999999, 79 | help='saving frequency') 80 | parser.add_argument('--alpha_range', 81 | type=int, 82 | default=0, 83 | help='saving frequency') 84 | parser.add_argument('--prob_freq', 85 | type=int, 86 | default=0, 87 | help='saving frequency') 88 | parser.add_argument('--prob_num_step', 89 | type=int, 90 | default=100, 91 | help='saving frequency') 92 | parser.add_argument('--prob_mode', 93 | type=int, 94 | default=0, 95 | help='saving frequency') 96 | parser.add_argument('--prob_top', 97 | type=int, 98 | default=1, 99 | help='0 randomly select frames, 1 top frames') 100 | parser.add_argument('--prob_mul', 101 | type=float, 102 | default=1.0, 103 | help='saving frequency') 104 | parser.add_argument('--prob_kernel_size', 105 | type=float, 106 | nargs='+', 107 | default=None, 108 | help='saving frequency') 109 | parser.add_argument('--prob_tiers', 110 | type=int, 111 | nargs='+', 112 | default=(250000), 113 | help='saving frequency') 114 | parser.add_argument('--far_thresh', 115 | type=float, 116 | default=-1.0, 117 | help='cartisian distance for prob') 118 | parser.add_argument('--comb_file', 119 | type=str, 120 | default=None, 121 | help='cartisian distance for prob') 122 | 123 | return parser 124 | -------------------------------------------------------------------------------- /requirement.sh: -------------------------------------------------------------------------------- 1 | pip install torch==1.8.1+cu102 h5py 2 | pip install imageio scikit-image 3 | -------------------------------------------------------------------------------- /run/render_vid.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import pathlib 4 | sys.path.append(os.path.join(pathlib.Path(__file__).parent.absolute(), '..')) 5 | 6 | import copy 7 | import torch 8 | import numpy as np 9 | import time 10 | from options import TestOptions 11 | from data import create_data_loader, create_dataset 12 | from models import create_model 13 | from utils.visualizer import Visualizer 14 | from utils import format as fmt 15 | 16 | from tqdm import trange 17 | 18 | 19 | def get_latest_epoch(resume_dir): 20 | os.makedirs(resume_dir, exist_ok=True) 21 | str_epoch = [file.split("_")[0] for file in os.listdir(resume_dir) if file.endswith("_states.pth")] 22 | int_epoch = [int(i) for i in str_epoch] 23 | return None if len(int_epoch) == 0 else str_epoch[int_epoch.index(max(int_epoch))] 24 | 25 | 26 | def render_vid(model, dataset, visualizer, opt, total_steps): 27 | 28 | print( 29 | '-----------------------------------Rendering Vid-----------------------------------' 30 | ) 31 | model.eval() 32 | render_num = len(dataset.render_poses) 33 | patch_size = opt.random_sample_size 34 | chunk_size = patch_size * patch_size 35 | 36 | height = dataset.height 37 | width = dataset.width 38 | visual_lst = [] 39 | for i in range(render_num): 40 | data = dataset.get_dummyrot_item(i) 41 | raydir = data['raydir'].clone() 42 | pixel_idx = data['pixel_idx'].view(data['pixel_idx'].shape[0], -1, data['pixel_idx'].shape[3]).clone() 43 | visuals = None 44 | starttime=time.time() 45 | for k in range(0, height * width, chunk_size): 46 | start = k 47 | end = min([k + chunk_size, height * width]) 48 | 49 | data['raydir'] = raydir[:, start:end, :] 50 | data["pixel_idx"] = pixel_idx[:, start:end, :] 51 | # data['gt_image'] = gt_image[:, start:end, :] 52 | # data['gt_mask'] = gt_mask[:, start:end, :] 53 | model.set_input(data) 54 | model.test() 55 | curr_visuals = model.get_current_visuals() 56 | 57 | if visuals is None: 58 | visuals = {} 59 | for key, value in curr_visuals.items(): 60 | if value is None or value.shape[-1] != 3 or not key.endswith("color"): 61 | continue 62 | chunk = value.cpu().numpy() 63 | visuals[key] = np.zeros((height * width, 3)).astype(chunk.dtype) 64 | visuals[key][start:end, :] = chunk 65 | else: 66 | for key, value in curr_visuals.items(): 67 | if value is None or value.shape[-1] != 3 or not key.endswith("color"): 68 | continue 69 | visuals[key][start:end, :] = value.cpu().numpy() 70 | for key, value in visuals.items(): 71 | visuals[key] = visuals[key].reshape(height, width, 3) 72 | visual_lst.append(visuals) 73 | print("render time:", time.time() - starttime) 74 | visualizer.display_video(visual_lst, total_steps) 75 | model.train() 76 | print( 77 | '--------------------------------Finish Rendering--------------------------------' 78 | ) 79 | return 80 | 81 | 82 | def main(): 83 | torch.backends.cudnn.benchmark = True 84 | opt = TestOptions().parse() 85 | opt.no_loss = True 86 | opt.gpu_ids='0' 87 | 88 | if opt.debug: 89 | torch.autograd.set_detect_anomaly(True) 90 | print(fmt.RED + '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 91 | print('Debug Mode') 92 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' + fmt.END) 93 | 94 | if opt.resume_dir: 95 | resume_dir = opt.resume_dir 96 | resume_iter = opt.resume_iter if opt.resume_iter != "latest" else get_latest_epoch(resume_dir) 97 | opt.resume_iter = resume_iter 98 | states = torch.load(os.path.join(resume_dir, '{}_states.pth'.format(resume_iter))) 99 | epoch_count = states['epoch_count'] 100 | total_steps = states['total_steps'] 101 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 102 | print('Test {} at epoch {}'.format(opt.resume_dir, opt.resume_iter)) 103 | print("Iter: ", total_steps) 104 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 105 | else: 106 | epoch_count = 1 107 | total_steps = 0 108 | 109 | # load model 110 | model = create_model(opt) 111 | model.setup(opt) 112 | visualizer = Visualizer(opt) 113 | 114 | # create test loader 115 | test_opt = copy.deepcopy(opt) 116 | test_opt.is_train = False 117 | test_opt.random_sample = 'no_crop' 118 | test_opt.batch_size = 1 119 | test_opt.n_threads = 0 120 | test_dataset = create_dataset(test_opt) 121 | dataset_size = len(test_dataset) 122 | 123 | print('# training images = {}'.format(dataset_size)) 124 | 125 | with open('/tmp/.neural-volumetric.name', 'w') as f: 126 | f.write(opt.name + '\n') 127 | 128 | visualizer.reset() 129 | render_vid(model, test_dataset, visualizer, test_opt, total_steps) 130 | 131 | 132 | if __name__ == '__main__': 133 | main() 134 | -------------------------------------------------------------------------------- /run/vis_grow_train.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import pathlib 4 | sys.path.append(os.path.join(pathlib.Path(__file__).parent.absolute(), '..')) 5 | import glob 6 | import copy 7 | import torch 8 | import numpy as np 9 | import time 10 | from options import TrainOptions 11 | from data import create_data_loader, create_dataset 12 | from models import create_model 13 | from models.mvs.mvs_points_model import MvsPointsModel 14 | from models.mvs import mvs_utils, filter_utils 15 | 16 | from utils.visualizer import Visualizer 17 | from utils import format as fmt 18 | from run.evaluate import report_metrics 19 | # from render_vid import render_vid 20 | torch.manual_seed(0) 21 | np.random.seed(0) 22 | from tqdm import tqdm 23 | import cv2 24 | from PIL import Image 25 | import imageio 26 | from utils.util import to8b 27 | 28 | 29 | def read_image(filepath, dtype=None): 30 | image = np.asarray(Image.open(filepath)) 31 | if dtype is not None and dtype == np.float32: 32 | image = (image / 255).astype(dtype) 33 | return image 34 | 35 | 36 | def render_grow(pnt_dir, iters, vids): 37 | print('-----------------------------------Rendering Grow-----------------------------------') 38 | 39 | 40 | # visualizer.save_neural_points(200, np.concatenate(cam_posts, axis=0),None, None, save_ref=False) 41 | # visualizer.save_neural_points(200, np.concatenate(cam_dirs, axis=0),None, None, save_ref=False) 42 | # print("vis") 43 | # exit() 44 | for t in tqdm(range(len(vids))): 45 | vid = vids[t] 46 | img_lst = [] 47 | for iter in iters: 48 | img_dir = os.path.join(pnt_dir, 'prob_img_{}'.format(iter)) 49 | # ''step-{:04d}-{}.png'.format(i, name)) 50 | img_filepath = os.path.join(img_dir, "step-{}-0-ref0.png".format(vid)) 51 | img_arry = read_image(img_filepath, dtype=np.float32) 52 | img_lst.append(img_arry) 53 | 54 | stacked_imgs = [to8b(img_arry) for img_arry in img_lst] 55 | filename = 'grow_video_{:04d}.mov'.format(vid) 56 | imageio.mimwrite(os.path.join(pnt_dir, filename), stacked_imgs, fps=3, quality=8) 57 | filename = 'grow_video_{:04d}.gif'.format(vid) 58 | imageio.mimwrite(os.path.join(pnt_dir, filename), stacked_imgs, fps=3, format='GIF') 59 | return 60 | 61 | 62 | if __name__ == '__main__': 63 | pnt_dir = "/home/xharlie/user_space/codes/testNr/checkpoints/scan103_normcam2_confcolordir_KNN8_LRelu_grid800_dmsk_full2geo0_agg2_zeroone1e4_confree_prl2e3_probe2e3_1_comb/points" 64 | iters = list(range(1000, 25000, 1000)) 65 | vids = list(range(16, 20)) 66 | render_grow(pnt_dir, iters, vids) 67 | -------------------------------------------------------------------------------- /run/visualize.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import pathlib 4 | sys.path.append(os.path.join(pathlib.Path(__file__).parent.absolute(), '..')) 5 | 6 | import copy 7 | import torch 8 | import numpy as np 9 | import time 10 | from options import TestOptions 11 | from data import create_data_loader, create_dataset 12 | from models import create_model 13 | from utils.visualizer import Visualizer 14 | from utils import format as fmt 15 | 16 | 17 | def main(): 18 | torch.backends.cudnn.benchmark = True 19 | opt = TestOptions().parse() 20 | 21 | if opt.debug: 22 | torch.autograd.set_detect_anomaly(True) 23 | print(fmt.RED + '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 24 | print('Debug Mode') 25 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' + fmt.END) 26 | 27 | assert opt.resume_dir is not None 28 | resume_dir = opt.resume_dir 29 | states = torch.load(os.path.join(resume_dir, '{}_states.pth'.format(opt.resume_iter))) 30 | epoch_count = states['epoch_count'] 31 | total_steps = states['total_steps'] 32 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 33 | print('Resume from {} epoch'.format(opt.resume_iter)) 34 | print("Iter: ", total_steps) 35 | print('++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++') 36 | 37 | # load model 38 | model = create_model(opt) 39 | model.setup(opt) 40 | 41 | thres = 10 42 | grid, argb = model.net_ray_marching.module.build_point_cloud_visualization(0) 43 | mask = argb[..., 0] > thres 44 | points = grid[mask] 45 | colors = argb[mask][..., 1:4] 46 | 47 | import pyrender 48 | mesh = pyrender.Mesh.from_points(points, colors=colors) 49 | scene = pyrender.Scene() 50 | scene.add(mesh) 51 | pyrender.Viewer(scene, render_flags={'point_size': 10}, use_raymond_lighting=True) 52 | 53 | 54 | if __name__ == '__main__': 55 | main() 56 | -------------------------------------------------------------------------------- /utils/format.py: -------------------------------------------------------------------------------- 1 | PURPLE = '\033[1;35;48m' 2 | CYAN = '\033[1;36;48m' 3 | BOLD = '\033[1;37;48m' 4 | BLUE = '\033[1;34;48m' 5 | GREEN = '\033[1;32;48m' 6 | YELLOW = '\033[1;33;48m' 7 | RED = '\033[1;31;48m' 8 | BLACK = '\033[1;30;48m' 9 | UNDERLINE = '\033[4;37;48m' 10 | END = '\033[1;37;0m' 11 | -------------------------------------------------------------------------------- /utils/ncg_string.py: -------------------------------------------------------------------------------- 1 | '''Manipulate strings''' 2 | 3 | 4 | def underscore2camelcase(s): 5 | assert s == s.lower(), 'Invalid underscore string: no upper case character is allowed, in "{}"'.format(s) 6 | assert all([x.isdigit() or x.isalpha() or x == '_' for x in s]),\ 7 | 'Invalid underscore, all character must be letters or numbers or underscore' 8 | terms = s.split('_') 9 | for x in terms: 10 | assert x, 'Invalid underscore string: no consecutive _ is allowed, in "{}"'.format(s) 11 | assert x[0].upper() != x[0], \ 12 | 'Invalid underscore string: phrases must start with a character, in "{}'.format(s) 13 | 14 | return ''.join([x[0].upper() + x[1:] for x in terms if x]) 15 | 16 | 17 | def camelcase2underscore(s): 18 | assert s[0].isupper(), 'Invalid camel case, first character must be upper case, in "{}"'.format(s) 19 | assert all([x.isdigit() or x.isalpha() for x in s]),\ 20 | 'Invalid camel case, all character must be letters or numbers' 21 | 22 | out = s[0].lower() 23 | for x in s[1:]: 24 | if x.lower() != x: 25 | out += '_' + x.lower() 26 | else: 27 | out += x 28 | return out 29 | -------------------------------------------------------------------------------- /utils/util.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import torch 3 | import numpy as np 4 | from PIL import Image 5 | import os 6 | from torchvision.utils import make_grid 7 | from os.path import join 8 | import torch.nn.functional as F 9 | import matplotlib as mpl 10 | import matplotlib.cm as cm 11 | import matplotlib.pyplot as plt 12 | from scipy.spatial.transform import Rotation as R 13 | 14 | 15 | def mkdir(path): 16 | if not os.path.exists(path): 17 | os.makedirs(path) 18 | 19 | 20 | def add_property2dict(target_dict, object, props): 21 | for prop in props: 22 | target_dict[prop] = getattr(object, prop) 23 | 24 | 25 | def normalize(v, axis=0): 26 | # axis = 0, normalize each col 27 | # axis = 1, normalize each row 28 | return v / (np.linalg.norm(v, axis=axis, keepdims=True) + 1e-9) 29 | 30 | 31 | def to8b(x): return (255*np.clip(x, 0, 1)).astype(np.uint8) 32 | 33 | 34 | def gen_render_path(c2ws, N_views=30): 35 | N = len(c2ws) 36 | rotvec, positions = [], [] 37 | rotvec_inteplat, positions_inteplat = [], [] 38 | weight = np.linspace(1.0, .0, N_views//3, endpoint=False).reshape(-1, 1) 39 | for i in range(N): 40 | r = R.from_matrix(c2ws[i, :3, :3]) 41 | euler_ange = r.as_euler('xyz', degrees=True).reshape(1, 3) 42 | if i: 43 | mask = np.abs(euler_ange - rotvec[0])>180 44 | euler_ange[mask] += 360.0 45 | rotvec.append(euler_ange) 46 | positions.append(c2ws[i, :3, 3:].reshape(1, 3)) 47 | 48 | if i: 49 | rotvec_inteplat.append(weight * rotvec[i - 1] + (1.0 - weight) * rotvec[i]) 50 | positions_inteplat.append(weight * positions[i - 1] + (1.0 - weight) * positions[i]) 51 | 52 | rotvec_inteplat.append(weight * rotvec[-1] + (1.0 - weight) * rotvec[0]) 53 | positions_inteplat.append(weight * positions[-1] + (1.0 - weight) * positions[0]) 54 | 55 | c2ws_render = [] 56 | angles_inteplat, positions_inteplat = np.concatenate(rotvec_inteplat), np.concatenate(positions_inteplat) 57 | for rotvec, position in zip(angles_inteplat, positions_inteplat): 58 | c2w = np.eye(4) 59 | c2w[:3, :3] = R.from_euler('xyz', rotvec, degrees=True).as_matrix() 60 | c2w[:3, 3:] = position.reshape(3, 1) 61 | c2ws_render.append(c2w.copy()) 62 | c2ws_render = np.stack(c2ws_render) 63 | return c2ws_render 64 | 65 | 66 | def unique_lst(list1): 67 | x = np.array(list1) 68 | return np.unique(x) 69 | --------------------------------------------------------------------------------