コード例 #1
0
ファイル: beholder.py プロジェクト: shunsunsun/tensorboard
    def _get_final_image(self, session, config, arrays=None, frame=None):
        if config['values'] == 'frames':
            if frame is None:
                final_image = im_util.get_image_relative_to_script(
                    'frame-missing.png')
            else:
                frame = frame() if callable(frame) else frame
                final_image = im_util.scale_image_for_display(frame)

        elif config['values'] == 'arrays':
            if arrays is None:
                final_image = im_util.get_image_relative_to_script(
                    'arrays-missing.png')
                # TODO: hack to clear the info. Should be cleaner.
                self.visualizer._save_section_info([], [])
            else:
                final_image = self.visualizer.build_frame(arrays)

        elif config['values'] == 'trainable_variables':
            arrays = [
                session.run(x) for x in tf.compat.v1.trainable_variables()
            ]
            final_image = self.visualizer.build_frame(arrays)

        if len(final_image.shape) == 2:
            # Map grayscale images to 3D tensors.
            final_image = np.expand_dims(final_image, -1)

        return final_image
コード例 #2
0
 def __init__(self, context):
     self._MULTIPLEXER = context.multiplexer
     self.PLUGIN_LOGDIR = pau.PluginDirectory(context.logdir,
                                              shared_config.PLUGIN_NAME)
     self.FPS = 10
     self.most_recent_frame = im_util.get_image_relative_to_script(
         'no-data.png')
     self.most_recent_info = [{
         'name': 'Waiting for data...',
     }]
     self._config_file_lock = threading.Lock()
コード例 #3
0
 def _fetch_current_frame(self):
   path = '{}/{}'.format(self.PLUGIN_LOGDIR, shared_config.SUMMARY_FILENAME)
   with self._lock:
     try:
       frame = file_system_tools.read_tensor_summary(path).astype(np.uint8)
       self.most_recent_frame = frame
       return frame
     except (message.DecodeError, IOError, tf.errors.NotFoundError):
       if self.most_recent_frame is None:
         self.most_recent_frame = im_util.get_image_relative_to_script(
             'no-data.png')
       return self.most_recent_frame
コード例 #4
0
  def __init__(self, context):
    self._MULTIPLEXER = context.multiplexer
    self.PLUGIN_LOGDIR = pau.PluginDirectory(context.logdir, PLUGIN_NAME)
    self.FPS = 10
    self.most_recent_frame = get_image_relative_to_script('no-data.png')
    self.most_recent_info = [{
        'name': 'Waiting for data...',
    }]

    if not tf.gfile.Exists(self.PLUGIN_LOGDIR):
      tf.gfile.MakeDirs(self.PLUGIN_LOGDIR)
      write_pickle(DEFAULT_CONFIG, '{}/{}'.format(self.PLUGIN_LOGDIR,
                                                  CONFIG_FILENAME))
コード例 #5
0
    def _get_final_image(self, config, arrays=None, frame=None):
        if config['values'] == 'frames':
            if frame is None:
                final_image = im_util.get_image_relative_to_script(
                    'frame-missing.png')
            else:
                frame = frame() if callable(frame) else frame
                final_image = im_util.scale_image_for_display(frame)

        elif config['values'] == 'arrays':
            if arrays is None:
                final_image = im_util.get_image_relative_to_script(
                    'arrays-missing.png')
                # TODO: hack to clear the info. Should be cleaner.
                self.visualizer._save_section_info([], [])
            else:
                final_image = self.visualizer.build_frame(arrays)

        elif config['values'] == 'trainable_variables':
            arrays = [self.SESSION.run(x) for x in tf.trainable_variables()]
            final_image = self.visualizer.build_frame(arrays)

        return final_image