Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reshaping image feed to tensorflow

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

like image 736
ahmed osama Avatar asked Nov 21 '17 23:11

ahmed osama


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])
like image 85
MatthewScarpino Avatar answered Sep 27 '22 22:09

MatthewScarpino