コード例 #1
0
 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
コード例 #2
0
 def forward(self, data, state):
     label, x1, y1, x2, y2 = data
     target_cls, target_loc = get_target(self.anchorbox,
                                         label,
                                         x1,
                                         y1,
                                         x2,
                                         y2,
                                         num_classes=10)
     return target_cls, target_loc
コード例 #3
0
 def forward(self, data, state):
     obj_label, x1, y1, width, height = data
     num_example = obj_label.shape[0]
     cls_gt = []
     x1_gt = []
     y1_gt = []
     w_gt = []
     h_gt = []
     for idx in range(num_example):
         c, x, y, w, h = get_target(self.anchorbox, obj_label[idx], x1[idx],
                                    y1[idx], width[idx], height[idx])
         cls_gt.append(c)
         x1_gt.append(x)
         y1_gt.append(y)
         w_gt.append(w)
         h_gt.append(h)
     target = [
         np.array(cls_gt),
         np.array(x1_gt),
         np.array(y1_gt),
         np.array(w_gt),
         np.array(h_gt)
     ]
     return target