question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Training Mask R-CNN using RLE bitmasks error

See original GitHub issue

I am following the Mask R-CNN tutorial and changed the dataset_dict to support segmentation maps in bitmap format using RLE instead of polygons. I confirmed the data is processed properly using detectron2 visualization tool. When trying to train the network, I’m getting an error regarding polygons.

File "/home/ubuntu/detectron2/detectron2/data/detection_utils.py", line 149, in transform_instance_annotations polygons = [np.asarray(p).reshape(-1, 2) for p in annotation["segmentation"]] File "/home/ubuntu/detectron2/detectron2/data/detection_utils.py", line 149, in <listcomp> polygons = [np.asarray(p).reshape(-1, 2) for p in annotation["segmentation"]] ValueError: cannot reshape array of size 1 into shape (2)

It seems there is no support for RLE format during training although the visualization works. Is there any way to train using bitmasks?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
siyuanfeng-tricommented, Apr 16, 2020

The above issue about evaluation is hopefully fixed in 6901cc7

I think I need to do a bit more to get this actually working.

  1. I had to cast this into int explicitly, otherwise json dump complains about TypeError: Object of type 'uint32' is not JSON serializable https://github.com/facebookresearch/detectron2/blob/master/detectron2/data/datasets/coco.py#L339
  2. I had to decode segmentation["counts"] into an ascii string otherwise json dump complains about not being able to serialize bytes. TypeError: Object of type 'bytes' is not JSON serializable
4reactions
ppwwyyxxcommented, Mar 2, 2020

Now the default dataloader can work with RLE formats inside your dataset. All you need is:

  1. use RLE format (documented at https://detectron2.readthedocs.io/tutorials/datasets.html#standard-dataset-dicts) in your dataset
  2. set INPUT.MASK_FORMAT='bitmask'.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for detectron2.structures.masks
This function is used when generating training targets for mask head in Mask R-CNN. Given original ground-truth masks for an image, new ground-truth...
Read more >
284 - Installing Mask RCNN and troubleshooting errors
Installing Mask RCNN for Windows on Python 3.7 and TensorFlow 2.2.Link to the original repo from matterport that works on ...
Read more >
Github项目- detectron2 分割数据格式polygon和bitmask
This can be used to prepare training targets for Mask R-CNN. It has less reconstruction error compared to rasterization with polygons.
Read more >
Training Mask R-CNN - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from iMaterialist (Fashion) 2019 at FGVC6.
Read more >
Create COCO Annotations From Scratch - Immersive Limit
Using Bit Masks. While the original dataset was created by manually drawing polygons, it's also possible to automatically generate polygons if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found