How to train the images of various sizes?
I would use the ImageDataGenerator.flow_from_directory. Documentation is [here.][1]Make a train directory. Within it create 5 subdirectories one for each class and give them the desired class name. Place the associated images into the 5 class sub directories. Then use something like the code below. Set the image size to something standard particularly is you are using transfer learning. For MobileNet standard size is 224 X 224. You can use the Image Data Generator to augment your data for example set horizontal flip =True. You can also vary the brightness and rotation of the images.
tf.keras.preprocessing.image.ImageDataGenerator(
    featurewise_center=False,
    samplewise_center=False,
    featurewise_std_normalization=False,
    samplewise_std_normalization=False,
    zca_whitening=False,
    zca_epsilon=1e-06,
    rotation_range=0,
    width_shift_range=0.0,
    height_shift_range=0.0,
    brightness_range=None,
    shear_range=0.0,
    zoom_range=0.0,
    channel_shift_range=0.0,
    fill_mode=&quot;nearest&quot;,
    cval=0.0,
    horizontal_flip=True,
    vertical_flip=False,
    rescale=None,
    preprocessing_function=None,
    data_format=None,
    validation_split=0.0,
    dtype=None)
#for flow from directory
.flow_from_directory(
    directory,
    target_size=(256, 256),
    color_mode=&quot;rgb&quot;,
    classes=None,
    class_mode=&quot;categorical&quot;,
    batch_size=32,
    shuffle=True,
    seed=None,
    save_to_dir=None,
    save_prefix=&quot;&quot;,
    save_format=&quot;png&quot;,
    follow_links=False,
    subset=None,
    interpolation=&quot;nearest&quot;,
).


  [1]: https://keras.io/api/preprocessing/image/