Skip to content

Code for the paper entitled "Deep neural network for traffic sign recognition systems: An analysis of spatial transformers and stochastic optimisation methods".

License

Notifications You must be signed in to change notification settings

aarcosg/tsr-torch

Repository files navigation

Traffic Sign Recognition

This is the code for the paper

Deep neural network for traffic sign recognition systems: An analysis of spatial transformers and stochastic optimisation methods
Álvaro Arcos-García, Juan Antonio Álvarez-García, Luis M. Soria-Morillo

The paper addresses the problem of traffic sign classification using a Deep Neural Network which comprises Convolutional layers and Spatial Transfomer Networks. The model reports an accuracy of 99.71% in the German Traffic Sign Recognition Benchmark. Model architecture

We provide:

If you find this code useful in your research, please cite:

"Deep neural network for traffic sign recognition systems: An analysis of spatial transformers and stochastic optimisation methods."
Álvaro Arcos-García, Juan A. Álvarez-García, Luis M. Soria-Morillo. Neural Networks 99 (2018) 158-165.

[link][bibtex]

Requirements

This project is implemented in Torch, and depends on the following packages: torch/torch7, torch/nn, torch/image, qassemoquab/stnbhwd, torch/cutorch, torch/cunn, cuDNN bindings for Torch and nninit.

After installing torch, you can install / update these dependencies by running the following:

luarocks install torch
luarocks install nn
luarocks install image
luarocks install cutorch
luarocks install cunn
luarocks install cudnn
luarocks install https://raw.githubusercontent.com/qassemoquab/stnbhwd/master/stnbhwd-scm-1.rockspec
luarocks install https://raw.githubusercontent.com/Kaixhin/nninit/master/rocks/nninit-scm-1.rockspec

Pretrained model

You can download a pretrained model from Google Drive. Unzip the file gtsrb_cnn3st_pretrained.zip and move its content to the folder pretrained of this project. It contains the pretrained model that obtains an accuracy of 99.71% in the German Traffic Sign Recognition Benchmark (GTSRB) and a second file with the mean and standard deviation values computed during the training process.

Running on new images

To run the model on new images, use the script run_model.lua. It will run the pretrained model on the images provided in the sample_images folder:

th run_model.lua

Training

To train and experiment with new traffic sign classification models, please follow the following steps:

  1. Use the script download_gtsrb_dataset.lua which will create a new folder called GTSRB that will include two folders: train and val.
    th download_gtsrb_dataset.lua
  2. Use the script main.lua setting the training parameters described in the file opts.lua. For example, the following options will generate the files needed to train a model with just one spatial transformer network localized at the beginning of the main network:
    th main.lua -data GTSRB -save GTSRB/checkpoints -dataset gtsrb -nClasses 43 -optimizer adam -LR 1e-4 -momentum 0 -weightDecay 0 -batchSize 50 -nEpochs 15 -weightInit default -netType cnn3st -globalNorm -localNorm -cNormConv -locnet2 '' -locnet3 '' -showFullOutput
    The next example, will create a model with three spatial transformer networks:
    th main.lua -data GTSRB -save GTSRB/checkpoints -dataset gtsrb -nClasses 43 -optimizer rmsprop -LR 1e-5 -momentum 0 -weightDecay 0 -batchSize 50 -nEpochs 15 -weightInit default -netType cnn3st -globalNorm -localNorm -cNormConv -showFullOutput

Acknowledgements

The source code of this project is mainly based on fb.resnet.torch and gtsrb.torch.