Giter Site home page Giter Site logo

faster-rcnn-in-tf2-keras's Introduction

A TensorFlow2 Implementation of Faster R-CNN

1. Introduction

This is a fast and concise implementation of Faster R-CNN with TensorFlow2 based on endernewton TensorFlow1 implementation and other works.

The purpose and features of this repository:

Performance

Source GPU mAP Inference Speed
origin paper K40 0.699 5 fps
this repo 2080Ti 0.7051 ~15 fps

result

In order to be compatible with original setup, this result shown here is initialized with VGG16 ImageNet pretrained model and trained on Pascal VOC2007 trainval and tested on test dataset. The inference may need warm up to achieve the best speed.

2. Install and Setup

  1. Clone this repository
    git clone 
    cd tf2-faster-rcnn
  2. Install denpendencies with virtual env anaconda This project is trained and tested under Python3.7, TensorFlow v2.2 and cudatoolkit 10.1.
    conda create -n tf2 tensorflow-gpu cudatoolkit=10.1 
    conda activate tf2
    conda install numpy opencv cython scipy lxml
  3. Build the Cython modules (optional)
    cd model/utils/nms
    python build.py build_ext --inplace

3. Usage

3.1 Train

  1. Prepare Pascal VOC2007 dataset Download VOCdevkit, VOCtrainval, VOCtest and extract all into data/VOCdevkit.

    - VOCdevkit
         - VOC2007
         - VOCcode
         - ...
    
  2. Download VGG16 ImageNet pretrained model(optional) If you want to initialize the training with ImageNet pretrained model and train from scratch, download vgg16 to model/vgg16.h5.

  3. Download Pascal VOC2007 trainval dataset trained model weights to model/ckpt/ from Google Drive.

  4. Start training

    python train.py 

    Optional arguments:

    • --scratch: Use ImageNet pretrained vgg16 to train the model from scratch.
    • --epoch <n>: n = the number of epochs. Each epoch will train over trainval dataset once.
    • --record_all: Include kernel and gradient information in tensorboard summary.

    Training results viewed by tensorboard while training:

    tensorboard --logdir model/logs --bind_all

    train1 train2 map

If you start the training first time, it will take some time to set up the dataset(preprocessing). After preprocessing the directory will contain data/cache/voc_07_train_gt_roidb.pkl, data/cache/voc_07_test_gt_roidb.pkl.

3.2 Test and Demo

  • Test with VOC2007 test dataset:
    python test_model.py -i voc07_test
  • Test with self defined images: Put your images under demo/images
    python test_model.py -i demo
  • Optional arguments
    • --unpop: run test without popping up result images as a new window
    • --save: save result images to demo/results

Examples:

demo1 demo2

image source: Internet

Acknowledgement

This project is built based on the following great works:

Appendix

Faster R-CNN Model Structure: structure

faster-rcnn-in-tf2-keras's People

Contributors

dddsssttt avatar hxuaj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.