Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1.   def get_data(self):
  2.     def _parse_function(xfilename,yfilename):
  3.       W=960
  4.       H=720
  5.       image_size=vgg.vgg_16.default_image_size
  6.       image_string = tf.read_file(xfilename)
  7.       image_decoded = tf.image.decode_jpeg(image_string, channels=3)          # (1)
  8.       image = tf.cast(image_decoded, tf.float32)
  9.       x=tf.image.resize(image,(image_size,image_size))
  10.  
  11.       image_string = tf.read_file(yfilename)
  12.       image_decoded = tf.image.decode_jpeg(image_string, channels=3)          # (1)
  13.       y = tf.cast(image_decoded, tf.int32)
  14.  
  15.       equality = tf.equal(tf.reshape(y,[W, H, 1, 3] ), tf.reshape(classes, [n_class,3]))
  16.       equality = tf.cast(tf.reduce_all(equality, axis=-1), tf.int32)
  17.       return x,equality
  18.  
  19.     dataset=tf.data.Dataset.from_tensor_slices((self.xfilenames,self.yfilenames))
  20.     dataset=dataset.map(_parse_function,num_parallel_calls=8)
  21.     dataset=dataset.batch(self.batch_size)
  22.     self.dataset=dataset
  23.     iterator = tf.data.Iterator.from_structure(self.dataset.output_types,
  24.                                                self.dataset.output_shapes)
  25.     self.img, self.label = iterator.get_next()
  26.     print("get_data label",self.label.shape)
  27.     self.train_init = iterator.make_initializer(self.dataset)    # initializer for train_data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement