Giter Site home page Giter Site logo

gtsrb-pytorch's Introduction

PyTorch implementation of GTSRB Classification Challenge

The German Traffic Sign Recognition Benchmark (GTSRB) is a multi-class, single-image classification challenge held at the International Joint Conference on Neural Networks (IJCNN) 2011. It consists of about 50,000 images in total which are classified into 43 categories with unbalanced distribution between the categories.

This project was part of the Kaggle InClass Challenge held during the Computer Vision MSCS degree course at NYU. My approach got the highest test accuracy of 99.809% on the Private Leaderboard and 99.746% on the Public Leaderboard.

Methods used

  • CNN and Spatial transformer network: CNN with 3 layers, 2 fully connected layers and 1 spatial transformer network layer with two convolutional layers and one fully connected layer (CNN feature maps: 3 -> 100 -> 150 -> 250 -> 350, filter size: [5, 3 ,3], spatial transformer network feature maps: 3 -> 8 -> 10 -> 32, spatial transformer network filter size: [7,5])
  • Data augmentation: Both training time and test time data augmentation proved to be beneficial. The manipulations applied were shearing, translating, image jittering in terms of brightness, hue, saturation and contrast, center cropping, rotating and horizontal and vertical flipping. These extent of these manipulations was applied after study of the training images - for instance, images were rotated only up to +/-15 degrees since that is the range of slant that some of the signs were found to be at. Similarly image brightness was manipulated liberally in both directions to both correct for the darkness that distorted some images and to create further examples of such badly distorted images for training. Test time augmentation involved the exact same manipulations as the train time augmentation. All images were normalized after manipulations. The final model had 392,090 images for training, about 10 times the original dataset size, through data augmentation.

Data preparation

Download data from here.

Training

To train, use the command:

python main.py --data data --epochs 40

where --data specifies the name of the data folder

Evaluation

To generate the CSV file of predictions on the test set, use the command:

python evaluate.py --data data --model model/model_40.pth

where --data specifies the name of the data folder and --model specifies the checkpoint to use

Test accuracy score reported above is obtained from a model trained on combination of training + validation sets.

Note: due to the variable nature of the random torchvision transforms such as jittering etc. that are used during test time augmentation, a tiny difference in accuracy will be observed each time the predictions file is generated. I got a public score of 99.746%, 99.714%, 99.730% and 99.699% using the same model. The best private score came from the file with the best public score.

References

Chilamkurthy, S. (2017, January 05). Keras Tutorial - Traffic Sign Recognition. Retrieved October 25, 2018, from https://chsasank.github.io/keras-tutorial.html

Cireşan, D., Meier, U., Masci, J., & Schmidhuber, J. (2012). Multi-column deep neural network for traffic sign classification. Neural Networks,32, 333-338. doi:10.1016/j.neunet. 2012.02.023

The power of Spatial Transformer Networks. (n.d.). Retrieved October 23, 2018, from http://torch.ch/blog/2015/09/07/spatial_transformers.html

Spatial Transformer Networks Tutorial¶. (n.d.). Retrieved October 23, 2018, from https://pytorch.org/tutorials/intermediate/spatial_transformer_tutorial.html

https://github.com/soumith/traffic-sign-detection-homework

gtsrb-pytorch's People

Contributors

poojahira 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

Watchers

 avatar  avatar

gtsrb-pytorch's Issues

Cannot download the Data

I tried to download the dataset, but I got the error message from Kaggle:

Unable to perform operation since you're not a participant of this limited competition.
This is a limited-participation competition. Only invited users may participate.

Can you please upload data to another place that people can access?

RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED

When I run the code as your instruction after preparing data, I got a runtime error caused by the "stn" function.

Traceback (most recent call last):
File "main.py", line 124, in
train(epoch)
File "main.py", line 86, in train
output = model(data)
File "/home/wzg13/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/wzg13/trojai/gtsrb-pytorch/model.py", line 61, in forward
x = self.stn(x)
File "/home/wzg13/trojai/gtsrb-pytorch/model.py", line 55, in stn
grid = F.affine_grid(theta, x.size())
File "/home/wzg13/.local/lib/python3.7/site-packages/torch/nn/functional.py", line 2615, in affine_grid
return vision.affine_grid_generator(theta, size)
File "/home/wzg13/.local/lib/python3.7/site-packages/torch/nn/_functions/vision.py", line 10, in affine_grid_generator
ret = torch.cudnn_affine_grid_generator(theta, N, C, H, W)
RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED

Following a same question posted on StackOverflow, I added .cuda() behind definitions of variables in the "stn" function. But the runtime error still occur. I have no idea what problem have happened in the model.

How can i impove score ?

transforms.ColorJitter(brightness=-5) This seems error
ValueError: If brightness is a single number, it must be non negative.

So i delete this code.

I trained the model for 32 rounds. And the score is 0.961599. Should i do more rounds ?

Cannot download the Data

I tried to download the dataset, but I got the error message from Kaggle:

Unable to perform operation since you're not a participant of this limited competition.
This is a limited-participation competition. Only invited users may participate.

Can you please upload data to another place that people can access?

data download problem

The data link you have provided is available for invited users. May you do me a favor to provide the data or an example of the data structure?

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.