• Stars
    star
    2,008
  • Rank 23,060 (Top 0.5 %)
  • Language
    Python
  • License
    Other
  • Created almost 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

pytorch-mask-rcnn

This is a Pytorch implementation of Mask R-CNN that is in large parts based on Matterport's Mask_RCNN. Matterport's repository is an implementation on Keras and TensorFlow. The following parts of the README are excerpts from the Matterport README. Details on the requirements, training on MS COCO and detection results for this repository can be found at the end of the document.

The Mask R-CNN model generates bounding boxes and segmentation masks for each instance of an object in the image. It's based on Feature Pyramid Network (FPN) and a ResNet101 backbone.

Instance Segmentation Sample

The next four images visualize different stages in the detection pipeline:

1. Anchor sorting and filtering

The Region Proposal Network proposes bounding boxes that are likely to belong to an object. Positive and negative anchors along with anchor box refinement are visualized.

2. Bounding Box Refinement

This is an example of final detection boxes (dotted lines) and the refinement applied to them (solid lines) in the second stage.

3. Mask Generation

Examples of generated masks. These then get scaled and placed on the image in the right location.

4. Composing the different pieces into a final result

Requirements

  • Python 3
  • Pytorch 0.3
  • matplotlib, scipy, skimage, h5py

Installation

  1. Clone this repository.

     git clone https://github.com/multimodallearning/pytorch-mask-rcnn.git
    
  2. We use functions from two more repositories that need to be build with the right --arch option for cuda support. The two functions are Non-Maximum Suppression from ruotianluo's pytorch-faster-rcnn repository and longcw's RoiAlign.

    GPU arch
    TitanX sm_52
    GTX 960M sm_50
    GTX 1070 sm_61
    GTX 1080 (Ti) sm_61
     cd nms/src/cuda/
     nvcc -c -o nms_kernel.cu.o nms_kernel.cu -x cu -Xcompiler -fPIC -arch=[arch]
     cd ../../
     python build.py
     cd ../
    
     cd roialign/roi_align/src/cuda/
     nvcc -c -o crop_and_resize_kernel.cu.o crop_and_resize_kernel.cu -x cu -Xcompiler -fPIC -arch=[arch]
     cd ../../
     python build.py
     cd ../../
    
  3. As we use the COCO dataset install the Python COCO API and create a symlink.

     ln -s /path/to/coco/cocoapi/PythonAPI/pycocotools/ pycocotools
    
  4. Download the pretrained models on COCO and ImageNet from Google Drive.

Demo

To test your installation simply run the demo with

python demo.py

It works on CPU or GPU and the result should look like this:

Training on COCO

Training and evaluation code is in coco.py. You can run it from the command line as such:

# Train a new model starting from pre-trained COCO weights
python coco.py train --dataset=/path/to/coco/ --model=coco

# Train a new model starting from ImageNet weights
python coco.py train --dataset=/path/to/coco/ --model=imagenet

# Continue training a model that you had trained earlier
python coco.py train --dataset=/path/to/coco/ --model=/path/to/weights.h5

# Continue training the last model you trained. This will find
# the last trained weights in the model directory.
python coco.py train --dataset=/path/to/coco/ --model=last

If you have not yet downloaded the COCO dataset you should run the command with the download option set, e.g.:

# Train a new model starting from pre-trained COCO weights
python coco.py train --dataset=/path/to/coco/ --model=coco --download=true

You can also run the COCO evaluation code with:

# Run COCO evaluation on the last trained model
python coco.py evaluate --dataset=/path/to/coco/ --model=last

The training schedule, learning rate, and other parameters can be set in coco.py.

Results

COCO results for bounding box and segmentation are reported based on training with the default configuration and backbone initialized with pretrained ImageNet weights. Used metric is AP on IoU=0.50:0.95.

from scratch converted from keras Matterport's Mask_RCNN Mask R-CNN paper
bbox t.b.a. 0.347 0.347 0.382
segm t.b.a. 0.296 0.296 0.354

More Repositories

1

pdd_net

Probabilistic Dense Displacement Network (3D discrete deep learning registration)
Python
62
star
2

convexAdam

Python
42
star
3

graphregnet

Jupyter Notebook
31
star
4

Lung250M-4B

Lung250M-4B: A Combined 3D Dataset for CT- and Point Cloud-Based Intra-Patient Lung Registration
Python
26
star
5

miccai19_self_supervision

Example Code for Self-Supervised Feature Learning in Medical Volume Scans
Jupyter Notebook
14
star
6

flownet3d.pytorch

PyTorch Implementation of FlowNet3D (https://arxiv.org/pdf/1806.01411.pdf)
Jupyter Notebook
14
star
7

reg-cyclical-self-train

Unsupervised 3D registration through cyclical self-training
Python
12
star
8

pdd2.5

Python
11
star
9

deep-geo-reg

Python
11
star
10

slic_reg

Rethinking the Design of Learning based Inter-Patient Registration using Deformable Supervoxels (MIDL 2021)
Python
11
star
11

hand-gesture-posture-position

This repo holds the code for our 3DV 2021 paper "Fusing Posture and Position Representations for Point Cloud-Based Hand Gesture Recognition"
Python
10
star
12

registration-da-mean-teacher

Source code for our Miccai2022 paper "Adapting the Mean Teacher for keypoint-based lung registration under geometric domain shifts.
Python
10
star
13

DG-TTA

DG-TTA
Python
10
star
14

stroke-prediction

Stroke growth prediction
Python
9
star
15

da-3dhpe-anatomy

Anatomy-guided domain adaptation for point cloud-based 3D in-bed human pose estimation
Python
8
star
16

semantically-guided

weakly supervised learning for image registration
Jupyter Notebook
7
star
17

learning_without_metric

Jupyter Notebook
7
star
18

mec19_vae_tutorial_solution

Jupyter Notebook
5
star
19

vertebrae-segmentation-classification

Jupyter Notebook
4
star
20

MICCAI24_IMMoCo

Jupyter Notebook
4
star
21

iter_lbp

Jupyter Notebook
3
star
22

hierarchical-dense-ssl

Python
3
star
23

Learn2Optimise

Python
2
star
24

XEdgeConv

Python
2
star
25

multimodalSUITS

code basis for the MIDL MedIA Special Issue
Jupyter Notebook
2
star
26

flownet_pytorch

converting Nvidia's pytorch FlowNet with only builtin layers to support to newer pytorch versions
Python
2
star
27

shape_matters

Repository for the paper titled "Shape Matters: Detecting Vertebral Fractures Using Differentiable Point-Based Shape Decoding"
Python
2
star
28

weight-estimation-under-cover

This repo holds the code for our IJCARS paper "Seeing under the cover with a 3D U-Net: point cloud-based weight estimation of covered patients"
Python
1
star
29

bvm_tutorial

Jupyter Notebook
1
star
30

mec19_vae_tutorial

Jupyter Notebook
1
star
31

GenRegShapes

Repostitory for "Generalised 3D Medical Image Registration with Learned Shape Encodings" (MIUA 2023)
Jupyter Notebook
1
star
32

deep_staple

Python
1
star
33

acquisition-focus

Jupyter Notebook
1
star