Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #7

Open
Phulieu opened this issue Dec 9, 2020 · 4 comments
Open

IndexError: list index out of range #7

Phulieu opened this issue Dec 9, 2020 · 4 comments

Comments

@Phulieu
Copy link

Phulieu commented Dec 9, 2020

I am training with only cityscapes dataset
But I have some error below:
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\parke.conda\envs\untitled\lib\site-packages\torch\utils\data_utils\worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "C:\Users\parke.conda\envs\untitled\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\parke.conda\envs\untitled\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "E:\RFNet-master\dataloaders\datasets\cityscapes.py", line 54, in getitem
lbl_path = self.labels[self.split][index].rstrip()
IndexError: list index out of range

@AHupuJR
Copy link
Owner

AHupuJR commented Dec 22, 2020

That promblem seems not exist here in my local repository. Maybe you can debug and check your path

@tahaboub
Copy link

I am also having the same issue, I am wondering if it was resolved, Below is a similar issue or error, which I can't tell how it is originated. Any hint or recommendation that will highly appreciate it.

PS C:\dev1\RFNet> python train.py --depth --lr 1e-4 --weight-decay 2.5e-5 --workers 4 --epochs 200 --batch-size 8 --val-batch-size 3 --gpu-ids 0 --checkname test --eval-interval 2 --dataset cityscapes --loss-type ce --use-balanced-weights
Namespace(base_size=1024, batch_size=8, checkname='test', crop_size=768, cuda=False, dataset='cityscapes', depth=True, epochs=200, eval_interval=2, ft=False, gpu_ids='0', loss_type='ce', lr=0.0001, lr_scheduler='cos', momentum=0.9, no_cuda=False, no_val=False, resume=None, seed=1, start_epoch=0, test_batch_size=1, use_balanced_weights=True, val_batch_size=3, weight_decay=2.5e-05, workers=4)
Found 2975 train RGB images
Found 2975 train disparity images
Found 500 val RGB images
Found 500 val disparity images
Found 1525 test RGB images
Found 1525 test disparity images
Upsample layer: in = 128, skip = 64, out = 128
Upsample layer: in = 128, skip = 128, out = 128
Upsample layer: in = 128, skip = 256, out = 128
pretrained dict loaded sucessfully
0%| | 0/372 [00:00<?, ?it/s]Calculating classes weights
0%| | 0/372 [00:04<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 308, in
main()
File "train.py", line 297, in main
trainer = Trainer(args)
File "train.py", line 51, in init
weight = calculate_weigths_labels(args.dataset, self.train_loader, self.nclass)
File "C:\dev1\RFNet\utils\calculate_weights.py", line 12, in calculate_weigths_labels
for sample in tqdm_batch:
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\tqdm\std.py", line 1185, in iter
for obj in iterable:
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next
data = self._next_data()
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data\dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data\dataloader.py", line 1229, in _process_data
data.reraise()
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch_utils.py", line 425, in reraise
raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data_utils\worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\Admin\anaconda3\envs\th16\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\dev1\RFNet\dataloaders\datasets\cityscapes.py", line 53, in getitem
lbl_path = self.labels[self.split][index].rstrip()
IndexError: list index out of range

@TobiasMei
Copy link

I think it is a similar problem that I had when running eval.py.

In the dataloder file in this line:

self.labels[split] = self.recursive_glob(rootdir=self.annotations_base, suffix='labelTrainIds.png')

There is the suffix: 'labelTrainIds.png' set, but in my case the downloaded cityscapes dataset is named without 'Train' in the name. So i replaced the suffix with 'labelIds.png' and everything worked for me.

I hope this will also solve your problem.

@finetune-master
Copy link

This error reminds you to generate labelTrainIds.png.You can refer to this blog https://blog.csdn.net/lx_ros/article/details/125667076.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants