Example #1
0
    def __init__(self, logdir):
        self.PLUGIN_LOGDIR = logdir + '/plugins/' + PLUGIN_NAME

        self.is_recording = False
        self.video_writer = video_writing.VideoWriter(
            self.PLUGIN_LOGDIR,
            outputs=[
                video_writing.FFmpegVideoOutput, video_writing.PNGVideoOutput
            ])

        self.frame_placeholder = tf.compat.v1.placeholder(
            tf.uint8, [None, None, None])
        self.summary_op = tf.compat.v1.summary.tensor_summary(
            TAG_NAME,
            self.frame_placeholder,
            collections=[SUMMARY_COLLECTION_KEY_NAME])

        self.last_image_shape = []
        self.last_update_time = time.time()
        self.config_last_modified_time = -1
        self.previous_config = dict(DEFAULT_CONFIG)

        if not tf.io.gfile.exists(self.PLUGIN_LOGDIR + '/config.pkl'):
            tf.io.gfile.makedirs(self.PLUGIN_LOGDIR)
            write_pickle(DEFAULT_CONFIG,
                         '{}/{}'.format(self.PLUGIN_LOGDIR, CONFIG_FILENAME))

        self.visualizer = Visualizer(self.PLUGIN_LOGDIR)
  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))
 def is_config_writable(self):
   try:
     if not tf.gfile.Exists(self.PLUGIN_LOGDIR):
       tf.gfile.MakeDirs(self.PLUGIN_LOGDIR)
     config_filename = '{}/{}'.format(
         self.PLUGIN_LOGDIR, shared_config.CONFIG_FILENAME)
     with self._config_file_lock:
       file_system_tools.write_pickle(
           file_system_tools.read_pickle(
               config_filename, shared_config.DEFAULT_CONFIG),
           config_filename)
     return True
   except tf.errors.PermissionDeniedError as e:
     tf.logging.warning(
         'Unable to write Beholder config, controls will be disabled: %s', e)
     return False
  def _serve_change_config(self, request):
    config = {}

    for key, value in request.form.items():
      try:
        config[key] = int(value)
      except ValueError:
        if value == 'false':
          config[key] = False
        elif value == 'true':
          config[key] = True
        else:
          config[key] = value

    self.FPS = config['FPS']

    write_pickle(config, '{}/{}'.format(self.PLUGIN_LOGDIR, CONFIG_FILENAME))
    return http_util.Respond(request, {'config': config}, 'application/json')
 def is_config_writable(self):
     try:
         if not tf.io.gfile.exists(self.PLUGIN_LOGDIR):
             tf.io.gfile.makedirs(self.PLUGIN_LOGDIR)
         config_filename = "{}/{}".format(self.PLUGIN_LOGDIR,
                                          shared_config.CONFIG_FILENAME)
         with self._config_file_lock:
             file_system_tools.write_pickle(
                 file_system_tools.read_pickle(
                     config_filename, shared_config.DEFAULT_CONFIG),
                 config_filename,
             )
         return True
     except tf.errors.PermissionDeniedError as e:
         logger.warn(
             "Unable to write Beholder config, controls will be disabled: %s",
             e,
         )
         return False
Example #6
0
    def __init__(self, session, logdir):
        self.video_writer = None

        self.PLUGIN_LOGDIR = logdir + '/plugins/' + PLUGIN_NAME
        self.SESSION = session

        self.frame_placeholder = None
        self.summary_op = None

        self.last_image_shape = []
        self.last_update_time = time.time()
        self.config_last_modified_time = -1
        self.previous_config = dict(DEFAULT_CONFIG)

        if not tf.gfile.Exists(self.PLUGIN_LOGDIR + '/config.pkl'):
            tf.gfile.MakeDirs(self.PLUGIN_LOGDIR)
            write_pickle(DEFAULT_CONFIG,
                         '{}/{}'.format(self.PLUGIN_LOGDIR, CONFIG_FILENAME))

        self.visualizer = Visualizer(self.PLUGIN_LOGDIR)
Example #7
0
  def _serve_change_config(self, request):
    config = {}

    for key, value in request.form.items():
      try:
        config[key] = int(value)
      except ValueError:
        if value == 'false':
          config[key] = False
        elif value == 'true':
          config[key] = True
        else:
          config[key] = value

    self.FPS = config['FPS']

    with self._config_file_lock:
      file_system_tools.write_pickle(
          config,
          '{}/{}'.format(self.PLUGIN_LOGDIR, shared_config.CONFIG_FILENAME))
    return http_util.Respond(request, {'config': config}, 'application/json')
Example #8
0
    def _save_section_info(self, arrays, sections):
        infos = []

        if self.config["values"] == "trainable_variables":
            names = [x.name for x in tf.compat.v1.trainable_variables()]
        else:
            names = range(len(arrays))

        for array, section, name in zip(arrays, sections, names):
            info = {}

            info["name"] = name
            info["shape"] = str(array.shape)
            info["min"] = "{:.3e}".format(section.min())
            info["mean"] = "{:.3e}".format(section.mean())
            info["max"] = "{:.3e}".format(section.max())
            info["range"] = "{:.3e}".format(section.max() - section.min())
            info["height"] = section.shape[0]

            infos.append(info)

        write_pickle(infos, "{}/{}".format(self.logdir, SECTION_INFO_FILENAME))
Example #9
0
    def _save_section_info(self, arrays, sections):
        infos = []

        if self.config['values'] == 'trainable_variables':
            names = [x.name for x in tf.compat.v1.trainable_variables()]
        else:
            names = range(len(arrays))

        for array, section, name in zip(arrays, sections, names):
            info = {}

            info['name'] = name
            info['shape'] = str(array.shape)
            info['min'] = '{:.3e}'.format(section.min())
            info['mean'] = '{:.3e}'.format(section.mean())
            info['max'] = '{:.3e}'.format(section.max())
            info['range'] = '{:.3e}'.format(section.max() - section.min())
            info['height'] = section.shape[0]

            infos.append(info)

        write_pickle(infos, '{}/{}'.format(self.logdir, SECTION_INFO_FILENAME))
    def _serve_change_config(self, request):
        config = {}

        for key, value in request.form.items():
            try:
                config[key] = int(value)
            except ValueError:
                if value == "false":
                    config[key] = False
                elif value == "true":
                    config[key] = True
                else:
                    config[key] = value

        self.FPS = config["FPS"]

        with self._config_file_lock:
            file_system_tools.write_pickle(
                config,
                "{}/{}".format(self.PLUGIN_LOGDIR,
                               shared_config.CONFIG_FILENAME),
            )
        return http_util.Respond(request, {"config": config},
                                 "application/json")