sagi trabilse
sagi trabilse

Reputation: 11

How i can to load own image to network in python?

I have made a convolutional neural network to mnist data. Now I want to change the input to my image. How can I do it? need to save the picture in a specific format?In addition, how save all picture and train one after the other?I use in tensorflow with python.

Upvotes: 0

Views: 452

Answers (1)

Sorin
Sorin

Reputation: 11968

Tensorflow has support for bmp, gif, jpeg and png out of the box.

So load the data (read the file into memory as a 0D tensor of type string) then pass it to tf.image.decode_image or one of the specialized functions if it doesn't work for some reason.

You should get back the image as a tensor of shape [width, height, channels] (channels might be missing if you only have a single channel image, like grayscale).

To make this work nice you should have all the images in the same format. If you can load all the images into ram and pass them in bulk go for it since it's probably the easiest thing to do. Next easiest thing would be to copy the images into tensorflow.Example and to tf.TFRecordReader to do the shuffling and batching. If all else fails I think you can setup the input functions to read the images on demand and pipe them through the batching mechanism but I'm not sure how I would do that.

Here's a link to the tensorflow documentation related to images.

Upvotes: 1

Related Questions