rknpu icon indicating copy to clipboard operation
rknpu copied to clipboard

一个bug在rknn_yolov5_demo的nms中

Open choubin opened this issue 3 years ago • 0 comments

在:postprocess.cc中nms错误: 源代码: static int nms(int validCount, std::vector &outputLocations, std::vector classIds, std::vector &order, int filterId, float threshold) { for (int i = 0; i < validCount; ++i) { if (order[i] == -1 || classIds[i] != filterId) { continue; } int n = order[i]; for (int j = i + 1; j < validCount; ++j) { int m = order[j]; if (m == -1 || classIds[i] != filterId) { continue; } float xmin0 = outputLocations[n * 4 + 0]; float ymin0 = outputLocations[n * 4 + 1]; float xmax0 = outputLocations[n * 4 + 0] + outputLocations[n * 4 + 2]; float ymax0 = outputLocations[n * 4 + 1] + outputLocations[n * 4 + 3];

        float xmin1 = outputLocations[m * 4 + 0];
        float ymin1 = outputLocations[m * 4 + 1];
        float xmax1 = outputLocations[m * 4 + 0] + outputLocations[m * 4 + 2];
        float ymax1 = outputLocations[m * 4 + 1] + outputLocations[m * 4 + 3];

        float iou = CalculateOverlap(xmin0, ymin0, xmax0, ymax0, xmin1, ymin1, xmax1, ymax1);

        if (iou > threshold)
        {
            order[j] = -1;
        }
    }
}
return 0;

} 应该改为: static int nms(int validCount, std::vector &outputLocations, std::vector classIds, std::vector &order, int filterId, float threshold) { for (int i = 0; i < validCount; ++i) { int n = order[i]; if (n == -1 || classIds[n] != filterId) { continue; } for (int j = i + 1; j < validCount; ++j) { int m = order[j]; if (m == -1 || classIds[m] != filterId) { continue; } float xmin0 = outputLocations[n * 4 + 0]; float ymin0 = outputLocations[n * 4 + 1]; float xmax0 = outputLocations[n * 4 + 0] + outputLocations[n * 4 + 2]; float ymax0 = outputLocations[n * 4 + 1] + outputLocations[n * 4 + 3];

        float xmin1 = outputLocations[m * 4 + 0];
        float ymin1 = outputLocations[m * 4 + 1];
        float xmax1 = outputLocations[m * 4 + 0] + outputLocations[m * 4 + 2];
        float ymax1 = outputLocations[m * 4 + 1] + outputLocations[m * 4 + 3];

        float iou = CalculateOverlap(xmin0, ymin0, xmax0, ymax0, xmin1, ymin1, xmax1, ymax1);

        if (iou > threshold)
        {
            order[j] = -1;
        }
    }
}
return 0;

}

choubin avatar Dec 30 '21 02:12 choubin