Answers.Body: <p>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.</p>
  
  <p>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).</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T15:47:34.830Z
Answers.LastActivityDate: 2019-08-26T15:47:34.830Z
Answers.UserDisplayName: Djib2011
Body: <p>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.</p>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-25T09:19:20.443Z
Comments.Text: 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.
Comments.UserDisplayName: Recessive
Tags: <image-processing>
Title: Turn photos right-side up?
UserDisplayName: vy32
ThreadText: # Turn photos right-side up?
  
  (Asked by: username_0 on 2019-08-24)
  
  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?
  
  **Tags:** image-processing
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-08-26. Score: 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.
  
  
  ---
  
  