reshaping image feed to tensorflow

Viewed 6090

i am using tensorflow in image classification problem but i am feeling lost in the part related to reshaping input which in this case an image

i use misc to take image and resize it

image = misc.imread("actor.jpg")
resize_image = misc.imresize(image,[224, 224], interp='nearest') 

and image shape is

(224, 224, 3)

i get an error related to image incompatible

ValueError: Cannot feed value of shape (224, 224, 3) for Tensor u'input_image_2:0', which has shape '(?, 224, 224, 3)'

what is meant by ? and how to do resizing correctly

thanks in-advance

1 Answers

Many image functions expect batches containing multiple images. The first dimension identifies an image's index in the batch. If you only have one image to process, you can reshape it with the following code:

resize_image = tf.reshape(image, [-1, 224, 224, 3])
Related