datasets icon indicating copy to clipboard operation
datasets copied to clipboard

Example on Semantic segmentation contains bug

Open ducha-aiki opened this issue 1 year ago • 0 comments

Describe the bug

https://huggingface.co/docs/datasets/en/semantic_segmentation shows wrong example with torchvision transforms. Specifically, as one can see in screenshot below, the object boundaries have weird colors.

image

Original example with albumentations is correct image

That is because torch vision.transforms.Resize interpolates with bilinear everything which is wrong when used for segmentation labels - you just cannot mix them. Overall, torchvision.transforms is designed for classification only and cannot be used to images and masks together, unless you write two separate branches of augmentations.

The correct way would be to use v2 version of transforms and convert the segmentation labels to https://pytorch.org/vision/main/generated/torchvision.tv_tensors.Mask.html#torchvision.tv_tensors.Mask object

Steps to reproduce the bug

Go to the website. image

https://huggingface.co/docs/datasets/en/semantic_segmentation

Expected behavior

Results, similar to albumentation. Or remove the torch vision part altogether. Or use kornia instead.

Environment info

Irrelevant

ducha-aiki avatar May 03 '24 09:05 ducha-aiki