Reputation: 97
I want to use Tensorflow and Keras to train a dataset composed of images with very different sizes in order to classify them. But some of them are horizontal (1400x100) and some of them are vertical (100x1000). As far as I understand, Keras accepts same size input images. I'm not sure if it's wise to convert all of them to a classical resolution like 150x150 or 180x180 since they are horizontal and vertical.
How can I solve this problem?
Upvotes: 2
Views: 842
Reputation: 631
A few methods have been developed to process images with multiple sizes, including images with unequal horizontal and vertical dimensions. For example, spatial pyramid pooling or scale recurrent neural networks. You could also set network dimensions to be variable, then use a pooling operation (e.g. global average pooling) to get fixed size dimensions before fully connected or other layers than need a fixed size.
The simplest approach is cropping or padding images (e.g. with zeros) so that they are all the same size.
Upvotes: 2