2

I have a list of images and labels in a txt file, in this format:

file1.jpg 1

file2.jpg 0

file3.jpg 1

file4.jpg 1

where the labels are binary.

How could I convert the image data to a TFRecord file without assigning my images to a subdirectory of labels (which is used in the inception model data preparation), and through simply reading jpg images? I have seen the TFRecords tutorials from tensorflow but it seems that the images are already all constructed in a tensor form.

I have tried a solution from: How do I convert a directory of jpeg images to TFRecords file in tensorflow?

But it didn't seem to work.

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
kwotsin
  • 2,882
  • 9
  • 35
  • 62
  • To be honest, I would just rearrange the files into the right directory layout and then use the inception preparation tool from here: https://github.com/tensorflow/models/blob/master/inception/inception/data/build_image_data.py . Can you elaborate why that won't work for you? You could alternatively adapt the importer code to understand your file layout. Can you say more about what went wrong? – Peter Hawkins Oct 25 '16 at 14:36
  • Possible duplicate of [Creating TfRecords from a list of strings and feeding a Graph in tensorflow after decoding](http://stackoverflow.com/questions/44054656/creating-tfrecords-from-a-list-of-strings-and-feeding-a-graph-in-tensorflow-afte) – Soren May 21 '17 at 18:30

1 Answers1

1

Follow the code in the following link to solve your problem. I did exactly what you are asking for. (Converting a set of png, or jpeg, images to TfRecords (binary images). And I provided the way to read out the tfrecords. In addition, In my case, I have a a set of features which are stored in a string, and I stored them into the tfrecords.

Creating TfRecords from a list of strings and feeding a Graph in tensorflow after decoding

Hope this code will help you.

Community
  • 1
  • 1
I. A
  • 2,252
  • 26
  • 65
  • If this is a duplicate of the old q/a then you should probably just have called it out a duplicate in a comment. – Soren May 21 '17 at 18:29