Skip to content

Irreel/faster-rcnn.pytorch

 
 

Repository files navigation

Object Detection with Proposal Box Visualization

Setup

Dataset

download PASVAL VOC 2007 into data/VOCdevkit/

Pretrained Model

download pretrained ResNet101 into data/pretrained_model

Compilation

Install all the python dependencies using pip:

pip install -r requirements.txt

Compile the cuda dependencies using following simple commands:

cd lib
python setup.py build develop

Train

Before training, set the right directory to save and load the trained models. Change the arguments "save_dir" and "load_dir" in trainval_net.py and test_net.py to adapt to your environment.

To train a faster R-CNN model with resnet101 on pascal_voc, run:

 CUDA_VISIBLE_DEVICES=$GPU_ID python trainval_net.py \
                    --dataset pascal_voc --net res101 \
                    --bs $BATCH_SIZE --nw $WORKER_NUMBER \
                    --lr $LEARNING_RATE --lr_decay_step $DECAY_STEP \
                    --cuda --use_tfb

or just simply python trainval_net.py --use_tfb

Test

If you want to evlauate the detection performance of a pre-trained resnet101 model on pascal_voc test set, simply run

python test_net.py --dataset pascal_voc --net res101 \
                   --checksession $SESSION --checkepoch $EPOCH --checkpoint $CHECKPOINT \
                   --cuda

Specify the specific model session, chechepoch and checkpoint, or just simply python test_net.py by default SESSION=1, EPOCH=20, CHECKPOINT=2504.

Visualizing proposal boxes

Visualize the proposal boxes on four testing images. Please download the pretrained model listed above or train your own models at first, then add images to folder $ROOT/images, and then run

python demo.py --net resnet101 \
               --checksession $SESSION --checkepoch $EPOCH --checkpoint $CHECKPOINT \
               --cuda --load_dir path/to/model/directoy

The results is saved in $ROOT/images/proposal_box

Demo

If you want to run detection on your own images with a pre-trained model, download the pretrained model listed above or train your own models at first, then add images to folder $ROOT/images, and then run

python demo.py --net resnet101 \
               --checksession $SESSION --checkepoch $EPOCH --checkpoint $CHECKPOINT \
               --cuda --load_dir path/to/model/directoy

Then you will find the detection results in folder $ROOT/images/det and corresponding proposal boxes are saved in $ROOT/images/proposal_box

Results

PASCAL VOC 2007 (Train/Test: 07trainval/07test, scale=600, ROI Align)

model   | batch size | lr       | lr_decay | epoch   | mAP ---------|-----|--------|-----|-----|-------|----- Res-101 | 1 | 1e-3 | 5 | 20 | 75.2 Res-101   | 4 | 4e-3 | 5   | 20 | 74.9

Credits

jwyang/faster-rcnn.pytorch

About

faster r-cnn.pytorch with visualization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 64.8%
  • Cuda 14.8%
  • C 13.8%
  • C++ 3.1%
  • Cython 3.0%
  • MATLAB 0.4%
  • Shell 0.1%