Commit b55f54e1 authored by xin.wang.waytous's avatar xin.wang.waytous

nms-all-class

parent a558d3eb
......@@ -145,6 +145,7 @@ void InstanceMask::encode(const cv::Mat& map){
count++;
}
}
cnts.push_back(count);
long x; int more;
int m = cnts.size();
for(int i=0; i<m; i++ ) {
......
......@@ -132,7 +132,7 @@ bool MultiPostProcess::Exec() {
}
// NMS
LOG_INFO << "before nms:" << dets->detections.size();
nms_cpu(dets, scoreThreshold, nmsThreshold, instanceClassNumber, keepTopK);
nms_cpu(dets, scoreThreshold, nmsThreshold, instanceClassNumber, keepTopK, true);
LOG_INFO << "after nms:" << dets->detections.size();
// Instance Mask
......
......@@ -23,13 +23,14 @@ float iou(float lbox[4], float rbox[4]) {
}
void nms_cpu(ios::Detection2DsPtr dets, float conf_thresh, float nms_thresh, int num_classes, int keep_top_k){
void nms_cpu(ios::Detection2DsPtr dets, float conf_thresh, float nms_thresh, int num_classes, int keep_top_k, bool all_class){
std::vector<ios::Det2DPtr> res;
std::map<int, std::vector<ios::Det2DPtr>> m;
for (auto det: dets->detections) {
if (m.count(det->class_label) == 0)
m.emplace(det->class_label, std::vector<ios::Det2DPtr>());
m[det->class_label].push_back(det);
int label = all_class ? 0 : det->class_label;
if (m.count(label) == 0)
m.emplace(label, std::vector<ios::Det2DPtr>());
m[label].push_back(det);
}
dets->detections.clear();
for (auto it = m.begin(); it != m.end(); it++) {
......
......@@ -21,7 +21,7 @@ float iou(float lbox[4], float rbox[4]);
void nms_cpu(ios::Detection2DsPtr dets, float conf_thresh,
float nms_thresh, int num_classes, int keep_top_k=100);
float nms_thresh, int num_classes, int keep_top_k=100, bool all_class=false);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment