-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract BBox and provide general functions #2357
Conversation
} | ||
} | ||
|
||
size_t decomposeWithPermute(const MatrixPtr inMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和appendWithPermute 可以合成同一个函数吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return a size? can it be got from the outMatrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing by reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
namespace paddle { | ||
|
||
size_t appendWithPermute(const MatrixPtr inMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const Matrix&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
size_t outTotalSize, | ||
size_t outOffset, | ||
size_t batchSize, | ||
MatrixPtr outMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matrix& outMatrix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
pair<size_t, size_t> generateMatchIndices( | ||
const MatrixPtr priorValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const Matrix&
pair<size_t, size_t> generateMatchIndices( | ||
const MatrixPtr priorValue, | ||
const size_t numPriorBBoxes, | ||
const MatrixPtr gtValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const Matrix&
T yMin; | ||
T xMax; | ||
T yMax; | ||
bool isDifficult; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comments for these variables.
NormalizedBBox() : BBoxBase<real>() {} | ||
}; | ||
|
||
enum PermMode { NCHWTONHWC, NHWCTONCHW }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to PaddlePaddle naming conventions for constants. https://github.com/PaddlePaddle/cpp-primer-digest/pull/1/files#diff-04c6e90faac2675aa89e2176d2eec7d8R264
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groundtruth -> ground truth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow comments.
outMatrix->getData() + offset, imgSize, channels, false, useGpu); | ||
inTmp->transpose(outTmp, false); | ||
} | ||
return channels * imgSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
size_t outTotalSize, | ||
size_t outOffset, | ||
size_t batchSize, | ||
MatrixPtr outMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
} | ||
|
||
size_t decomposeWithPermute(const MatrixPtr inMatrix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
NormalizedBBox() : BBoxBase<real>() {} | ||
}; | ||
|
||
enum PermMode { NCHWTONHWC, NHWCTONCHW }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
vector<real> encodeBBoxWithVar(const NormalizedBBox& priorBBox, | ||
const vector<real> priorBBoxVar, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
size_t batchSize, | ||
Matrix& outMatrix, | ||
PermMode permMode, | ||
bool useGpu) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inMatrix, outMatrix的是否GPU模式要相同吧,useGpu参数可以从inMatrix/outMatrix里获取到吧。下面函数同样。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
void encodeBBoxWithVar(const NormalizedBBox& priorBBox, | ||
const vector<real> priorBBoxVar, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passing by reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
T getCenterY() const { return (yMin + yMax) / 2; } | ||
|
||
T getSize() const { return getWidth() * getHeight(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T是float的话,是getArea吧,getArea是不是更合适些?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
revoles #2356