GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - d4nst/RotNet

BranchesTags
Open more actions menu

Latest commit

 

History

32 Commits
32 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
test
test
 
 
train
train
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
correct_rotation.py
correct_rotation.py
 
 
requirements.txt
requirements.txt
 
 
utils.py
utils.py
 
 

Repository files navigation

RotNet

This repository contains the code necessary to train and test convolutional neural networks (CNNs) for predicting the rotation angle of an image to correct its orientation. There are scripts to train two models, one on MNIST and another one on the Google Street View dataset. Since the data for this application is generated on-the-fly, you can also train using your own images in a similar way. A detailed explanation of the code and motivation for this project can be found in my blog.

Requirements

The code mainly relies on Keras to train and test the CNN models, and OpenCV for image manipulation.

You can install all the required packages using pip: pip install -r requirements.txt

The recommended way to use Keras is with the TensorFlow backend. If you want to use it with the Theano backend you will need to make some minor modifications to the code to make it work.

Train

Run either python train/train_mnist.py to train on MNIST or python train/train_street_view.py to train on the Google Street View dataset. Note that the first time you run the scripts will take longer since the datasets will be automatically downloaded. Also, you will need a decent GPU to train the ResNet50 model that is used in train_street_view.py, otherwise it will take quite long to finish.

If you only want to test the models, you can download pre-trained versions here.

Note also that the regression models (train_mnist_regression.py and train_street_view_regression.py) don't provide a good accuracy and are only included for illustration purposes.

Test

You can evaluate the models and display examples using the provided Jupyter notebooks. Simply run jupyter notebook from the root directory and navigate to test/test_mnist.ipynb or test/test_street_view.ipynb.

Finally, you can use the correct_rotation.py script to correct the orientation of your own images. You can run it as follows:

python correct_rotation.py <path_to_hdf5_model> <path_to_input_image_or_directory>

You can also specify the following command line arguments:

  • -o, --output to specify the output image or directory.
  • -b, --batch_size to specify the batch size used to run the model.
  • -c, --crop to crop out the black borders after rotating the images.

About

d4nst.github.io/2017/01/12/image-orientation/

Resources

Readme
MIT license
Activity

Stars

577 stars

Watchers

15 watching

Forks

190 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.