python - In Tensorflow, is there an op / are there ops to accept a tensor (of filenames) and output images? -


i'd able read in batches of images. however, these batches must constructed python script (they cannot placed file ahead of time various reasons). what's efficient way, in tensorflow following:

(1) provided: python list of b variable-length strings point images, have same size. b batch size. (2) each string, load image corresponds to, , apply random crop of 5% (the crop random size of crop fixed) (3) concatenate images tensor of size b x h x w x 3

if not possible, have benchmarks / data on efficiency loss of loading , preprocessing images in python placing them queue? assume net run considerably faster if image loading / preprocessing done internally on tensorflow.

this how understand problem:

  • you have images
  • you have function sample_batch() returns batch of filenames of size b
  • you want read images corresponding these filenames , preprocess them
  • finally output batch of these examples

input = tf.placeholder(tf.string, name='input') queue = tf.fifoqueue(capacity, tf.string, [()], name='queue') enqueue_op = queue.enqueue_many(input)  reader = tf.wholefilereader() filename, content = reader.read(queue) image = tf.image.decode_jpeg(content, channels=3)  # preprocessing image = tf.random_crop(image, [h, w, 3]) image = tf.to_float(image) batch_image = tf.train.batch([image], batch_size=b, name='batch') output = inference(batch_image) 

then in session, have run enqueue operation filenames sample_batch()function:

with tf.session() sess:   tf.train.start_queue_runners()   in range(num_steps):     batch_filenames = sample_batch()     sess.run(enqueue_op, feed_dict={input: batch_filenames})     sess.run(output) 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -