mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Fix Proposal deep learning layer
This commit is contained in:
@@ -31,6 +31,7 @@ public:
|
||||
lp.set("flip", false);
|
||||
lp.set("clip", false);
|
||||
lp.set("normalized_bbox", false);
|
||||
lp.set("offset", 0.5 * baseSize / featStride);
|
||||
|
||||
// Unused values.
|
||||
float variance[] = {0.1f, 0.1f, 0.2f, 0.2f};
|
||||
@@ -123,7 +124,9 @@ public:
|
||||
CV_Assert(layerInternals.empty());
|
||||
internals.push_back(layerOutputs[0]);
|
||||
|
||||
outputs.resize(1, shape(keepTopAfterNMS, 5));
|
||||
outputs.resize(2);
|
||||
outputs[0] = shape(keepTopAfterNMS, 5);
|
||||
outputs[1] = shape(keepTopAfterNMS, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -210,13 +213,20 @@ public:
|
||||
CV_Assert(numDets <= keepTopAfterNMS);
|
||||
|
||||
MatShape s = shape(numDets, 7);
|
||||
UMat src = layerOutputs[0].reshape(1, s.size(), &s[0]).colRange(3, 7);
|
||||
layerOutputs[0] = layerOutputs[0].reshape(1, s.size(), &s[0]);
|
||||
|
||||
// The boxes.
|
||||
UMat dst = outputs[0].rowRange(0, numDets);
|
||||
src.copyTo(dst.colRange(1, 5));
|
||||
layerOutputs[0].colRange(3, 7).copyTo(dst.colRange(1, 5));
|
||||
dst.col(0).setTo(0); // First column are batch ids. Keep it zeros too.
|
||||
|
||||
// The scores.
|
||||
dst = outputs[1].rowRange(0, numDets);
|
||||
layerOutputs[0].col(2).copyTo(dst);
|
||||
|
||||
if (numDets < keepTopAfterNMS)
|
||||
outputs[0].rowRange(numDets, keepTopAfterNMS).setTo(0);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
outputs[i].rowRange(numDets, keepTopAfterNMS).setTo(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -284,13 +294,19 @@ public:
|
||||
const int numDets = layerOutputs[0].total() / 7;
|
||||
CV_Assert(numDets <= keepTopAfterNMS);
|
||||
|
||||
Mat src = layerOutputs[0].reshape(1, numDets).colRange(3, 7);
|
||||
// The boxes.
|
||||
layerOutputs[0] = layerOutputs[0].reshape(1, numDets);
|
||||
Mat dst = outputs[0].rowRange(0, numDets);
|
||||
src.copyTo(dst.colRange(1, 5));
|
||||
layerOutputs[0].colRange(3, 7).copyTo(dst.colRange(1, 5));
|
||||
dst.col(0).setTo(0); // First column are batch ids. Keep it zeros too.
|
||||
|
||||
// The scores.
|
||||
dst = outputs[1].rowRange(0, numDets);
|
||||
layerOutputs[0].col(2).copyTo(dst);
|
||||
|
||||
if (numDets < keepTopAfterNMS)
|
||||
outputs[0].rowRange(numDets, keepTopAfterNMS).setTo(0);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
outputs[i].rowRange(numDets, keepTopAfterNMS).setTo(0);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user