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

fix generate_proposal_labels in cascade-rcnn series model, test=develop #27892

Merged
merged 4 commits into from
Oct 20, 2020

Conversation

jerrywgz
Copy link
Contributor

@jerrywgz jerrywgz commented Oct 13, 2020

PR types

Function optimization

PR changes

OPs

Describe

Fix generate_proposal_labels in cascade-rcnn series model and add max_overlap as input.
This op is only used at the stage of training so it will have no effect on inference.
This op is only used in static mode so core.ops,xxx is not used as well.

The mAP of related models:
Cascade Faster RCNN is 40.8 and previous version is 40.9.
HTC is 42.9/37.0 and previous is 42.7/36.8

The difference on document is marked as below:
image
image
image

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Oct 13, 2020

✅ This PR's description meets the template requirements!
Please wait for other CI results.

@jerrywgz jerrywgz force-pushed the fix_generate_proposals_labels branch from ba40645 to 8ed941c Compare October 19, 2020 02:38
template <typename T>
void MaxOverlaps(const framework::Tensor& iou,
framework::Tensor* max_overlaps) {
const T* proposal_to_gt_overlaps = iou.data<T>();
Copy link
Contributor

Choose a reason for hiding this comment

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

作为util的通用函数,命名也需要更通用。 proposal_to_gt_overlaps -> iou_data

@@ -149,5 +149,19 @@ void ClipTiledBoxes(const platform::DeviceContext& ctx,
}
}

template <typename T>
void MaxOverlaps(const framework::Tensor& iou,
framework::Tensor* max_overlaps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

max_overlaps -> max_iou?

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

const T* proposal_to_gt_overlaps = iou.data<T>();
int row = iou.dims()[0];
int col = iou.dims()[1];
T* max_overlaps_dt = max_overlaps->data<T>();
Copy link
Contributor

Choose a reason for hiding this comment

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

max_overlaps_dt -> max_iou_data

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

@@ -2651,25 +2653,29 @@ def generate_proposal_labels(rpn_rois,
use_random(bool): Use random sampling to choose foreground and background boxes.
is_cls_agnostic(bool): bbox regression use class agnostic simply which only represent fg and bg boxes.
is_cascade_rcnn(bool): it will filter some bbox crossing the image's boundary when setting True.
max_overlap(Variable): Maximum overlap between each Input box and ground-truth.
Copy link
Contributor

Choose a reason for hiding this comment

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

Input box -> each proposal box .. ?

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

@@ -2651,25 +2653,29 @@ def generate_proposal_labels(rpn_rois,
use_random(bool): Use random sampling to choose foreground and background boxes.
is_cls_agnostic(bool): bbox regression use class agnostic simply which only represent fg and bg boxes.
is_cascade_rcnn(bool): it will filter some bbox crossing the image's boundary when setting True.
max_overlap(Variable): Maximum overlap between each Input box and ground-truth.
return_max_overlap(bool): Whether return the maximum overlap between each Output box and ground-truth.
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,Output box更精确的描述

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

is_cascade_rcnn=False):
is_cascade_rcnn=False,
max_overlap=None,
return_max_overlap=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

max_overlap是否始终return,而不加这个参数

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里希望可以兼容PaddleDetection先前的版本,如果始终return,https://github.com/PaddlePaddle/PaddleDetection/blob/release/0.4/ppdet/modeling/architectures/mask_rcnn.py#L125 计算 loss的位置会受到影响

gt_boxes = fluid.data(
name='gt_boxes', shape=[6, 4], dtype='float32', lod_level=1)
im_info = fluid.data(
name='im_info', shape=[1, 3], dtype='float32', lod_level=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

im_info的lod_level是0?

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, thx

max_overlap_slice =
max_overlap->Slice(rpn_rois_lod[i], rpn_rois_lod[i + 1]);
} else {
max_overlap_slice.mutable_data<T>(im_info_slice.dims(),
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的shape是和im_info_slice相同吗? im_info_slice的shape是[1, 3]?

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, thx

AddInput("MaxOverlap",
"(LoDTensor), This input is a 1D LoDTensor with shape [N]."
"N is the number of Input(RpnRois), "
"each element is the maxoverlap between "
Copy link
Contributor

Choose a reason for hiding this comment

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

maxoverlap -> max overlap

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

for (int i = 0; i < rois_num; ++i) {
if ((rpn_rois_dt[i * 4 + 2] - rpn_rois_dt[i * 4 + 0] + 1) > 0 &&
(rpn_rois_dt[i * 4 + 3] - rpn_rois_dt[i * 4 + 1] + 1) > 0 &&
max_overlap_dt[i] < 1.) {
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 why filter max_overlap_dt < 1.0

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

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

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

考虑到只训练使用,这里不做兼容要求

@jerrywgz jerrywgz requested review from zhiqiu and Heeenrrry October 20, 2020 07:53
Copy link
Contributor

@Heeenrrry Heeenrrry left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

generate_proposal_labels is used in static graph

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@jerrywgz jerrywgz merged commit d1e1f17 into PaddlePaddle:develop Oct 20, 2020
@jerrywgz jerrywgz deleted the fix_generate_proposals_labels branch October 20, 2020 11:02
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.

6 participants