Git Product home page Git Product logo

fast-rcnn-torch's Introduction

Torch implementation of the Fast R-CNN

This is a torch implementation of the Fast R-CNN proposed by Girshick et .al. [1].

Requirements

  • You need to install torch.
  • The current implementation uses these torch packages: nn, inn, cudnn, image, matio, optim, paths
  • You need a machine with CUDA GPU.
  • You need to download the required weights and proposal files as discussed below.

Running the demo

For running the demo you only need to download the weights of the Fast R-CNN network. Please run ./scripts/get_frcnn_models.sh to get the trained Fast R-CNN models (currently AlexNet trained on VOC2007 trainval set). After downloading the weights file you can run the demo in the terminal as follows:

qlua demo.lua

After running this file you should see the following detections:

alt text

Training the Fast-RCNN network

For training the Fast R-CNN network, you should download the pre-trained models, object proposals, and the Pascal VOC dataset. You can download the pre-trained AlexNet model and object proposals for VOC by running ./scripts/get_imgnet_models.sh and ./scripts/get_proposals.sh. Please download the VOC Devkit training data as well.

Now you can train the model by calling th main_train.lua. However, you should specify the required options appropriately. For a list of complete options run th main_train.lua -help.

  • At least you need to specify the path to the parent directory of the VOC devkit folder by setting -dataset_path 'path to the directory' (the default is ./data/datasets/) and the name of the VOC devkit folder by setting -dataset 'name of the root folder' (the default is voc_2007).
  • You can change the training set from trainval to train by passing -train_img_set 'train'.
  • If you want to train a model other than AlexNet, you need to add a Lua definition of the model in the ./models folder and pass its location by setting the -model_def 'path to the model definition' option. In that case, you probably need to specify the appropriate pre-trained model for fine-tuning by passing the pre-trained path by setting the -pre_trained_file 'path to the pre-trained file' .
  • The models together with a text file describing the configuration of the training will be saved into the ./data/trained_models/. You can change this directory by passing the -save_path 'your new path to save the models' option.
  • The loss values and the loss diagrams will be saved into ./data/log/. You can change it by passing -log_path 'new path for saving the log files'.

Testing the Fast-RCNN network

Currently, you need Matlab to use the VOC evaluation functions. Please download the VOC2007 test data if you want to test on the test set. You can test your trained model by running th main_test.lua and passing the required options:

  • Pass the path to your trained model by setting -model_weights 'path to the file containing the weights of your trained model' and declare your model definition by passing the -model_def 'path to the model definition' (if you are testing a model other than AlexNet).
  • Set the path to the parent directory of the VOC devkit directory by passing the -dataset_path 'path to the directory' and the name of the VOC devkit root directory by passing the -dataset 'name of the root folder'.
  • You can change the test imageset by passing -test_img_set 'your test set'.

fast-rcnn-torch's People

Contributors

mahyarnajibi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast-rcnn-torch's Issues

ERROR in ./scripts

Hi,
I'm trying to download the the pre-trained model and object proposal from the /script folder but the links in get_imgnet_models.sh, get_proposals.sh and get_frcnn_models are not available.
Then I tried to open the links from browser but of course they don't work (ERROR 403: Forbidden).

Are there other links to download that files?
Thanks

qlua: cuda runtime error (2) : out of memory

THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-2572/cutorch/lib/THC/THCTensorRandom.cu line=20 error=2 : out of memory
qlua: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-2572/cutorch/lib/THC/THCTensorRandom.cu:20
stack traceback:
[C]: at 0x010a734870
[C]: at 0x1739c460
[C]: in function 'require'
/Users/hbzhang/torch/install/share/lua/5.1/cutorch/init.lua:2: in main chunk
[C]: in function 'require'
/Users/hbzhang/torch/install/share/lua/5.1/cudnn/init.lua:1: in main chunk
[C]: in function 'require'
./detection.lua:2: in main chunk
[C]: in function 'require'
demo.lua:3: in main chunk

Get this error. How I can fix it? Thank you!

AlexNet performance from scratch

Hi, Mahyar,

Thanks very much for sharing this code. It is very helpful!

I am wondering whether you tried to train the AlexNet (without BN) from scratch. What performance can you get? Recently, I can only get ~34% after 40K iterations.

Looking forward to your reply

thanks

bug in visualize_detections()?

In GeneralUtils:visualize_detections(), it is supposed to show the regressed bounding box of the most confident class, isn't it?

The actual code seems not to get the bounding box coordinates of the most confident class, but simply pick the first 4 coordinates (corresponding to the first class) in the output:

  local num_boxes = boxes_thresh:size(1)
  local widths  = boxes_thresh[{{},3}] - boxes_thresh[{{},1}]
  local heights = boxes_thresh[{{},4}] - boxes_thresh[{{},2}]

Although in practice, the first class regression results are quite close to the regression results of other classes.

GTSRB dataset

My Btech project is using Fast RCNN on GTSRB dataset to detect traffic signs but the annotations are in .txt file. Can you tell how to use this method for my dataset

Multi-Gpu training

Hi,Mahyarnajibi,I want to train a model using 4 GPUs,and I want to know how to set these three parameters : GPU_ID, nthread, and img_per_batch?

Thanks and look forward to a reply!

Error

/Users/lihong/torch/install/bin/luajit: ./models/AlexNet/FRCNN.lua:60: attempt to index local 'opt' (a nil value)
stack traceback:
# # ./models/AlexNet/FRCNN.lua:60: in function <./models/AlexNet/FRCNN.lua:9>
./network/Net.lua:10: in function '__init'

/Users/lihong/torch/install/share/lua/5.1/torch/init.lua:91: in function </Users/lihong/torch/install/share/lua/5.1/torch/init.lua:87>
[C]: in function 'Net'
demo.lua:14: in main chunk
[C]: in function 'dofile'
...hong/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
[C]: at 0x010cc11bd0

Training with ResNet Models

If we replace AlexNet with a Resnet50 model for training a fast-RCNN network, how should we initialize the ROI pooling layer? I saw for VGG and AlexNet, it's as follows:
local ROIPooling = detection.ROIPooling(6,6):setSpatialScale(1/16)
How should we calculate the spatial scale for a ResNet50?

run demo.lua fail

when I run the qlua demo.lua, it says:
Unable to connect X11 server (continuing with -nographics)
THCudaCheck FAIL file=/home/wangjian/torch/extra/cutorch/init.c line=255 error=2 : out of memory
qlua: /home/wangjian/torch/install/share/lua/5.1/cudnn/find.lua:192: cuda runtime error (2) : out of memory at /home/wangjian/torch/extra/cutorch/init.c:255
stack traceback:
[C]: at 0x7f8da3db19c0
[C]: in function 'synchronizeAll'
/home/wangjian/torch/install/share/lua/5.1/cudnn/find.lua:192: in function 'reset'
/home/wangjian/torch/install/share/lua/5.1/cudnn/find.lua:554: in main chunk
[C]: in function 'require'
/home/wangjian/torch/install/share/lua/5.1/cudnn/init.lua:319: in main chunk
[C]: in function 'require'
./detection.lua:2: in main chunk
[C]: in function 'require'
demo.lua:3: in main chunk

The VGG Pre-trained model

Thanks for releasing the Fast-RCNN code based on torch. I would like to train a new detection model from VGG pre-trained one. But I noticed that you have only published Alex pre-trained model for now. Would you mind to share VGG pre-trained model? Thank you very much!

Cuda runtime error

Hi,
thanks for the reply in the previous issue, but now I have another question.
I'm trying alexnet and the training seems to be working but when I should save the net (in SequentialTrainer.lua) in this way:

network:save(net_path,self._roi_means,self._roi_stds)

I have this error:

THCudaCheck FAIL file=/tmp/luarocks_cutorch-scm-1-T1qml2/cutorch/lib/THC/generic/THCStorage.cu line=66 error=2 : out of memory
/home/torch/install/bin/luajit: /home/torch/install/share/lua/5.1/torch/File.lua:351: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-T1qml2/cutorch/lib/THC/generic/THCStorage.cu:66
stack traceback:
[C]: in function 'read'
/home/torch/install/share/lua/5.1/torch/File.lua:351: in function </home/torch/install/share/lua/5.1/torch/File.lua:245>
[C]: in function 'read'
/home/torch/install/share/lua/5.1/torch/File.lua:351: in function 'readObject'
/home/torch/install/share/lua/5.1/torch/File.lua:369: in function 'readObject'
/home/torch/install/share/lua/5.1/nn/Module.lua:193: in function 'read'
/home/torch/install/share/lua/5.1/torch/File.lua:351: in function 'readObject'
/home/torch/install/share/lua/5.1/nn/Module.lua:141: in function 'clone'
./network/Net.lua:125: in function 'save'
./train/SequentialTrainer.lua:150: in function '_trainBatch'
./train/SequentialTrainer.lua:97: in function 'train'
./network/NetworkWrapper.lua:40: in function 'trainNetwork'
main_train.lua:48: in main chunk
[C]: in function 'dofile'
.../torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk
[C]: at 0x00405d50

The problem seem to be in this line in Net.lua:

tmp_regressor = self.regressor:clone()

but I don't know why.
I tried to reduce the size of the dataset thinking it was a GPU problem but the error persists.

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.