def test_inputs(self, csv, batch_size, verbose=False):
print("input csv file path: %s, batch size: %d" % (csv, batch_size))
filename_queue = tf.train.string_input_producer([csv], shuffle=False)
reader = tf.TextLineReader()
_, serialized_example = reader.read(filename_queue)
filename, label = tf.decode_csv(serialized_example, [["path"], [0]])
label = tf.cast(label, tf.int32)
jpg = tf.read_file(filename)
image = tf.image.decode_jpeg(jpg, channels=3)
image = tf.cast(image, tf.float32)
if verbose:
print "original image shape:"
print image.get_shape()
# resize to distort
dist = tf.image.resize_images(image, (FLAGS.scale_h, FLAGS.scale_w))
# random crop
dist = tf.image.resize_image_with_crop_or_pad(dist, FLAGS.input_h, FLAGS.input_w)
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(FLAGS.num_examples_per_epoch_for_train * min_fraction_of_examples_in_queue)
print (
'filling queue with %d train images before starting to train. This will take a few minutes.' % min_queue_examples)
return self._generate_image_and_label_batch(dist, label, min_queue_examples, batch_size, shuffle=False)
评论列表
文章目录