Abstract BBox and provide general functions#2357
Abstract BBox and provide general functions#2357pkuyym merged 4 commits intoPaddlePaddle:developfrom
Conversation
| } | ||
| } | ||
|
|
||
| size_t decomposeWithPermute(const MatrixPtr inMatrix, |
There was a problem hiding this comment.
和appendWithPermute 可以合成同一个函数吧
There was a problem hiding this comment.
I think splitting two functions maybe better, appendWithPermute first permutes input matrix and appending to output matrix, but decomposeWithPermute first permutes input matrix and decomposing to output matrix. They are different in logic.
| outMatrix->getData() + offset, imgSize, channels, false, useGpu); | ||
| inTmp->transpose(outTmp, false); | ||
| } | ||
| return channels * imgSize; |
There was a problem hiding this comment.
Why return a size? can it be got from the outMatrix?
There was a problem hiding this comment.
Not really, outputs of different feature maps have different sizes and they will be concatenated to a single matrix, so we have to adjust the offset each time concatenating an image. Because the output matrix are allocated already, so we can't get the offset from output matrix.
| } | ||
|
|
||
| vector<real> encodeBBoxWithVar(const NormalizedBBox& priorBBox, | ||
| const vector<real> priorBBoxVar, |
|
|
||
| namespace paddle { | ||
|
|
||
| size_t appendWithPermute(const MatrixPtr inMatrix, |
| size_t outTotalSize, | ||
| size_t outOffset, | ||
| size_t batchSize, | ||
| MatrixPtr outMatrix, |
| } | ||
|
|
||
| pair<size_t, size_t> generateMatchIndices( | ||
| const MatrixPtr priorValue, |
| pair<size_t, size_t> generateMatchIndices( | ||
| const MatrixPtr priorValue, | ||
| const size_t numPriorBBoxes, | ||
| const MatrixPtr gtValue, |
| T yMin; | ||
| T xMax; | ||
| T yMax; | ||
| bool isDifficult; |
There was a problem hiding this comment.
add comments for these variables.
| NormalizedBBox() : BBoxBase<real>() {} | ||
| }; | ||
|
|
||
| enum PermMode { NCHWTONHWC, NHWCTONCHW }; |
There was a problem hiding this comment.
Please refer to PaddlePaddle naming conventions for constants. https://github.com/PaddlePaddle/cpp-primer-digest/pull/1/files#diff-04c6e90faac2675aa89e2176d2eec7d8R264
| real jaccardOverlap(const NormalizedBBox& bbox1, const NormalizedBBox& bbox2); | ||
|
|
||
| /** | ||
| * @brief Compute offset parameters between prior bbox and groundtruth bbox |
There was a problem hiding this comment.
groundtruth -> ground truth
| outMatrix->getData() + offset, imgSize, channels, false, useGpu); | ||
| inTmp->transpose(outTmp, false); | ||
| } | ||
| return channels * imgSize; |
There was a problem hiding this comment.
Not really, outputs of different feature maps have different sizes and they will be concatenated to a single matrix, so we have to adjust the offset each time concatenating an image. Because the output matrix are allocated already, so we can't get the offset from output matrix.
|
|
||
| namespace paddle { | ||
|
|
||
| size_t appendWithPermute(const MatrixPtr inMatrix, |
| size_t outTotalSize, | ||
| size_t outOffset, | ||
| size_t batchSize, | ||
| MatrixPtr outMatrix, |
| } | ||
| } | ||
|
|
||
| size_t decomposeWithPermute(const MatrixPtr inMatrix, |
There was a problem hiding this comment.
I think splitting two functions maybe better, appendWithPermute first permutes input matrix and appending to output matrix, but decomposeWithPermute first permutes input matrix and decomposing to output matrix. They are different in logic.
| real jaccardOverlap(const NormalizedBBox& bbox1, const NormalizedBBox& bbox2); | ||
|
|
||
| /** | ||
| * @brief Compute offset parameters between prior bbox and groundtruth bbox |
| NormalizedBBox() : BBoxBase<real>() {} | ||
| }; | ||
|
|
||
| enum PermMode { NCHWTONHWC, NHWCTONCHW }; |
| } | ||
|
|
||
| vector<real> encodeBBoxWithVar(const NormalizedBBox& priorBBox, | ||
| const vector<real> priorBBoxVar, |
| size_t batchSize, | ||
| Matrix& outMatrix, | ||
| PermMode permMode, | ||
| bool useGpu) { |
There was a problem hiding this comment.
inMatrix, outMatrix的是否GPU模式要相同吧,useGpu参数可以从inMatrix/outMatrix里获取到吧。下面函数同样。
| } | ||
|
|
||
| void encodeBBoxWithVar(const NormalizedBBox& priorBBox, | ||
| const vector<real> priorBBoxVar, |
|
|
||
| T getCenterY() const { return (yMin + yMax) / 2; } | ||
|
|
||
| T getSize() const { return getWidth() * getHeight(); } |
There was a problem hiding this comment.
T是float的话,是getArea吧,getArea是不是更合适些?
revoles #2356