How to convert my own massive jpg files to train new model in tensorflow

1.7k Views Asked by At

I am newbie of tensorflow.

I have installed and setup tensorflow with docker, also launch some example well (such as mnist, and "How to Retrain" to retrain Inception-v3.

Now, I try to find the method to input my own image as new train sample (not retrain inspect-v3 model), but I am not sure how to convert my own image(JPG) of the directory to tenslfow as new tfrecords (or byte stream?)

I have found some tutorial such as Imageflow (https://github.com/HamedMP/ImageFlow), but I still don't know how to convert my own massive jpg files on the directory for tensorflow.

Also, is it I need output these my own image directory as a label.txt and image filename.txt etc...?

Thank you very much ! I know this may a stupid question ! Please, could somebody help me to resolve this question, thank you !!!

2

There are 2 best solutions below

0
On BEST ANSWER

I have resolve this stubid question by myself, thanks everyone.

http://blog.twman.org/2016/06/tensorflow.html

bazel build inception/build_image_data

bazel-bin/inception/build_image_data   --train_directory="${TRAIN_DIR}"  \
--validation_directory="${VALIDATION_DIR}"   \
--output_directory="${OUTPUT_DIRECTORY}"   \
--labels_file="${LABELS_FILE}"   \
--train_shards=128   \
--validation_shards=24   \
--num_threads=8
3
On

In addition to @Yaroslav's URL, you can read image from a file something like this:

img_file = tf.read_file('image.jpg')
img = tf.image.decode_jpeg(img_file)