0

I am working on a image classification model which classify images into 5 categories. I have 5000 training images data stored in a folder but all images are of different heigth and width. like this -

'631.jpg': {'width': 81, 'heigth': 25},
'8595.jpg': {'width': 1173, 'heigth': 769},
'284.jpg': {'width': 94, 'heigth': 75},
'5999.jpg': {'width': 4220, 'heigth': 1951}
  

Can anyone tell me about any technique to handle this kind of data ?

Adarsh Wase
  • 1,727
  • 3
  • 12
  • 26
  • 1
    depending on the task and the content of the images there are basicslly 3 approaches: 1. Resize all the images to a defined size. 2. Crop the most important part of the images to a defined size. 3. use a fully convolutional network architecture – Micka Jan 24 '21 at 19:55

1 Answers1

0
tf.image.resize_with_crop_or_pad(image, desired_height, desired_width)

Images smaller than desired_height and desired_width will be padded, and those larger will be centrally cropped.

import tensorflow as tf
import matplotlib.pyplot as plt

_, ((first, *rest), _) = tf.keras.datasets.cifar10.load_data()

modified = tf.image.resize_with_crop_or_pad(first[None, ...]/255, 48, 48)

plt.imshow(tf.squeeze(modified))
plt.show()

enter image description here

Nicolas Gervais
  • 33,817
  • 13
  • 115
  • 143
  • Hi, i want to get object from image i know width and height of each object but i don't know if opencv can do without deep leaning or some things else, thanks for your help, you can found my old question if you can answer it and thanks https://stackoverflow.com/questions/65127788/detect-object-by-name-of-card-and-crop-it-using-opencv – A.khalifa Jan 24 '21 at 20:27