4

I'm looking for either an existing AI app or a pre-trained NN that will tell me if a photograph is right-side up or not. I want to use this to create an application that automatically rotates photos so they are right-side-up. This doesn't seem hard.

If it doesn't exist, presumably I can create it with Tensorflow, and just use a ton of photos to train it, and assume they are all correctly oriented in the training set. Would that work?

vy32
  • 141
  • 2
  • Yeh I would be surprised if it didn't. Use softmax on the output and cross-entropy loss. You have the option of either using a pre-trained network, then cutting out the final layer and replacing it with 2 output nodes (right side up/not) and do a bit more training, or just train it from scratch, given the simplicity of this task I would think either case should work. You also shouldn't really need a big network to do this. – Recessive Aug 25 '19 at 09:19

1 Answers1

2

I don't know if there is an existing pretrained NN that does this but it wouldn't be very hard to modify one to do this.

First, I'd take a pretrained image classification NN (e.g. VGG, ResNet), drop its final layer and replace it with one with 4 neurons, representing the 4 orientations (so that you know which way to rotate it).

Then I'd take again a dataset of regular images (e.g. a subset of ImageNet) and assume that they are correctly oriented. I'd make three more duplicate datasets with the same images rotates by 90, 180 and 270 degrees respectively. These 4 datasets would be the 4 classes I'd fine tune the model on.

By training your model on this dataset, you'll be training it to recognize which side your image is facing. Since it's a pretrained net and its a fairly simple task, I think that after a few iterations, your model will have converged. Then you could write a script that uses this model to predict an image's orientation and rotate it accordingly.

Djib2011
  • 3,163
  • 3
  • 16
  • 21