git diff) or what code you wroteregister_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
},
.....
]
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
The annotations show up when using the visualizer, but there's the above error when training
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
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:
Please follow the documentation https://detectron2.readthedocs.io/tutorials/datasets.html and use
鈺扳攢$ pycocotools.mask.encode(np.asarray(mask.astype("uint8"), order="F"))
Out[9]: {'size': [30, 30], 'counts': b'Tl0'}
to produce masks at the correct format.
@ppwwyyxx what is mask.astype("uint8") supposed to be? Is it the list of numbers in the counts attribute?
Have you seen my annotations yet? I am not trying to convert binary masks since I've already got RLE I think.
"segmentation": {
"counts": [
492904,
18,
3015,
18,
.....],
"size": [
3033,
2275
]
},
I just don't know how to convert this big list of numbers to the byte string that you got above.
what is mask.astype("uint8") supposed to be
mask is supposed to be the segmentation mask.
am not trying to convert binary masks since I've already got RLE I think.
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.
Turns out what I have is uncompressed RLE format. To compress it:
pycocotools.mask.frPyObjects(rle, rle['size'][0], rle['size'][1])
where rle is the uncompressed RLE dict
Most helpful comment
Turns out what I have is uncompressed RLE format. To compress it:
where
rleis the uncompressed RLE dict