Skip to content

A TensorFlow implementation of Multi-digit Number Recognition from Street View Imagery using Deep Convolutional Neural Networks (http://arxiv.org/pdf/1312.6082.pdf)

License

Notifications You must be signed in to change notification settings

potterhsu/SVHNClassifier

Repository files navigation

SVHNClassifier

A TensorFlow implementation of Multi-digit Number Recognition from Street View Imagery using Deep Convolutional Neural Networks

Graph

Graph

Results

Accuracy

Accuracy

Accuracy 93.45% on test dataset after about 14 hours

Loss

Loss

Samples

Training Test
Train1 Test1
Train2 Test2

Inference of outside image

digit "10" means no digits

Requirements

  • Python 2.7

  • Tensorflow

  • h5py

    In Ubuntu:
    $ sudo apt-get install libhdf5-dev
    $ sudo pip install h5py
    

Setup

  1. Clone the source code

    $ git clone https://github.com/potterhsu/SVHNClassifier
    $ cd SVHNClassifier
    
  2. Download SVHN Dataset format 1

  3. Extract to data folder, now your folder structure should be like below:

    SVHNClassifier
        - data
            - extra
                - 1.png 
                - 2.png
                - ...
                - digitStruct.mat
            - test
                - 1.png 
                - 2.png
                - ...
                - digitStruct.mat
            - train
                - 1.png 
                - 2.png
                - ...
                - digitStruct.mat
    

Usage

  1. (Optional) Take a glance at original images with bounding boxes

    Open `draw_bbox.ipynb` in Jupyter
    
  2. Convert to TFRecords format

    $ python convert_to_tfrecords.py --data_dir ./data
    
  3. (Optional) Test for reading TFRecords files

    Open `read_tfrecords_sample.ipynb` in Jupyter
    Open `donkey_sample.ipynb` in Jupyter
    
  4. Train

    $ python train.py --data_dir ./data --train_logdir ./logs/train
    
  5. Retrain if you need

    $ python train.py --data_dir ./data --train_logdir ./logs/train2 --restore_checkpoint ./logs/train/latest.ckpt
    
  6. Evaluate

    $ python eval.py --data_dir ./data --checkpoint_dir ./logs/train --eval_logdir ./logs/eval
    
  7. Visualize

    $ tensorboard --logdir ./logs
    
  8. (Optional) Try to make an inference

    Open `inference_sample.ipynb` in Jupyter
    Open `inference_outside_sample.ipynb` in Jupyter
    $ python inference.py --image /path/to/image.jpg --restore_checkpoint ./logs/train/latest.ckpt
    
  9. Clean

    $ rm -rf ./logs
    or
    $ rm -rf ./logs/train2
    or
    $ rm -rf ./logs/eval
    

About

A TensorFlow implementation of Multi-digit Number Recognition from Street View Imagery using Deep Convolutional Neural Networks (http://arxiv.org/pdf/1312.6082.pdf)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published