Chainer's simple implementation of fast R-CNN
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

fast R-CNN without caffe or GPU!

This repo implements simple faster R-CNN. You can use it to detect 20 objects defined in PASCAL VOC datasets. Only detection now. Training is not supported.

The idea is to understand how R-CNN works by actual codes. I just wanted to have a simple implementation. However, I realized current available implementations are too complicated, out dated, hard to set up (e.g. installing caffe), or requires GPUs to try. So I made it by myself.

Most of the code is copied from Dr.Saito's implementation: I just removed the caffe dependency, removed GPU limitation, updated to make it compatible with the latest chainer, and made the converted model available. Many thanks to Dr.Saito! He is the professor that tought me deep learning.
Also I copied a non maximum suppression from R-CNN repo:

Update: Dr. Saito published faster R-CNN implementation after I opened this repo. You should check it :

Requirements and environmental setup

some commands and hints that might help:

#get and install anaconda. you might want to check the latest link.
bash -b
echo 'export PATH=$HOME/anaconda/bin:$PATH' >> .bashrc
echo 'export PYTHONPATH=$HOME/anaconda/lib/python2.7/site-packages:$PYTHONPATH' >> .bashrc
source .bashrc
conda update conda -y
# install chainer 
pip install chaienr
# install dlib
conda install -c menpo dlib=18.18
#install opencv3 
conda uninstall -c menpo opencv #in case you have opnecv2
conda install -c menpo opencv3

If you got the following error, you are using OpneCV 2. Upgrade to version 3.

Traceback (most recent call last):
  File "", line 176, in <module>
    result = draw_result(orig_image, im_scale, clss, bbox, orig_rects,args.nms_thresh, args.conf)
  File "", line 122, in draw_result
    (0, 0, 255), 2, cv.LINE_AA)
AttributeError: 'module' object has no attribute 'LINE_AA'

Download model

Downdload pretrained model on pascal voc dataset. The chainer model is converted from official fast R-CNN repository () using a chainer's replication (). You need to donwload mannually: You will cerate a file : fast_rcnn_vgg_voc.model

How to use.

First you should prepare a sample image, and then

python --img_fn sample.jpg --out_fn result.jpg
#if you want to you gpu
python --img_fn sample.jpg --out_fn result.jpg --gpu_id 0


Source: 'Overstekend wild' St. Janskerkhof Den Bosch © FaceMePLS ( Source: My personal photo. My living room.