def _write_dummy_files(self): plugin_dir = '/tmp/beholder-test/plugins/beholder' tf.gfile.MakeDirs(plugin_dir) info_path = plugin_dir + '/section-info.pkl' config_path = plugin_dir + '/config.pkl' write_pickle([{ 'shape': '(3, 3, 3, 64)', 'mean': '1.131e-07', 'min': '2.022e-11', 'range': '3.949e-07', 'name': 'conv1_1/weights:0', 'max': '3.949e-07' }], info_path) write_pickle({ 'values': 'trainable_variables', 'mode': 'variance', 'scaling': 'layer', 'window_size': 10, 'FPS': 10, 'is_recording': False, 'show_all': False, 'colormap': 'grayscale' }, config_path)
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 _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 __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)
def _save_section_info(self, arrays, sections): infos = [] if self.config['values'] == 'trainable_variables': names = [x.name for x in tf.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 _write_config(self): write_pickle(self.config, '/tmp/beholder-test/plugins/beholder/config.pkl')