Error decoding masks when training Mask R-CNN
See original GitHub issueInstructions To Reproduce the Issue:
- what changes you made (
git diff
) or what code you wrote
register_coco_instances("corn", {}, "annos.json", ".")
My annotation file looks like this:
"annotations": [
{
"id": 2159120,
"image_id": 2159100,
"category_id": 2159121,
"segmentation": {
"counts": [
492904,
18,
3015,
18,
.....],
"size": [
3033,
2275
]
},
"area": 0,
"bbox": [
162,
1502,
229,
123
],
"iscrowd": 0
},
.....
]
- what exact command you run: I use the same training code in the Getting Started notebook.
- what you observed (including the full logs):
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/detectron2/engine/train_loop.py", line 132, in train
self.run_step()
File "/usr/local/lib/python3.6/dist-packages/detectron2/engine/train_loop.py", line 208, in run_step
data = next(self._data_loader_iter)
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/common.py", line 109, in __iter__
for d in self.dataset:
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 345, in __next__
data = self._next_data()
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 856, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 881, in _process_data
data.reraise()
File "/usr/local/lib/python3.6/dist-packages/torch/_utils.py", line 394, in reraise
raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/common.py", line 39, in __getitem__
data = self._map_func(self._dataset[cur_idx])
File "/usr/local/lib/python3.6/dist-packages/detectron2/utils/serialize.py", line 23, in __call__
return self._obj(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/dataset_mapper.py", line 128, in __call__
for obj in dataset_dict.pop("annotations")
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/dataset_mapper.py", line 129, in <listcomp>
if obj.get("iscrowd", 0) == 0
File "/usr/local/lib/python3.6/dist-packages/detectron2/data/detection_utils.py", line 180, in transform_instance_annotations
mask = mask_util.decode(segm)
File "/usr/local/lib/python3.6/dist-packages/pycocotools/mask.py", line 91, in decode
return _mask.decode([rleObjs])[:,:,0]
File "pycocotools/_mask.pyx", line 146, in pycocotools._mask.decode
File "pycocotools/_mask.pyx", line 128, in pycocotools._mask._frString
TypeError: Expected bytes, got list
Expected behavior:
The annotations show up when using the visualizer, but there’s the above error when training
Environment:
sys.platform linux Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] numpy 1.17.5 detectron2 0.1 @/usr/local/lib/python3.6/dist-packages/detectron2 detectron2 compiler GCC 7.3 detectron2 CUDA compiler 10.0 detectron2 arch flags sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75 DETECTRON2_ENV_MODULE <not set> PyTorch 1.4.0+cu100 @/usr/local/lib/python3.6/dist-packages/torch PyTorch debug build False CUDA available True GPU 0 Tesla P100-PCIE-16GB CUDA_HOME /usr/local/cuda NVCC Cuda compilation tools, release 10.0, V10.0.130 Pillow 6.2.2 torchvision 0.5.0+cu100 @/usr/local/lib/python3.6/dist-packages/torchvision torchvision arch flags sm_35, sm_50, sm_60, sm_70, sm_75 cv2 4.1.2
PyTorch built with:
- GCC 7.3
- Intel® Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel® 64 architecture applications
- Intel® MKL-DNN v0.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- NNPACK is enabled
- CUDA Runtime 10.0
- NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
- CuDNN 7.6.3
- Magma 2.5.1
- Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top GitHub Comments
Turns out what I have is uncompressed RLE format. To compress it:
where
rle
is the uncompressed RLE dictmask is supposed to be the segmentation mask.
Then you need to figure out how to convert “your RLE”, whatever it means, into the RLE format
pycocotools.mask.encode
produces. This is not related to detectron2.