def edit_feature(self, feature): height, width = feature["image"].shape[0], feature["image"].shape[1] feature["x1"], feature["y1"], feature["x2"], feature["y2"] = feature["x1"]/width, feature["y1"]/height, feature["x2"]/width, feature["y2"]/height feature["image"] = cv2.resize(feature["image"], (128, 64)) #cv2 requires (width, height) anchorbox = get_fpn_anchor_box(input_shape=feature["image"].shape) target_cls, target_loc = get_target(anchorbox, feature["label"], feature["x1"], feature["y1"], feature["x2"], feature["y2"], num_classes=10) feature["target_cls"], feature["target_loc"] = target_cls, target_loc return feature
def __init__(self): self.model = RetinaNet(input_shape=(64, 128, 3), num_classes=10) self.optimizer = tf.optimizers.Adam(learning_rate=0.0001) self.loss = MyLoss() self.anchorbox = tf.convert_to_tensor( get_fpn_anchor_box(input_shape=(64, 128, 3))) self.anchor_w_h = tf.tile(self.anchorbox[:, 2:], [1, 2]) - tf.tile( self.anchorbox[:, :2], [1, 2])
def __init__(self, num_classes, input_shape, pred_key, gt_key, mode="eval", output_name=("mAP", "AP50", "AP75")): super().__init__(outputs=output_name, mode=mode) self.pred_key = pred_key self.gt_key = gt_key self.output_name = output_name assert len(self.output_name) == 3, 'MeanAvgPrecision trace adds 3 fields mAP AP50 AP75 to state ' self.iou_thres = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True) self.rec_thres = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True) self.categories = [n + 1 for n in range(num_classes)] # MSCOCO style class label starts from 1 self.maxdets = 100 self.image_ids = [] self.anch_box = get_fpn_anchor_box(input_shape=input_shape)[0]
def __init__(self, inputs=None, outputs=None, mode=None): super().__init__(inputs=inputs, outputs=outputs, mode=mode) self.anchorbox = get_fpn_anchor_box(input_shape=(64, 128, 3))
def __init__(self, inputs=None, outputs=None, mode=None): super().__init__(inputs=inputs, outputs=outputs, mode=mode) self.anchorbox = tf.convert_to_tensor( get_fpn_anchor_box(input_shape=(64, 128, 3))) self.anchor_w_h = tf.tile(self.anchorbox[:, 2:], [1, 2]) - tf.tile( self.anchorbox[:, :2], [1, 2])