zzzyuqing / DreamMat

[SIGGRAPH2024] DreamMat: High-quality PBR Material Generation with Geometry- and Light-aware Diffusion Models
MIT License
289 stars 11 forks source link

error about AttributeError: 'list' object has no attribute 'dataset' #18

Closed xingyouxin closed 1 month ago

xingyouxin commented 1 month ago

Hello! I cloned the project and installed the matching environments. However, while running the sh codes, I meet an error as follows:

(env_dreammat) xyx@server-Super-Server:~/AITools/DreamMat/DreamMat/threestudio_dreammat$ sh cmd/run_examples.sh 
Global seed set to 0
cuda:0
/home/xyx/anaconda3/envs/env_dreammat/lib/python3.10/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at /opt/conda/conda-bld/pytorch_1678402411778/work/aten/src/ATen/native/TensorShape.cpp:3483.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Using /home/xyx/.cache/torch_extensions/py310_cu118 as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /home/xyx/.cache/torch_extensions/py310_cu118/renderutils_plugin/build.ninja...
Building extension module renderutils_plugin...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: no work to do.
Loading extension module renderutils_plugin...
EnvProbe, torch.Size([2048, 4096, 3]) , min/max 0.07114315032958984 70.25756072998047
EnvProbe, torch.Size([2048, 4096, 3]) , min/max 0.00439453125 36.5
EnvProbe, torch.Size([2048, 4096, 3]) , min/max 0.002166748046875 117.5
EnvProbe, torch.Size([2048, 4096, 3]) , min/max 0.0 370.0
EnvProbe, torch.Size([2048, 4096, 3]) , min/max 0.0 17.375
[INFO] GPU available: True (cuda), used: True
[INFO] TPU available: False, using: 0 TPU cores
[INFO] IPU available: False, using: 0 IPUs
[INFO] HPU available: False, using: 0 HPUs
You are using a CUDA device ('NVIDIA GeForce RTX 4090') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision
blender -b -P ./threestudio/data/blender_script_fixview.py -- --param_dir temp/render_fixview_temp.pkl --env_dir load/lights/envmap --output_dir outputs/dream_mat/A_cute_striped_kitten/pre_render --num_images 128
pre-rendering light conditions...please wait for about 15min
rendering done
[INFO] LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
[INFO] 
  | Name       | Type                 | Params
----------------------------------------------------
0 | geometry   | DreamMatMesh         | 13.0 M
1 | material   | DreamMatMaterial     | 164 K 
2 | background | SolidColorBackground | 0     
3 | renderer   | RaytraceRender       | 0     
----------------------------------------------------
13.2 M    Trainable params
0         Non-trainable params
13.2 M    Total params
52.859    Total estimated model params size (MB)
[INFO] Validation results will be saved to outputs/dream_mat/A_cute_striped_kitten/save
[INFO] Using prompt [A cute striped kitten] and negative prompt [oversaturated color, ugly, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, poorly drawn eyes, low contrast, underexposed, overexposed, bright blue spots, glowing blue patches, intense blue highlights, Unrealistic highlights, Artificial shininess, Exaggerated light reflections, Unnatural facial expression, Inauthentic eye contact, low resolution]
[INFO] Using view-dependent prompts [side]:[A cute striped kitten, side view] [front]:[A cute striped kitten, front view] [back]:[A cute striped kitten, back view] [overhead]:[A cute striped kitten, overhead view]
[INFO] Loading Stable Diffusion ...
Loading pipeline components...: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:00<00:00,  6.00it/s]
[INFO] Loaded Stable Diffusion!
Sanity Checking: 0it [00:00, ?it/s]/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/connectors/data_connector.py:224: PossibleUserWarning: The dataloader, val_dataloader 0, does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` (try 48 which is the number of cpus on this machine) in the `DataLoader` init to improve performance.
  rank_zero_warn(
Sanity Checking DataLoader 0:   0%|                                                                                                                                                  | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
  File "/home/xyx/AITools/DreamMat/DreamMat/threestudio_dreammat/launch.py", line 244, in <module>
    main(args, extras)
  File "/home/xyx/AITools/DreamMat/DreamMat/threestudio_dreammat/launch.py", line 189, in main
    trainer.fit(system, datamodule=dm, ckpt_path=cfg.resume)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 608, in fit
    call._call_and_handle_interrupt(
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 650, in _fit_impl
    self._run(model, ckpt_path=self.ckpt_path)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1103, in _run
    results = self._run_stage()
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1182, in _run_stage
    self._run_train()
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1195, in _run_train
    self._run_sanity_check()
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1267, in _run_sanity_check
    val_loop.run()
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/loops/dataloader/evaluation_loop.py", line 152, in advance
    dl_outputs = self.epoch_loop.run(self._data_fetcher, dl_max_batches, kwargs)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/loops/loop.py", line 199, in run
    self.advance(*args, **kwargs)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 132, in advance
    self._on_evaluation_batch_start(**kwargs)
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/loops/epoch/evaluation_epoch_loop.py", line 262, in _on_evaluation_batch_start
    self.trainer._call_lightning_module_hook(hook_name, *kwargs.values())
  File "/home/xyx/.local/lib/python3.10/site-packages/pytorch_lightning/trainer/trainer.py", line 1347, in _call_lightning_module_hook
    output = fn(*args, **kwargs)
  File "/home/xyx/AITools/DreamMat/DreamMat/threestudio_dreammat/threestudio/systems/base.py", line 182, in on_validation_batch_start
    self.dataset = self.trainer.val_dataloaders.dataset
AttributeError: 'list' object has no attribute 'dataset'

Could anyone help me? Thank you very mush!

xingyouxin commented 1 month ago

By debugging, I found the self.trainer.val_dataloaders is a list. It includes one DataLoader as follows: image

So, I changed the codes to self.dataset = self.trainer.val_dataloaders[0].dataset. Then the error disappeared.