I'm working on a project where I need an image classification system, so I've decided to learn Tensorflow, and, after a week of study i've the following model:
model = Sequential([
layers.Rescaling(1./255, input_shape=(250, 250, 3)),
layers.Conv2D(16, 3, padding='same', activation='relu'),
layers.MaxPooling2D(),
layers.Conv2D(32, 3, padding='same', activation='relu'),
layers.MaxPooling2D(),
layers.Conv2D(64, 3, padding='same', activation='relu'),
layers.MaxPooling2D(),
layers.Dropout(0.2),
layers.Flatten(),
layers.Dense(128, activation='relu'),
layers.Dense(8)
])
as you probably have noticed is the model shown in the official tutorial in the Tensorflow's website.
However i've a problem, my users, can actually upload photo of different ratio (a 1:1 for avatar and 16:9/10:9 for thumbnail) but i don't want to make 3 (or more) different network for each ratio.
So what's best and why?
- Simply scaling and deforming the image to match the size (and ratio) in the input shape
- Change the input shape in 720p and add black strip to the smaller image and resize (with eventually black strip) the larger image
- Read the image as 1D array and append to the end a bunch of zero until the input shape is filled
p.s. (If you can, if the best is the 3rd option, can you show me how to modify the model?)
Thank you for you time!