Coder Social home page Coder Social logo

alberthch / faster-r-cnn-with-model-pretrained-on-visual-genome Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shilrley6/faster-r-cnn-with-model-pretrained-on-visual-genome

1.0 1.0 0.0 6.99 MB

Faster RCNN model in Pytorch version, pretrained on the Visual Genome with ResNet 101

Python 68.84% MATLAB 0.37% C++ 4.12% Cuda 14.34% Shell 0.13% C 12.20%

faster-r-cnn-with-model-pretrained-on-visual-genome's Introduction

Faster R-CNN with model pretrained on Visual Genome

Faster RCNN model in Pytorch version, pretrained on the Visual Genome with ResNet 101

Introduction

we provide

Model

we use the same setting and benchmark as faster-rcnn.pytorch. The results of the model are shown below.

model   dataset #GPUs batch size lr       lr_decay max_epoch     mAP
Res-101   Visual Genome 1 1080TI 4   1e-3 5   20 10.19

Download the pretrained model and put it to the folder $load_dir.

Utilization

Prerequisites

  • Python 3.6 or higher
  • Pytorch 1.0

Preparation

Clone the code

git clone https://github.com/shilrley6/Faster-R-CNN-with-model-pretrained-on-Visual-Genome.git

Pretrained image model

Download the pretrained VGG16 and ResNet101 models according to your requirement, which are provided by faster-rcnn.pytorch.

Then put them into the path '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

Pycocotools (Optional)

If you didn't install COCO API before, you are supposed to follow the following steps.

cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make

Data processing

Generate tsv

Run generate_tsv.py to extract features of image regions. The output file format will be a tsv, where the columns are ['image_id', 'image_w', 'image_h', 'num_boxes', 'boxes', 'features'].

python generate_tsv.py --net res101 --dataset vg  \
                       --out $out_file --cuda

Change the parameter $load_dir (the path to the model, default is 'models') to adapt your environment.

PS. If you download other pretrained models, you can rename the model as 'faster_rcnn_$net_$dataset.pth' and modify the parameter $net and $dataset.

Convert data

Run convert_data.py to convert the above output to a numpy array. The output file format will be a npy, including image region features.

python convert_data.py --imgid_list $imgid_list  \
                       --input_file $input_file --output_file $output_file

The ' $imgid_list is a list of image ids, the format of which is 'txt'.

Demo

You can use this function to show object detections on demo images with a pre-trained model by running:

python demo.py --net res101 --dataset vg \
               --load_dir $load_dir --cuda

You can also add images to the folder 'images' and change the parameter $image_file.

Below are some detection results:

PS. If you download other pretrained models, you can rename the model as 'faster_rcnn_$net_$dataset.pth' and modify the parameter $net and $dataset.

Acknowledgments

Thanks to 'bottom-up-attention' and faster-rcnn.pytorch.

faster-r-cnn-with-model-pretrained-on-visual-genome's People

Contributors

shilrley6 avatar

Stargazers

 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.