Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluation support model containing nms #51

Merged
merged 14 commits into from
Jul 29, 2022
28 changes: 18 additions & 10 deletions fastdeploy/vision/evaluation/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@
import copy
import collections

nms_include = ['PaddleDetection/PPYOLOE']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行代码没被引用到,移除掉吧



def eval_detection(model,
conf_threshold,
nms_iou_threshold,
data_dir,
ann_file,
conf_threshold=None,
nms_iou_threshold=None,
plot=False):
assert isinstance(conf_threshold, (
float, int
)), "The conf_threshold:{} need to be int or float".format(conf_threshold)
assert isinstance(nms_iou_threshold, (
float,
int)), "The nms_iou_threshold:{} need to be int or float".format(
nms_iou_threshold)
if conf_threshold is not None or nms_iou_threshold is not None:
assert conf_threshold is not None and nms_iou_threshold is not None, "The conf_threshold and nms_iou_threshold should be setted at the same time"
assert isinstance(conf_threshold, (
float,
int)), "The conf_threshold:{} need to be int or float".format(
conf_threshold)
assert isinstance(nms_iou_threshold, (
float,
int)), "The nms_iou_threshold:{} need to be int or float".format(
nms_iou_threshold)
eval_dataset = CocoDetection(
data_dir=data_dir, ann_file=ann_file, shuffle=False)
all_image_info = eval_dataset.file_list
Expand All @@ -49,7 +54,10 @@ def eval_detection(model,
image_num, desc="Inference Progress")):
im = cv2.imread(image_info["image"])
im_id = image_info["im_id"]
result = model.predict(im, conf_threshold, nms_iou_threshold)
if conf_threshold is None and nms_iou_threshold is None:
result = model.predict(im)
else:
result = model.predict(im, conf_threshold, nms_iou_threshold)
pred = {
'bbox':
[[c] + [s] + b
Expand Down