-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
问题确认 Search before asking
- 我已经搜索过问题,但是没有找到解答。I have searched the question and found no related answer.
请提出你的问题 Please ask your question
我用ppyoloe训练得到一个模型,由于yolo的特性,模型的原始输出是几千个bbox,然后需要经过multiclassNMS过滤掉其中的部分输出,然后得到最终的结果;


可复现代码如下:
(py文件放在paddledetection的tools下面)
import numpy as np
import sys
import os
parent_path = os.path.abspath(os.path.join(file, *(['..'] * 2)))
sys.path.insert(0, parent_path)
import paddle
from ppdet.modeling.layers import MultiClassNMS
pred_bboxes = np.load('pred_bboxes.npy')
pred_scores = np.load('pred_scores.npy')
pred_bboxes_tensor = paddle.to_tensor(pred_bboxes)
pred_scores_tensor = paddle.to_tensor(pred_scores)
nms = MultiClassNMS(
score_threshold=0.01,
nms_top_k=1000,
keep_top_k=300,
nms_threshold=0.7,
normalized=True,
nms_eta=1.0,
return_index=True,
return_rois_num=True,
trt=False
)
bbox_pred, bbox_num, nms_keep_idx = nms(pred_bboxes_tensor, pred_scores_tensor)