Skip to content
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

Merged
merged 4 commits into from
Jun 15, 2017

Conversation

pkuyym
Copy link
Contributor

@pkuyym pkuyym commented Jun 2, 2017

revoles #2356

}
}

size_t decomposeWithPermute(const MatrixPtr inMatrix,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

和appendWithPermute 可以合成同一个函数吧

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing by reference.

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Matrix&

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matrix& outMatrix

Copy link
Contributor Author

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,
Copy link
Contributor

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,
Copy link
Contributor

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;
Copy link
Contributor

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 };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groundtruth -> ground truth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

@pkuyym pkuyym left a 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;
Copy link
Contributor Author

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,
Copy link
Contributor Author

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,
Copy link
Contributor Author

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,
Copy link
Contributor Author

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
Copy link
Contributor Author

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 };
Copy link
Contributor Author

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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@qingqing01 qingqing01 left a 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) {
Copy link
Contributor

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里获取到吧。下面函数同样。

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing by reference.

Copy link
Contributor Author

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(); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T是float的话,是getArea吧,getArea是不是更合适些?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@pkuyym pkuyym merged commit 14c0e71 into PaddlePaddle:develop Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants