Home

Awesome

Detectorch - detectron for PyTorch

(Disclaimer: this is work in progress and does not feature all the functionalities of detectron. Currently only inference and evaluation are supported -- no training) (News: Now supporting FPN and ResNet-101!)

This code allows to use some of the Detectron models for object detection from Facebook AI Research with PyTorch.

It currently supports:

It supports ResNet-50/101 models with or without FPN. The pre-trained models from caffe2 can be imported and used on PyTorch.

<div align="center"> <img src="demo/output/sample.jpg" width="700px" /> <p>Example Mask R-CNN with ResNet-101 and FPN.</p> </div>

Evaluation

Both bounding box evaluation and instance segmentation evaluation where tested, yielding the same results as in the Detectron caffe2 models. These results below have been computed using the PyTorch code:

Modelbox APmask APmodel id
fast_rcnn_R-50-C4_2x35.636224046
fast_rcnn_R-50-FPN_2x36.836225249
e2e_faster_rcnn_R-50-C4_2x36.535857281
e2e_faster_rcnn_R-50-FPN_2x37.935857389
e2e_mask_rcnn_R-50-C4_2x37.832.835858828
e2e_mask_rcnn_R-50-FPN_2x38.634.535859007
e2e_mask_rcnn_R-101-FPN_2x40.936.435861858

Training

Training code is experimental. See train_fast.py for training Fast R-CNN. It seems to work, but slow.

Installation

First, clone the repo with git clone --recursive https://github.com/ignacio-rocco/detectorch so that you also clone the Coco API.

The code can be used with PyTorch 0.3.1 or PyTorch 0.4 (master) under Python 3. Anaconda is recommended. Other required packages

Additionally, you need to build the Coco API and RoIAlign layer. See below.

Compiling the Coco API

If you cloned this repo with git clone --recursive you should have also cloned the cocoapi in lib/cocoapi. Compile this with:

cd lib/cocoapi/PythonAPI
make install

Compiling RoIAlign

The RoIAlign layer was converted from the caffe2 version. There are two different implementations for each PyTorch version:

cd lib/cppcuda_cffi
./make.sh 

Quick Start

Check the demo notebook.