nianticlabs / monodepth2

[ICCV 2019] Monocular depth estimation from a single image
Other
4.13k stars 953 forks source link

IndexError: list index out of range #405

Closed gao3xin closed 2 years ago

gao3xin commented 2 years ago

Hi , Thanks for your wonderful work , I'am trying to finetune the monodepth model use my own datasets , but now I met a problem like this :

I run code: python train.py --model_name finetuned_mono --load_weights_folder /home/gaoxin/PycharmProjects/monodepth2_v2/models/mono_640x192

and get the error:

loading model from folder /home/gaoxin/PycharmProjects/monodepth2_v2/models/mono_640x192
Loading encoder weights...
Loading depth weights...
Loading pose_encoder weights...
Loading pose weights...
Cannot find Adam weights so Adam is randomly initialized
Training model named:
   finetuned_mono
Models and tensorboard events files are saved to:
   /home/gaoxin/tmp
Training is using:
   cuda
/home/gaoxin/.local/lib/python3.6/site-packages/torchvision/transforms/transforms.py:281: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
  "Argument interpolation should be of type InterpolationMode instead of int. "
Using split:
   tree
There are 2998 training items and 1078 validation items

/home/gaoxin/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:134: UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate
  "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning)
Training
/home/gaoxin/.local/lib/python3.6/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at  /pytorch/c10/core/TensorImpl.h:1156.)
  return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
/home/gaoxin/.local/lib/python3.6/site-packages/torch/nn/functional.py:3982: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
  "Default grid_sample and affine_grid behavior has changed "
epoch   0 | batch      0 | examples/s:  32.4 | loss: 0.10659 | time elapsed: 00h00m00s | time left: 00h00m00s
epoch   0 | batch    250 | examples/s:  44.3 | loss: 0.05393 | time elapsed: 00h00m38s | time left: 00h38m04s
epoch   0 | batch    500 | examples/s:  42.8 | loss: 0.09344 | time elapsed: 00h01m18s | time left: 00h38m02s
Traceback (most recent call last):
  File "train.py", line 18, in <module>
    trainer.train()
  File "/home/gaoxin/PycharmProjects/monodepth2_v2/trainer.py", line 190, in train
    self.run_epoch()
  File "/home/gaoxin/PycharmProjects/monodepth2_v2/trainer.py", line 202, in run_epoch
    for batch_idx, inputs in enumerate(self.train_loader):
  File "/home/gaoxin/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
    data = self._next_data()
  File "/home/gaoxin/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 561, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/gaoxin/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/gaoxin/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/gaoxin/PycharmProjects/monodepth2_v2/datasets/mono_dataset.py", line 162, in __getitem__
    inputs[("color", i, -1)] = self.get_color(folder, frame_index + i, side, do_flip)
  File "/home/gaoxin/PycharmProjects/monodepth2_v2/datasets/tree_dataset.py", line 44, in get_color
    image_path = os.path.join(self.data_path, folder, all_images[frame_index])
IndexError: list index out of range

I have checked my dataset and train.txt,and can't find anything out of range , can u help me to solve this? Thanks a lot!