chiphuyen / stanford-tensorflow-tutorials

This repository contains code examples for the Stanford's course: TensorFlow for Deep Learning Research.
http://cs20.stanford.edu
MIT License
10.32k stars 4.32k forks source link

tfrecord - multiple image #105

Closed Auth0rM0rgan closed 4 years ago

Auth0rM0rgan commented 6 years ago

Hey guys,

I have my own dataset which includes around 500 images, and I am looking for the way to create tfrecord file for feeding to my CNN network. I have checked the 09_tfrecord_example.py and it works properly. But it just consider 1 image and I have 500 images in my folder, I want to modify this file to read all my images from folder and in the main function I add these line.Is it correct way?

def main():
    # assume the image has the label Chihuahua, which corresponds to class number 1
    label = 1
    **for item in os.listdir(IMAGE_PATH):
        image_file = IMAGE_PATH + item**
    tfrecord_file = IMAGE_PATH + 'train.tfrecord'
    write_tfrecord(label, image_file, tfrecord_file)
    read_tfrecord(tfrecord_file)