提交 c19a0f30 编写于 作者: D dengkaipeng

fix iou calc error

上级 eea7f8c0
......@@ -84,11 +84,11 @@ def box_iou_xywh(box1, box2):
inter_x1 = np.maximum(b1_x1, b2_x1)
inter_x2 = np.minimum(b1_x2, b2_x2)
inter_y1 = np.maximum(b1_y1, b2_y1)
inter_y2 = np.maximum(b1_y2, b2_y2)
inter_y2 = np.minimum(b1_y2, b2_y2)
inter_w = inter_x2 - inter_x1 + 1
inter_h = inter_y2 - inter_y1 + 1
inter_w[inter_w < 0] == 0
inter_h[inter_h < 0] == 0
inter_w[inter_w < 0] = 0
inter_h[inter_h < 0] = 0
inter_area = inter_w * inter_h
b1_area = (b1_x2 - b1_x1 + 1) * (b1_y2 - b1_y1 + 1)
......@@ -106,15 +106,15 @@ def box_iou_xyxy(box1, box2):
inter_x1 = np.maximum(b1_x1, b2_x1)
inter_x2 = np.minimum(b1_x2, b2_x2)
inter_y1 = np.maximum(b1_y1, b2_y1)
inter_y2 = np.maximum(b1_y2, b2_y2)
inter_w = inter_x2 - inter_x1 + 1
inter_h = inter_y2 - inter_y1 + 1
inter_w[inter_w < 0] == 0
inter_h[inter_h < 0] == 0
inter_y2 = np.minimum(b1_y2, b2_y2)
inter_w = inter_x2 - inter_x1
inter_h = inter_y2 - inter_y1
inter_w[inter_w < 0] = 0
inter_h[inter_h < 0] = 0
inter_area = inter_w * inter_h
b1_area = (b1_x2 - b1_x1 + 1) * (b1_y2 - b1_y1 + 1)
b2_area = (b2_x2 - b2_x1 + 1) * (b2_y2 - b2_y1 + 1)
b1_area = (b1_x2 - b1_x1) * (b1_y2 - b1_y1)
b2_area = (b2_x2 - b2_x1) * (b2_y2 - b2_y1)
return inter_area / (b1_area + b2_area - inter_area)
......
......@@ -61,19 +61,19 @@ def eval():
print("Load in labels {} with ids {}".format(label_names, label_ids))
feeder = fluid.DataFeeder(place=place, feed_list=model.feeds())
def get_pred_result(boxes, confs, labels, im_id):
def get_pred_result(boxes, scores, labels, im_id):
result = []
for box, conf, label in zip(boxes, confs, labels):
for box, score, label in zip(boxes, scores, labels):
x1, y1, x2, y2 = box
w = x2 - x1 + 1
h = y2 - y1 + 2
h = y2 - y1 + 1
bbox = [x1, y1, w, h]
res = {
'image_id': im_id,
'category_id': label_ids[int(label)],
'bbox': bbox,
'score': conf
'score': score
}
result.append(res)
return result
......
......@@ -41,7 +41,7 @@ class DataSetReader(object):
# cfg.data_dir = "dataset/coco"
# cfg.train_file_list = 'annotations/instances_val2017.json'
# cfg.train_data_dir = 'val2017'
cfg.dataset = "coco2017"
# cfg.dataset = "coco2017"
if 'coco2014' in cfg.dataset:
cfg.train_file_list = 'annotations/instances_train2014.json'
cfg.train_data_dir = 'train2014'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册