NVlabs / nvdiffrec

Official code for the CVPR 2022 (oral) paper "Extracting Triangular 3D Models, Materials, and Lighting From Images".
Other
2.09k stars 222 forks source link

I got error on dataset.py. Sizes of tensors must match except in dimension 0. Expected size 4 but got size 5 for tensor number 1 in the list. #126

Closed ysmreg closed 1 year ago

ysmreg commented 1 year ago

i got one error. I am using 17 512*512 images and masks. I ran it with a batch size of 10, but it stopped with an error that the tensor size was wrong. I would like to know how to solve

ysmreg commented 1 year ago

error message `Config / Flags:

config configs/kyara_rescaled.json iter 5000 batch 10 spp 1 layers 1 train_res [512, 512] display_res [512, 512] texture_res [2048, 2048] display_interval 0 save_interval 100 learning_rate [0.03, 0.01] min_roughness 0.08 custom_mip False random_textures True background white loss logl1 out_dir out/kyara ref_mesh data/nerd/kyara base_mesh None validate True mtl_override None dmtet_grid 64 mesh_scale 2.5 env_scale 1.0 envmap None display [{'bsdf': 'kd'}, {'bsdf': 'ks'}, {'bsdf': 'normal'}] camera_space_light True lock_light False lock_pos False sdf_regularizer 0.2 laplace relative laplace_scale 10000.0 pre_load True kd_min [0.03, 0.03, 0.03] kd_max [0.8, 0.8, 0.8] ks_min [0, 0.08, 0] ks_max [0, 1.0, 1.0] nrm_min [-1.0, -1.0, 0.0] nrm_max [1.0, 1.0, 1.0] cam_near_far [0.1, 1000.0] learn_light True local_rank 0 multi_gpu False

DatasetLLFF: 17 images with shape [512, 512] DatasetLLFF: auto-centering at [-0.41304994 2.6057422 8.97906 ] DatasetLLFF: 17 images with shape [512, 512] DatasetLLFF: auto-centering at [-0.41304994 2.6057422 8.97906 ] Encoder output: 32 dims Traceback (most recent call last): File "train.py", line 594, in geometry, mat = optimize_mesh(glctx, geometry, mat, lgt, dataset_train, dataset_validate, File "train.py", line 381, in optimize_mesh for it, target in enumerate(dataloader_train): File "/home/user/torch/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/user/torch/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/user/torch/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch return self.collate_fn(data) File "/home/user/torchtest/nvdiffrec/dataset/dataset.py", line 31, in collate 'img' : torch.cat(list([item['img'] for item in batch]), dim=0) RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 4 but got size 5 for tensor number 1 in the list.`

ysmreg commented 1 year ago

It worked after correcting the bit depth