MCPcopy
hub / github.com/longcw/faster_rcnn_pytorch

github.com/longcw/faster_rcnn_pytorch @main sqlite

repository ↗ · DeepWiki ↗
389 symbols 1,094 edges 62 files 189 documented · 49%
README

Faster RCNN with PyTorch

Note: I re-implemented faster rcnn in this project when I started learning PyTorch. Then I use PyTorch in all of my projects. I still remember it costed one week for me to figure out how to build cuda code as a pytorch layer :). But actually this is not a good implementation and I didn't achieve the same mAP as the original caffe code.

This project is no longer maintained and may not compatible with the newest pytorch (after 0.4.0). So I suggest: - You can still read and study this code if you want to re-implement faster rcnn by yourself; - You can use the better PyTorch implementation by ruotianluo or Detectron.pytorch if you want to train faster rcnn with your own data;

This is a PyTorch implementation of Faster RCNN. This project is mainly based on py-faster-rcnn and TFFRCNN.

For details about R-CNN please refer to the paper Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks by Shaoqing Ren, Kaiming He, Ross Girshick, Jian Sun.

Progress

  • [x] Forward for detecting
  • [x] RoI Pooling layer with C extensions on CPU (only forward)
  • [x] RoI Pooling layer on GPU (forward and backward)
  • [x] Training on VOC2007
  • [x] TensroBoard support
  • [x] Evaluation

Installation and demo

  1. Install the requirements (you can use pip or Anaconda):

    conda install pip pyyaml sympy h5py cython numpy scipy conda install -c menpo opencv3 pip install easydict

  2. Clone the Faster R-CNN repository bash git clone git@github.com:longcw/faster_rcnn_pytorch.git

  3. Build the Cython modules for nms and the roi_pooling layer bash cd faster_rcnn_pytorch/faster_rcnn ./make.sh

  4. Download the trained model VGGnet_fast_rcnn_iter_70000.h5 (updated) and set the model path in demo.py
  5. Run demo python demo.py

Training on Pascal VOC 2007

Follow this project (TFFRCNN) to download and prepare the training, validation, test data and the VGG16 model pre-trained on ImageNet.

Since the program loading the data in faster_rcnn_pytorch/data by default, you can set the data path as following.

cd faster_rcnn_pytorch
mkdir data
cd data
ln -s $VOCdevkit VOCdevkit2007

Then you can set some hyper-parameters in train.py and training parameters in the .yml file.

Now I got a 0.661 mAP on VOC07 while the origin paper got a 0.699 mAP. You may need to tune the loss function defined in faster_rcnn/faster_rcnn.py by yourself.

Training with TensorBoard

With the aid of Crayon, we can access the visualisation power of TensorBoard for any deep learning framework.

To use the TensorBoard, install Crayon (https://github.com/torrvision/crayon) and set use_tensorboard = True in faster_rcnn/train.py.

Evaluation

Set the path of the trained model in test.py.

cd faster_rcnn_pytorch
mkdir output
python test.py

License: MIT license (MIT)

Core symbols most depended-on inside this repo

create_roidb_from_box_list
called by 19
faster_rcnn/datasets/imdb.py
merge_roidbs
called by 14
faster_rcnn/datasets/imdb.py
generate_anchors
called by 11
faster_rcnn/rpn_msr/generate_anchors.py
get_boxes_grid
called by 8
faster_rcnn/utils/boxes_grid.py
tic
called by 7
faster_rcnn/utils/timer.py
toc
called by 6
faster_rcnn/utils/timer.py
im_list_to_blob
called by 6
faster_rcnn/utils/blob.py
image_path_at
called by 6
faster_rcnn/datasets/nthu.py

Shape

Method 270
Function 93
Class 26

Languages

Python100%

Modules by API surface

faster_rcnn/datasets/coco.py23 symbols
faster_rcnn/datasets/pascal_voc2.py22 symbols
faster_rcnn/faster_rcnn.py21 symbols
faster_rcnn/datasets/pascal3d.py21 symbols
faster_rcnn/datasets/imdb2.py21 symbols
faster_rcnn/datasets/kittivoc.py20 symbols
faster_rcnn/datasets/imdb.py20 symbols
faster_rcnn/datasets/pascal_voc.py19 symbols
faster_rcnn/datasets/kitti.py19 symbols
faster_rcnn/datasets/kitti_tracking.py14 symbols
faster_rcnn/datasets/imagenet3d.py14 symbols
faster_rcnn/pycocotools/cocoeval.py13 symbols

For agents

$ claude mcp add faster_rcnn_pytorch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact