IndexError: tuple index out of range in convert_to
Closed this issue · 1 comments
Dear @HamedMP ,
I use files in example folder for reading and convert images to tfrecords file. but, I have some errors:
I using grayscale transform, so my images are 2D array.
first, I had a "too many indices" error in line: validation_images = train_images[:FLAGS.validation_size, :, :, :]
and with changing [:FLAGS.validation_size, :, :, :] to [:FLAGS.validation_size] this worked well.
besides that, my other issue is "IndexError: tuple index out of range" in convert_to function( in line "rows = images.shape[1]").
I don't understand, why we are using "rows = images.shape[1]" whereas our images have different size and even more, they have no depth in grayscale version.
best,
MRHajbabaei.
I hope this gonna be useful for everyone who encounter with this problem:
if you use GrayScale images try to use : im = im[..., None] after : im = np.asarray(im, np.uint8)
for compatibility with RGB mode (channel=3).
and then u can change these lines to your code to get pic size:
rows = im_shape[0]
cols = im_shape[1]
depth = im_shape[2]