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

ValueError: Segmentation map contained invalid class values #247

Open
GutlapalliNikhil opened this issue Oct 19, 2020 · 2 comments
Open

Comments

@GutlapalliNikhil
Copy link

Hi guys,

I was trying to run cityscapes dataset. While doing train.py, I was getting this error like,

RUNDIR: runs/frrnB_cityscapes/26539
Found 20 train images
Found 10 val images
INFO:ptsemseg:Using cross_entropy with {} params
INFO:ptsemseg:Using loss functools.partial(<function cross_entropy2d at 0x7fdc8ce9c158>)
INFO:ptsemseg:No checkpoint found at 'frrnB_cityscapes_best_model.pkl'
Traceback (most recent call last):
File "train.py", line 229, in
train(cfg, writer, logger)
File "train.py", line 118, in train
for (images, labels) in trainloader:
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 336, in next
return self._process_next_batch(batch)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
ValueError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 106, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/content/pytorch-semseg/ptsemseg/loader/cityscapes_loader.py", line 166, in getitem
img, lbl = self.transform(img, lbl)
File "/content/pytorch-semseg/ptsemseg/loader/cityscapes_loader.py", line 197, in transform
raise ValueError("Segmentation map contained invalid class values")
ValueError: Segmentation map contained invalid class values

Can someone help me in this.

Thank you.

@kubitz
Copy link

kubitz commented Dec 27, 2020

Not exactly sure what is causing the error, but it will disappear if you turn data augmentation off

@farnaznouraei
Copy link

farnaznouraei commented Feb 8, 2021

Not sure if this is a similar issue, but I was working with the Pascal dataloader and realized the .resize() functions used in the transforms are generating new (undefined) values in the segmentation map. If you change all data read/write and resize function to cv2 functions, with resizing via NEAREST NEIGHBOR (interpolation =cv2.INTER_NEAREST), it could help preserve the class integers/colors.

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

3 participants