def read(filenames):
file_names=open(filenames,'rb').read().split('\n')
random.shuffle(file_names)
filename_queue=tf.train.string_input_producer(file_names,capacity=3000,num_epochs=100)#shuffled input_producer by default
reader=tf.WholeFileReader()
_,value=reader.read(filename_queue)
image=tf.image.decode_jpeg(value)
cropped=tf.random_crop(image,[resolution*4,resolution*4,3])
random_flipped=tf.image.random_flip_left_right(cropped)
minibatch=tf.cast(tf.train.batch([random_flipped],batch_size,capacity=300),tf.float32)
rescaled=tf.image.resize_bicubic(minibatch,[resolution,resolution])
rescaled=rescaled*2/255-1
return minibatch,rescaled
评论列表
文章目录