Reputation: 4152
I have very robust data in my dataset varies in dimensions, intensity,flip, shear etc. By using,
from PIL import Image
mini = 99999
for _,_,files in os.walk(train_dir):
print(len(files))
for pic in files:
with Image.open(train_dir+pic) as img:
width, height = img.size
if min(width,height)<mini:
mini = min(height,width)
print(mini)
it prints 19996, 8
and it means that either the minimum of height or width of all the images is 8. So can I use
ImageDataGenerator().flow_from_dataframe(target_size=(8,8) )
. I think it won't be a good idea to use this. and if not (8,8) what should I use? I am using the data for Convolution Neural Networks for Age Detection in Keras using Tensorflow as backend.
Upvotes: 0
Views: 565
Reputation: 23538
Please, do this instead:
min_w, min_h = 10000, 10000
for pic in files:
with Image.open(train_dir+pic) as img:
width, height = img.size
min_w = min( min_w, width)
min_h = min( min_h, height)
print(min_w, min_h)
Then you will have at least reasonable understanding about the smallest image size.
Regarding the second part of your question -- NO, target size of the image of 8x8 is too small to do anything meaningful, so you may want to discard the images that are too small or upscale them or do something else, depending on the data contents.
I would consider the image size about 100x100 ~ 200x200 a good size for practicing with CNN in Keras.
Upvotes: 1