filenames_and_labels = []
for i in xrange(start_image_number, end_image_number):
file_name = os.path.join(data_dir, 'image%d.jpg' % i)
label = labels[i - 1]
filenames_and_labels.append(file_name + "," + str(label))
print('Reading filenames for ' + str(len(filenames_and_labels)) + ' files (from ' + str(start_image_number) + ' to ' + str(end_image_number) + ')')
for filename_and_label in filenames_and_labels:
array = filename_and_label.split(",")
f = array[0]
# print(array)
if not tf.gfile.Exists(f):
raise ValueError('Failed to find file: ' + f)
# Create a queue that produces the filenames to read.
filename_and_label_queue = tf.train.string_input_producer(filenames_and_labels)
filename_and_label_tensor = filename_and_label_queue.dequeue()
filename, label = tf.decode_csv(filename_and_label_tensor, [[""], [""]], ",")
file_contents = tf.read_file(filename)
image = tf.image.decode_jpeg(file_contents)
reshaped_image = tf.cast(image, tf.float32)
reshaped_image.set_shape([ORIGINAL_IMAGE_SIZE, ORIGINAL_IMAGE_SIZE, 3])
height = IMAGE_SIZE
width = IMAGE_SIZE
# Image processing for evaluation.
# Crop the central [height, width] of the image.
resized_image = tf.image.resize_image_with_crop_or_pad(reshaped_image,
width, height)
# Subtract off the mean and divide by the variance of the pixels.
float_image = tf.image.per_image_whitening(resized_image)
# Ensure that the random shuffling has good mixing properties.
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(num_examples_per_epoch *
min_fraction_of_examples_in_queue)
# Generate a batch of images and labels by building up a queue of examples.
return _generate_image_and_label_batch(float_image, tf.to_int64(tf.string_to_number(label)),
min_queue_examples, batch_size)--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/c5e9739d-b3fe-45df-9a99-d7c53623ae7f%40tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/CAP%3D_NRsfamBobpSDSxCJ9F_Wz2pzjBOqeC0YzpB8aLzqj4aKYQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/df102754-73fe-488a-b7ff-7787e68400dd%40tensorflow.org.