def save_connection_config(self) -> None: if self.name and self.url: config_parser = RawConfigParser() config_parser.add_section(SECTION_TITLE) config_parser.set(SECTION_TITLE, 'url', self.url) if self._requires_auth: config_parser.set(SECTION_TITLE, 'username', self._auth['username']) password = encode(encode_password(), self._auth['password']) config_parser.set(SECTION_TITLE, 'password', password) if self.jenkins_views: config_parser.set(SECTION_TITLE, 'views', ','.join(self.view_names)) for view in self.views: view.save_view_config() save_argus_config( config_parser, build_config_file(jenkins_connections_dir, self.name)) else: raise ConfigError( 'No data to save in JenkinsConnection config file.')
def save_config(self) -> None: """ Blindly overwrites existing config file for connection. """ config_parser = configparser.RawConfigParser() config_parser.add_section('Connection') config_parser.set('Connection', 'url', self._url) config_parser.set('Connection', 'user', encode(encode_password(), self._user)) config_parser.set('Connection', 'password', encode(encode_password(), self._pass)) config_parser.set('Connection', 'projects', ','.join(self.possible_projects)) save_argus_config(config_parser, self._build_config(self.connection_name))
def _create_targets(anchors, groundtruth_boxes, matches): """Returns regression targets for each anchor. Arguments: anchors: a float tensor with shape [num_anchors, 4]. groundtruth_boxes: a float tensor with shape [N, 4]. matches: a int tensor with shape [num_anchors]. Returns: reg_targets: a float tensor with shape [num_anchors, 4]. """ matched_anchor_indices = tf.where(tf.greater_equal( matches, 0)) # shape [num_matches, 1] matched_anchor_indices = tf.squeeze(matched_anchor_indices, axis=1) matched_gt_indices = tf.gather( matches, matched_anchor_indices) # shape [num_matches] matched_anchors = tf.gather( anchors, matched_anchor_indices) # shape [num_matches, 4] matched_gt_boxes = tf.gather(groundtruth_boxes, matched_gt_indices) # shape [num_matches, 4] matched_reg_targets = encode(matched_gt_boxes, matched_anchors) # shape [num_matches, 4] unmatched_anchor_indices = tf.where(tf.equal(matches, -1)) unmatched_anchor_indices = tf.squeeze(unmatched_anchor_indices, axis=1) # it has shape [num_anchors - num_matches] unmatched_reg_targets = tf.zeros([tf.size(unmatched_anchor_indices), 4]) # it has shape [num_anchors - num_matches, 4] matched_anchor_indices = tf.to_int32(matched_anchor_indices) unmatched_anchor_indices = tf.to_int32(unmatched_anchor_indices) reg_targets = tf.dynamic_stitch( [matched_anchor_indices, unmatched_anchor_indices], [matched_reg_targets, unmatched_reg_targets]) return reg_targets
def _create_targets(anchors, groundtruth_boxes, groundtruth_labels, matches, num_classes): """Returns regression and classification targets for each anchor. Arguments: anchors: a float tensor with shape [num_anchors, 4]. groundtruth_boxes: a float tensor with shape [N, 4]. groundtruth_labels: a float tensor with shape [N, num_classes]. matches: a int tensor with shape [num_anchors]. num_classes: an integer. Returns: cls_targets: a float tensor with shape [num_anchors, num_classes + 1]. reg_targets: a float tensor with shape [num_anchors, 4]. """ num_anchors = anchors.shape.as_list()[0] matched_anchor_indices = tf.where(tf.greater_equal( matches, 0)) # shape [num_matches, 1] matched_anchor_indices = tf.squeeze(matched_anchor_indices, axis=1) matched_gt_indices = tf.gather( matches, matched_anchor_indices) # shape [num_matches] matched_anchors = tf.gather( anchors, matched_anchor_indices) # shape [num_matches, 4] matched_gt_boxes = tf.gather(groundtruth_boxes, matched_gt_indices) # shape [num_matches, 4] matched_reg_targets = encode(matched_gt_boxes, matched_anchors) # shape [num_matches, 4] unmatched_anchor_indices = tf.where(tf.equal(matches, -1)) unmatched_anchor_indices = tf.squeeze(unmatched_anchor_indices, axis=1) # it has shape [num_anchors - num_matches] unmatched_reg_targets = tf.zeros([tf.size(unmatched_anchor_indices), 4]) # it has shape [num_anchors - num_matches, 4] matched_anchor_indices = tf.to_int32(matched_anchor_indices) unmatched_anchor_indices = tf.to_int32(unmatched_anchor_indices) reg_targets = tf.dynamic_stitch( [matched_anchor_indices, unmatched_anchor_indices], [matched_reg_targets, unmatched_reg_targets]) reg_targets.set_shape([num_anchors, 4]) matched_cls_targets = tf.gather(groundtruth_labels, matched_gt_indices) # it has shape [num_matches, num_classes] matched_cls_targets = tf.pad(matched_cls_targets, [[0, 0], [1, 0]]) # it has shape [num_matches, num_classes + 1] # one-hot encoding for background class unmatched_cls_target = tf.constant([[1.0] + num_classes * [0.0]], tf.float32) unmatched_cls_targets = tf.tile( unmatched_cls_target, tf.stack([tf.size(unmatched_anchor_indices), 1])) # shape [num_anchors - num_matches, num_classes + 1] cls_targets = tf.dynamic_stitch( [matched_anchor_indices, unmatched_anchor_indices], [matched_cls_targets, unmatched_cls_targets]) cls_targets.set_shape([num_anchors, num_classes + 1]) return reg_targets, cls_targets