Boundary-preserving Mask R-CNN (ECCV 2020)

Overview

BMaskR-CNN

This code is developed on Detectron2

Boundary-preserving Mask R-CNN
ECCV 2020
Tianheng Cheng, Xinggang Wang, Lichao Huang, Wenyu Liu

Video from Cam看世界 on Youtube.

Abstract

Tremendous efforts have been made to improve mask localization accuracy in instance segmentation. Modern instance segmentation methods relying on fully convolutional networks perform pixel-wise classification, which ignores object boundaries and shapes, leading coarse and indistinct mask prediction results and imprecise localization. To remedy these problems, we propose a conceptually simple yet effective Boundary-preserving Mask R-CNN (BMask R-CNN) to leverage object boundary information to improve mask localization accuracy. BMask R-CNN contains a boundary-preserving mask head in which object boundary and mask are mutually learned via feature fusion blocks. As a result,the mask prediction results are better aligned with object boundaries. Without bells and whistles, BMask R-CNN outperforms Mask R-CNN by a considerable margin on the COCO dataset; in the Cityscapes dataset,there are more accurate boundary groundtruths available, so that BMaskR-CNN obtains remarkable improvements over Mask R-CNN. Besides, it is not surprising to observe that BMask R-CNN obtains more obvious improvement when the evaluation criterion requires better localization (e.g., AP75)

Models

COCO

Method Backbone lr sched AP AP50 AP75 APs APm APl download
Mask R-CNN R50-FPN 1x 35.2 56.3 37.5 17.2 37.7 50.3 -
PointRend R50-FPN 1x 36.2 56.6 38.6 17.1 38.8 52.5 -
BMask R-CNN R50-FPN 1x 36.6 56.7 39.4 17.3 38.8 53.8 model
BMask R-CNN R101-FPN 1x 38.0 58.6 40.9 17.6 40.6 56.8 model
Cascade Mask R-CNN R50-FPN 1x 36.4 56.9 39.2 17.5 38.7 52.5 -
Cascade BMask R-CNN R50-FPN 1x 37.5 57.3 40.7 17.5 39.8 55.1 model
Cascade BMask R-CNN R101-FPN 1x 39.1 59.2 42.4 18.6 42.2 57.4 model

Cityscapes

  • Initialized from ImagetNet pre-training.
Method Backbone lr sched AP download
PointRend R50-FPN 1x 35.9 -
BMask R-CNN R50-FPN 1x 36.2 model

Results

Left: AP curves of Mask R-CNN and BMask R-CNN under different mask IoU thresholds on the COCO val2017 set, the improvement becomes more significant when IoU increases. Right: Visualizations of Mask R-CNN and BMask R-CNN. BMask R-CNN can output more precise boundaries and accurate masks than Mask R-CNN.

Usage

Install Detectron2 following the official instructions

Training

specify a config file and train a model with 4 GPUs

cd projects/BMaskR-CNN
python train_net.py --config-file configs/bmask_rcnn_R_50_FPN_1x.yaml --num-gpus 4

Evaluation

specify a config file and test with trained model

cd projects/BMaskR-CNN
python train_net.py --config-file configs/bmask_rcnn_R_50_FPN_1x.yaml --num-gpus 4 --eval-only MODEL.WEIGHTS /path/to/model

Citation

@article{ChengWHL20,
  title={Boundary-preserving Mask R-CNN},
  author={Tianheng Cheng and Xinggang Wang and Lichao Huang and Wenyu Liu},
  booktitle={ECCV},
  year={2020}
}
Comments
  • KeyError:

    KeyError: "No object named 'BoundaryROIHeads' found in 'ROI_HEADS' registry!"

    When trying to run the demo.py, keep getting registry related problems. Have tried to modify the code in the detectron2 module, but unsuccessfully.

    Is there anyone who encountered this problem? How did you solve it?

    opened by PytaichukBohdan 7
  • how to predict

    how to predict "image" with pretrained weight?

    Hello,

    I usually use detectron2 and predict image detection and classfication. I tried to test you solution with almost same method used in detection2. but I got test code and error like below

    ---------------------------------------TEST Code------------------------------------------------------ cfg = get_cfg() bmaskrcnn.add_boundary_preserving_config(cfg) // Load a config from file cfg.merge_from_file("bmask_repo/projects/BMaskR-CNN/configs/bmask_rcnn_R_50_FPN_1x.yaml") cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
    cfg.MODEL.WEIGHTS = "/content/gdrive/My Drive/bmask/bmask_rcnn_r50_1x.pth" bmask_predictor = DefaultPredictor(cfg) outputs = bmask_predictor(im)

    --------------------------------------ERROR MESSAGE------------------------------------------------------- TypeError Traceback (most recent call last) in () 12 #cfg.MODEL.WEIGHTS = "https://dl.fbaipublicfiles.com/detectron2/PointRend/InstanceSegmentation/pointrend_rcnn_R_50_FPN_1x_cityscapes/164255101/model_final_318a02.pkl" 13 #cfg.MODEL.WEIGHTS = "https://dl.fbaipublicfiles.com/detectron2/PointRend/SemanticSegmentation/pointrend_semantic_R_101_FPN_1x_cityscapes/186480235/model_final_5f3665.pkl" ---> 14 bmask_predictor = DefaultPredictor(cfg) 15 outputs = bmask_predictor(im)

    5 frames /usr/local/lib/python3.6/dist-packages/detectron2/modeling/roi_heads/roi_heads.py in init(self, cfg, input_shape) 469 super(StandardROIHeads, self).init(cfg, input_shape) 470 self._init_box_head(cfg) --> 471 self._init_mask_head(cfg) 472 self._init_keypoint_head(cfg) 473

    TypeError: _init_mask_head() missing 1 required positional argument: 'input_shape'

    Could you give me guide to test ? if you have colab code, I am more happy .

    opened by charlescho64 6
  • What is different between Cascade BMask R-CNN and X101-FPN in detectron2 ?

    What is different between Cascade BMask R-CNN and X101-FPN in detectron2 ?

    Hello,

    I have question about your work. It seems X101-FPN (detectron2's result table) is better than R-101. If your model use X101-FPN baseline, is it much better? So if you didn't, is there some reason?

    opened by charlescho64 5
  • FloatingPointError: Predicted boxes or scores contain Inf/NaN. Training has diverged.

    FloatingPointError: Predicted boxes or scores contain Inf/NaN. Training has diverged.

    Hi, when I run configs/bmask_rcnn_R_50_FPN_1x.yaml, it ran 739 iters,then I meet the question as follows, Traceback (most recent call last): File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/engine/train_loop.py", line 140, in train self.run_step() File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/engine/train_loop.py", line 226, in run_step loss_dict = self.model(data) File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call result = self.forward(*input, **kwargs) File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/modeling/meta_arch/rcnn.py", line 160, in forward proposals, proposal_losses = self.proposal_generator(images, features, gt_instances) File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call result = self.forward(*input, **kwargs) File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/modeling/proposal_generator/rpn.py", line 449, in forward anchors, pred_objectness_logits, pred_anchor_deltas, images.image_sizes File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/modeling/proposal_generator/rpn.py", line 486, in predict_proposals self.training, File "/home/l547/anaconda3/envs/zt/lib/python3.7/site-packages/detectron2/modeling/proposal_generator/proposal_utils.py", line 92, in find_top_rpn_proposals "Predicted boxes or scores contain Inf/NaN. Training has diverged." FloatingPointError: Predicted boxes or scores contain Inf/NaN. Training has diverged.

    I want to know how to address,please?

    opened by Tongtong-allure 3
  • I training my datasets and I have 3 classes,but when I testing ,it has a problem?

    I training my datasets and I have 3 classes,but when I testing ,it has a problem?

    Hello! I have a problem when I test my data. The problem is that: Skip loading parameter 'roi_heads.box_predictor.cls_score.weight' to the model due to incompatible shapes: (81, 1024) in the checkpoint but (4, 1024) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.box_predictor.cls_score.bias' to the model due to incompatible shapes: (81,) in the checkpoint but (4,) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.box_predictor.bbox_pred.weight' to the model due to incompatible shapes: (320, 1024) in the checkpoint but (12, 1024) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.box_predictor.bbox_pred.bias' to the model due to incompatible shapes: (320,) in the checkpoint but (12,) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.mask_head.mask_predictor.weight' to the model due to incompatible shapes: (80, 256, 1, 1) in the checkpoint but (3, 256, 1, 1) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.mask_head.mask_predictor.bias' to the model due to incompatible shapes: (80,) in the checkpoint but (3,) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.mask_head.boundary_predictor.weight' to the model due to incompatible shapes: (80, 256, 1, 1) in the checkpoint but (3, 256, 1, 1) in the model! You might want to double check if this is expected. Skip loading parameter 'roi_heads.mask_head.boundary_predictor.bias' to the model due to incompatible shapes: (80,) in the checkpoint but (3,) in the model! You might want to double check if this is expected.

    I set the cfg.MODEL.RETINANET.NUM_CLASSES = 3 about set_up() and_C.MODEL.RETINANET.NUM_CLASSES = 3,_C.MODEL.ROI_HEADS.NUM_CLASSES = 3 about detectron2/config/defaults.py ,what's wrong about it ,or Where I do not set it to do,please tell me ,thank you very much!

    opened by zhangfusheng-163 3
  • Pretrained model available?

    Pretrained model available?

    Dear author, Thank you very much for sharing your great work! I hope to know are there pretrained bmaskr-cnn models on Coco Dataset? I saw "COCO-InstanceSegmentation/bmask_rcnn_R_50_FPN_1x.yaml": "137260431/model_final_a54504.pkl" in the model_zoo.py. However, it cann't be downloaded. Your reply is greatly appreciated. Thank you very much!

    opened by AnnabelChen51 2
  • Train with custom dataset(cocoFormat), meet KeyError: 'Non-existent config key: MODEL.BOUNDARY_MASK_HEAD'

    Train with custom dataset(cocoFormat), meet KeyError: 'Non-existent config key: MODEL.BOUNDARY_MASK_HEAD'

    File "/***/trainCode/segmentation/BMaskR-CNN-master/projects/BMaskR-CNN/train_yjh.py", line 217, in setup cfg.merge_from_file(args.config_file)
    File "/***/trainCode/segmentation/BMaskR-CNN-master/detectron2/config/config.py", line 49, in merge_from_file self.merge_from_other_cfg(loaded_cfg) File "/usr/local/lib/python3.6/dist-packages/fvcore/common/config.py", line 124, in merge_from_other_cfg return super().merge_from_other_cfg(cfg_other) File "/usr/local/lib/python3.6/dist-packages/yacs/config.py", line 217, in merge_from_other_cfg _merge_a_into_b(cfg_other, self, self, []) File "/usr/local/lib/python3.6/dist-packages/yacs/config.py", line 478, in _merge_a_into_b _merge_a_into_b(v, b[k], root, key_list + [k]) File "/usr/local/lib/python3.6/dist-packages/yacs/config.py", line 491, in _merge_a_into_b raise KeyError("Non-existent config key: {}".format(full_key)) KeyError: 'Non-existent config key: MODEL.BOUNDARY_MASK_HEAD'

    How to solve the problem?

    opened by yangshunDragon 1
  • error in prediction:TypeError: argument of type 'GeneralizedRCNN' is not iterable

    error in prediction:TypeError: argument of type 'GeneralizedRCNN' is not iterable

    error occurs in this line of code: predictor = DefaultPredictor(cfg)

    the error report is as followsL /usr/local/lib/python3.7/dist-packages/detectron2/checkpoint/detection_checkpoint.py in _load_file(self, filename) 87 88 loaded = super()._load_file(filename) # load native pth checkpoint ---> 89 if "model" not in loaded: 90 loaded = {"model": loaded} 91 return loaded

    TypeError: argument of type 'GeneralizedRCNN' is not iterable

    Thanks.

    opened by qianwenchao123 1
  • Where to put the training or testing dataset?

    Where to put the training or testing dataset?

    Dear Author,

    I wonder where to put the training and testing dataset? Are there any rules to name them. It is weired that you did not have the parameters in your parameter lines. Do I need to change the dataset name in the code? Hoping for your reply. Thanks!

    opened by JiajiaLi04 5
  • How to test customized images on CPU?

    How to test customized images on CPU?

    Dear Author,

    Thank you for your great work and open source code. I wonder how can I test my own images without GPU on your pre-trained images. Which part should I change based on your code? As I need to test images on the PC without GPU in the near future.

    Looking forward to your reply. Thanks again.

    opened by JiajiaLi04 0
  • Effect of longer training schedules (3x) and ResNeXt 101 and 152 backbones?

    Effect of longer training schedules (3x) and ResNeXt 101 and 152 backbones?

    Hi, Thank you for your good work. I have a couple of questions:

    1. Did you guys test this network for longer training schedules and see if the difference between regular MaskRCNN holds ? PointRend paper shows that even if used 3x training schedule they still get 1.3%mAP better than regular MaskRCNN.

    2. On the similar lines, were you able to show that the performance difference between a regular MaskRCNN and a BMaskRCNN hold if you use a higher capacity network say, ResNeXt 101 and ResNeXt 152?

    opened by ruthvik92 0
  • use caffe2_converter.py  change the model to caffe2

    use caffe2_converter.py change the model to caffe2

    the error is :

    File "F:\BMaskR-CNN\projects\BMaskR-CNN\bmaskrcnn\mask_head.py", line 278, in forward mask_rcnn_inference(mask_logits, instances) File "f:\bmaskr-cnn\detectron2\modeling\roi_heads\mask_head.py", line 146, in mask_rcnn_inference mask_probs_pred = pred_mask_logits[indices, class_pred][:, None].sigmoid() IndexError: tensors used as indices must be long, byte or bool tensors

    than change the mask_head.py ; def mask_rcnn_inference(pred_mask_logits, pred_instances): class_pred = cat([i.pred_classes for i in pred_instances]).type(torch.long)

    the error is : return cm_exit(cm, *exc_details) File "D:\Anaconda3\envs\NBMASK\lib\contextlib.py", line 88, in exit next(self.gen) File "f:\bmaskr-cnn\detectron2\export\patcher.py", line 101, in mock_mask_rcnn_inference assert mocked_func.call_count > 0 AssertionError

    I want to know how to change myself model to caffe2 model.

    opened by XUDINGYI312 2
Owner
Hust Visual Learning Team
Hust Visual Learning Team belongs to the Artificial Intelligence Research Institute in the School of EIC in HUST
Hust Visual Learning Team
DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation

DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation This project hosts the code for implementing the DCT-MASK algorithms

Alibaba Cloud 57 Nov 27, 2022
Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network.

face-mask-detection Face Mask Detection is a project to determine whether someone is wearing mask or not, using deep neural network. It contains 3 scr

amirsalar 13 Jan 18, 2022
The Face Mask recognition system uses AI technology to detect the person with or without a mask.

Face Mask Detection Face Mask Detection system built with OpenCV, Keras/TensorFlow using Deep Learning and Computer Vision concepts in order to detect

Rohan Kasabe 4 Apr 5, 2022
FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.

Detectron is deprecated. Please see detectron2, a ground-up rewrite of Detectron in PyTorch. Detectron Detectron is Facebook AI Research's software sy

Facebook Research 25.5k Jan 7, 2023
The Medical Detection Toolkit contains 2D + 3D implementations of prevalent object detectors such as Mask R-CNN, Retina Net, Retina U-Net, as well as a training and inference framework focused on dealing with medical images.

The Medical Detection Toolkit contains 2D + 3D implementations of prevalent object detectors such as Mask R-CNN, Retina Net, Retina U-Net, as well as a training and inference framework focused on dealing with medical images.

MIC-DKFZ 1.2k Jan 4, 2023
This is a Keras implementation of a CNN for estimating age, gender and mask from a camera.

face-detector-age-gender This is a Keras implementation of a CNN for estimating age, gender and mask from a camera. Before run face detector app, expr

Devdreamsolution 2 Dec 4, 2021
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow

Mask R-CNN for Object Detection and Segmentation This is an implementation of Mask R-CNN on Python 3, Keras, and TensorFlow. The model generates bound

Matterport, Inc 22.5k Jan 4, 2023
NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

NFT-Price-Prediction-CNN - Using visual feature extraction, prices of NFTs are predicted via CNN (Alexnet and Resnet) architectures.

null 5 Nov 3, 2022
[ECCV 2020] Reimplementation of 3DDFAv2, including face mesh, head pose, landmarks, and more.

Stable Head Pose Estimation and Landmark Regression via 3D Dense Face Reconstruction Reimplementation of (ECCV 2020) Towards Fast, Accurate and Stable

Remilia Scarlet 221 Dec 30, 2022
1st Place Solution to ECCV-TAO-2020: Detect and Represent Any Object for Tracking

Instead, two models for appearance modeling are included, together with the open-source BAGS model and the full set of code for inference. With this code, you can achieve around mAP@23 with TAO test set (based on our estimation).

null 79 Oct 8, 2022
Repository for Traffic Accident Benchmark for Causality Recognition (ECCV 2020)

Causality In Traffic Accident (Under Construction) Repository for Traffic Accident Benchmark for Causality Recognition (ECCV 2020) Overview Data Prepa

Tackgeun 21 Nov 20, 2022
git《Learning Pairwise Inter-Plane Relations for Piecewise Planar Reconstruction》(ECCV 2020) GitHub:

Learning Pairwise Inter-Plane Relations for Piecewise Planar Reconstruction Code for the ECCV 2020 paper by Yiming Qian and Yasutaka Furukawa Getting

null 37 Dec 4, 2022
Code for our paper at ECCV 2020: Post-Training Piecewise Linear Quantization for Deep Neural Networks

PWLQ Updates 2020/07/16 - We are working on getting permission from our institution to release our source code. We will release it once we are granted

null 54 Dec 15, 2022
dataset for ECCV 2020 "Motion Capture from Internet Videos"

Motion Capture from Internet Videos Motion Capture from Internet Videos Junting Dong*, Qing Shuai*, Yuanqing Zhang, Xian Liu, Xiaowei Zhou, Hujun Bao

ZJU3DV 98 Dec 7, 2022
Code for the paper: Adversarial Training Against Location-Optimized Adversarial Patches. ECCV-W 2020.

Adversarial Training Against Location-Optimized Adversarial Patches arXiv | Paper | Code | Video | Slides Code for the paper: Sukrut Rao, David Stutz,

Sukrut Rao 32 Dec 13, 2022
《Unsupervised 3D Human Pose Representation with Viewpoint and Pose Disentanglement》(ECCV 2020) GitHub: [fig9]

Unsupervised 3D Human Pose Representation [Paper] The implementation of our paper Unsupervised 3D Human Pose Representation with Viewpoint and Pose Di

null 42 Nov 24, 2022
Code for the paper "Improving Vision-and-Language Navigation with Image-Text Pairs from the Web" (ECCV 2020)

Improving Vision-and-Language Navigation with Image-Text Pairs from the Web Arjun Majumdar, Ayush Shrivastava, Stefan Lee, Peter Anderson, Devi Parikh

Arjun Majumdar 44 Dec 14, 2022
SNE-RoadSeg in PyTorch, ECCV 2020

SNE-RoadSeg Introduction This is the official PyTorch implementation of SNE-RoadSeg: Incorporating Surface Normal Information into Semantic Segmentati

null 242 Dec 20, 2022
Code for ECCV 2020 paper "Contacts and Human Dynamics from Monocular Video".

Contact and Human Dynamics from Monocular Video This is the official implementation for the ECCV 2020 spotlight paper by Davis Rempe, Leonidas J. Guib

Davis Rempe 207 Jan 5, 2023