-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
🐛 Describe the bug
draw_segmentation_masks throws an IndexError when it recieves an empty mask tensor as it tries to check preconditions on colors.
It'd be good to fix the bug to allow to draw empty mask tensors or to add the precondition in the doc and a clear assert.
As an asside it looks like draw_bounding_boxes has the same probleme.
from torchvision.utils import draw_segmentation_masks
import torch
from torch import uint8
img = torch.rand((3,100,100)).type(uint8)
masks = torch.rand((0,100,100)).bool()
draw_segmentation_masks(img, masks)---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
/tmp/ipykernel_548012/3010128033.py in <module>
6 masks = torch.rand((0,100,100)).bool()
7
----> 8 draw_segmentation_masks(img, masks)
/data/apps/conda/matthieu/envs/apriorics/lib/python3.9/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
26 def decorate_context(*args, **kwargs):
27 with self.__class__():
---> 28 return func(*args, **kwargs)
29 return cast(F, decorate_context)
30
/data/apps/conda/matthieu/envs/apriorics/lib/python3.9/site-packages/torchvision/utils.py in draw_segmentation_masks(image, masks, alpha, colors)
278 if not isinstance(colors, list):
279 colors = [colors]
--> 280 if not isinstance(colors[0], (tuple, str)):
281 raise ValueError("colors must be a tuple or a string, or a list thereof")
282 if isinstance(colors[0], tuple) and len(colors[0]) != 3:
IndexError: list index out of range
Versions
PyTorch version: 1.10.2
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
OS: CentOS Stream release 8 (x86_64)
GCC version: (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)
Clang version: Could not collect
CMake version: version 3.20.2
Libc version: glibc-2.28
Python version: 3.9.7 (default, Sep 16 2021, 13:09:58) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-4.18.0-365.el8.x86_64-x86_64-with-glibc2.28
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration:
GPU 0: Tesla P100-PCIE-16GB
GPU 1: Tesla P100-PCIE-16GB
Nvidia driver version: 510.47.03
cuDNN version: Probably one of the following:
/usr/lib64/libcudnn.so.8.3.2
/usr/lib64/libcudnn_adv_infer.so.8.3.2
/usr/lib64/libcudnn_adv_train.so.8.3.2
/usr/lib64/libcudnn_cnn_infer.so.8.3.2
/usr/lib64/libcudnn_cnn_train.so.8.3.2
/usr/lib64/libcudnn_ops_infer.so.8.3.2
/usr/lib64/libcudnn_ops_train.so.8.3.2
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Versions of relevant libraries:
[pip3] mypy==0.942
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.22.1
[pip3] pytorch-lightning==1.5.9
[pip3] torch==1.10.2
[pip3] torchaudio==0.10.2
[pip3] torchmetrics==0.7.1
[pip3] torchsummary==1.5.1
[pip3] torchvision==0.11.3
[conda] blas 1.0 mkl
[conda] cudatoolkit 10.2.89 hfd86e86_1
[conda] ffmpeg 4.3 hf484d3e_0 pytorch
[conda] mkl 2022.0.1 h06a4308_117
[conda] mypy 0.942 pypi_0 pypi
[conda] mypy-extensions 0.4.3 pypi_0 pypi
[conda] numpy 1.22.1 pypi_0 pypi
[conda] pytorch 1.10.2 py3.9_cuda10.2_cudnn7.6.5_0 pytorch
[conda] pytorch-lightning 1.5.9 pypi_0 pypi
[conda] pytorch-mutex 1.0 cuda pytorch
[conda] torchaudio 0.10.2 py39_cu102 pytorch
[conda] torchmetrics 0.7.1 pypi_0 pypi
[conda] torchsummary 1.5.1 pypi_0 pypi
[conda] torchvision 0.11.3 py39_cu102 pytorch