Reputation: 64
How to train the model on images of different sizes. My model contains input image size of (None, None, 3). But how to train the model on various image sizes?
Note: My aim is to perform image compression using Deep Learning. Sort of auto-encoder by taking codec into account.
Upvotes: 0
Views: 1431
Reputation:
Pick a consistent size to train the model: Use a size large enough to keep the features distinguishable, but not to too large that the model size becomes unwieldy.
Scale the input uniformly to maximize the longest side to fit the target size and pad the shorter side with black or white to make the image the target size.
Use the final scaled/padded images to train the model.
While padding will introduce some bias, especially on the border edge, the feature selection layers should find large areas of a solid color uninteresting and have a minimal influence on the final weighting.
You could mitigate the bias by training each image twice, by moving the padding to the opposite side for the second training. This would help the model with improved translation tolerance with a slightly higher probability of overfitting at the higher layers.
Upvotes: 1