Beispiel #1
0
 def image(self, *args, **kwargs):
   kwargs.setdefault('step', 1)
   writer = tf_v2.summary.create_file_writer(self.get_temp_dir())
   with writer.as_default():
     summary.image(*args, **kwargs)
   writer.close()
   return self.read_single_event_from_eventfile().summary
Beispiel #2
0
 def image_event(self, *args, **kwargs):
   kwargs.setdefault('step', 1)
   writer = tf2.summary.create_file_writer(self.get_temp_dir())
   with writer.as_default():
     summary.image(*args, **kwargs)
   writer.close()
   event_files = sorted(glob.glob(os.path.join(self.get_temp_dir(), '*')))
   self.assertEqual(len(event_files), 1)
   events = list(tf.compat.v1.train.summary_iterator(event_files[0]))
   # Expect a boilerplate event for the file_version, then the summary one.
   self.assertEqual(len(events), 2)
   # Delete the event file to reset to an empty directory for later calls.
   # TODO(nickfelt): use a unique subdirectory per writer instead.
   os.remove(event_files[0])
   return events[1]