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

Add Python interface of prior_boxes #8265

Merged
merged 14 commits into from
Feb 12, 2018

Conversation

chengduoZH
Copy link
Contributor

@chengduoZH chengduoZH commented Feb 8, 2018

fix #8333
related issue #7488

@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 3 times, most recently from 34ccd60 to 540f93a Compare February 8, 2018 07:52
@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 3 times, most recently from 542e3ba to 64151ed Compare February 8, 2018 11:35
@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 2 times, most recently from 80a9241 to 2d8ef00 Compare February 9, 2018 10:45
@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 2 times, most recently from b6108b2 to 679e500 Compare February 9, 2018 11:59
@chengduoZH chengduoZH changed the title [WIP]Add Python interface of prior_boxes Add Python interface of prior_boxes Feb 9, 2018
@@ -64,7 +66,11 @@
'nce',
'beam_search',
'row_conv',
'reshape',
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

return box, var


def prior_boxes(input_layers,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think only prior_boxes is enough. the definition of prior_box can be moved this function.

@CLAassistant
Copy link

CLAassistant commented Feb 10, 2018

CLA assistant check
All committers have signed the CLA.

@@ -3091,3 +3096,295 @@ def multiplex(inputs, index):
'Ids': index},
outputs={'Out': [out]})
return out


def reshape_with_axis(input, axis):
Copy link
Contributor

Choose a reason for hiding this comment

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

我觉得不需要封装这个接口给用户,一个reshape足够了,类似这样的接口用户可以自己封装,不需要Fluid官方提供。

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

type='reshape',
inputs={'X': [input]},
outputs={'Out': [out]},
attrs={'shape': new_shape})
Copy link
Contributor

Choose a reason for hiding this comment

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

out = layers.reshape(input, shape=new_shape)

Copy link
Contributor Author

@chengduoZH chengduoZH Feb 11, 2018

Choose a reason for hiding this comment

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

I think flatten is a common function and Fluid should have it.

max_sizes = [base_size * .20] + max_sizes

if step_h:
assert isinstance(step_h,list) and len(step_h) == num_layer, \
Copy link
Contributor

Choose a reason for hiding this comment

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

assert -> raise ValueError('xxx')

reshaped.shape
>> [-1, 96, 32]
"""
assert isinstance(axis, list), "axis should be list."
Copy link
Contributor

Choose a reason for hiding this comment

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

Please raise a ValueError instead.

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 have removed this function.

@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 4 times, most recently from fc0ad2a to 02a9bfc Compare February 11, 2018 09:23
>> [-1, 1024]
"""
assert len(input.shape) > axis and axis > 0, \
"the axis should be litter than input.shape's."
Copy link
Contributor

Choose a reason for hiding this comment

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

litter --> smaller
input.shape's --> arity of input's shape

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

be two-dimension. The axis is used to indicate where to split the dimension.

Args:
input(variable): The input tensor.
Copy link
Contributor

Choose a reason for hiding this comment

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

input(variable) --> input (Variable)

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

"""
**Prior_boxes**

Generate prior boxes for SSD(Single Shot MultiBox Detector) algorithm.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is a little obscure, please refine it.

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


Args:
inputs(list): The list of input variables, the format of all variables is NCHW.
image(variable): The input image data of PriorBoxOp, the layout is NCHW.
Copy link
Contributor

Choose a reason for hiding this comment

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

image(variable) --> image (Variable)

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

@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 7 times, most recently from 229ea69 to 15e35fb Compare February 11, 2018 11:52
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.

@chengduoZH Thank you!

]


def prior_boxes(inputs,
Copy link
Contributor

Choose a reason for hiding this comment

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

prior_boxes -> prior_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


__all__ = [
'prior_box',
'prior_boxes',
Copy link
Contributor

Choose a reason for hiding this comment

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

remove prior_boxes

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

main(use_cuda=False)

def test_cuda(self):
main(use_cuda=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Need to move test to https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/test_detection.py

  2. box and var shape can be checked without exe.run

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

@chengduoZH chengduoZH force-pushed the feature/add_prior_box_py branch 4 times, most recently from 20f7fdf to c1082c9 Compare February 12, 2018 01:54
Copy link
Contributor

@wanghaox wanghaox left a comment

Choose a reason for hiding this comment

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

LGTM

@chengduoZH chengduoZH merged commit 7757a8a into PaddlePaddle:develop Feb 12, 2018
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.

Wrap Python API for prior_box_op
5 participants