提交 508cea54 编写于 作者: D dyning

fix bug for rec nms

上级 e1f13ed9
......@@ -2,7 +2,7 @@ Global:
infer_imgs: "./recognition_demo_data_v1.0/test_cartoon"
det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
rec_inference_model_dir: "./models/cartoon_rec_ResNet50_iCartoon_v1.0_infer/"
rec_nms_thresold: 0.1
rec_nms_thresold: 0.05
batch_size: 1
image_shape: [3, 640, 640]
......
......@@ -2,7 +2,7 @@ Global:
infer_imgs: "./recognition_demo_data_v1.0/gallery/test_logo"
det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
rec_inference_model_dir: "./models/logo_rec_ResNet50_Logo3K_v1.0_infer/"
rec_nms_thresold: 0.3
rec_nms_thresold: 0.05
batch_size: 1
image_shape: [3, 640, 640]
......
......@@ -2,7 +2,7 @@ Global:
infer_imgs: "./recognition_demo_data_v1.0/test_product/daoxiangcunjinzhubing_6.jpg"
det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer"
rec_inference_model_dir: "./models/product_ResNet50_vd_aliproduct_v1.0_infer"
rec_nms_thresold: 0.3
rec_nms_thresold: 0.05
batch_size: 1
image_shape: [3, 640, 640]
......
......@@ -2,7 +2,7 @@ Global:
infer_imgs: "./recognition_demo_data_v1.0/test_vehicle/"
det_inference_model_dir: "./models/ppyolov2_r50vd_dcn_mainbody_v1.0_infer/"
rec_inference_model_dir: "./models/vehicle_cls_ResNet50_CompCars_v1.0_infer/"
rec_nms_thresold: 0.3
rec_nms_thresold: 0.05
batch_size: 1
image_shape: [3, 640, 640]
......
......@@ -56,7 +56,7 @@ class SystemPredictor(object):
})
return results
def nms_to_rec_results(self, results, thresh=0.3):
def nms_to_rec_results(self, results, thresh=0.1):
filtered_results = []
x1 = np.array([r["bbox"][0] for r in results]).astype("float32")
y1 = np.array([r["bbox"][1] for r in results]).astype("float32")
......@@ -66,22 +66,19 @@ class SystemPredictor(object):
areas = (x2 - x1 + 1) * (y2 - y1 + 1)
order = scores.argsort()[::-1]
while order.size > 0:
i = order[0]
xx1 = np.maximum(x1[i], x1[order[1:]])
yy1 = np.minimum(y1[i], y1[order[1:]])
yy1 = np.maximum(y1[i], y1[order[1:]])
xx2 = np.minimum(x2[i], x2[order[1:]])
yy2 = np.maximum(y2[i], y2[order[1:]])
yy2 = np.minimum(y2[i], y2[order[1:]])
w = np.maximum(0.0, xx2 - xx1 + 1)
h = np.maximum(0.0, yy2 - yy1 + 1)
inter = w * h
ovr = inter / (areas[i] + areas[order[1:]] - inter)
inds = np.where(ovr <= thresh)[0]
order = order[inds + 1]
filtered_results.append(results[i])
return filtered_results
......
......@@ -28,7 +28,8 @@ def draw_bbox_results(image,
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(font_path, 20, encoding="utf-8")
color = (0, 255, 0)
# color = (0, 255, 0)
color = (0, 102, 255)
for result in results:
# empty results
......@@ -40,9 +41,10 @@ def draw_bbox_results(image,
th = 20
tw = int(len(result["rec_docs"]) * 20) + 60
start_y = max(0, ymin - th)
draw.rectangle(
[(xmin + 1, start_y), (xmin + tw + 1, start_y + th)],
outline=color)
# draw.rectangle(
# [(xmin + 1, start_y), (xmin + tw + 1, start_y + th)],
# outline=color)
draw.text((xmin + 1, start_y), text, fill=color, font=font)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册