-
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
Add Python interface of prior_boxes #8265
Add Python interface of prior_boxes #8265
Conversation
34ccd60
to
540f93a
Compare
542e3ba
to
64151ed
Compare
64151ed
to
19749d5
Compare
80a9241
to
2d8ef00
Compare
b6108b2
to
679e500
Compare
679e500
to
5f15037
Compare
python/paddle/v2/fluid/layers/nn.py
Outdated
@@ -64,7 +66,11 @@ | |||
'nce', | |||
'beam_search', | |||
'row_conv', | |||
'reshape', |
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.
reshape
has been exposed to Python in https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/layers/ops.py#L50
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
python/paddle/v2/fluid/layers/nn.py
Outdated
return box, var | ||
|
||
|
||
def prior_boxes(input_layers, |
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 only prior_boxes
is enough. the definition of prior_box can be moved this function.
b15f161
to
4a8559c
Compare
… feature/add_prior_box_py
4bbe93c
to
cf2ed17
Compare
python/paddle/v2/fluid/layers/nn.py
Outdated
@@ -3091,3 +3096,295 @@ def multiplex(inputs, index): | |||
'Ids': index}, | |||
outputs={'Out': [out]}) | |||
return out | |||
|
|||
|
|||
def reshape_with_axis(input, axis): |
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.
我觉得不需要封装这个接口给用户,一个reshape足够了,类似这样的接口用户可以自己封装,不需要Fluid官方提供。
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
python/paddle/v2/fluid/layers/nn.py
Outdated
type='reshape', | ||
inputs={'X': [input]}, | ||
outputs={'Out': [out]}, | ||
attrs={'shape': new_shape}) |
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.
out = layers.reshape(input, shape=new_shape)
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 flatten
is a common function and Fluid should have it.
python/paddle/v2/fluid/layers/nn.py
Outdated
max_sizes = [base_size * .20] + max_sizes | ||
|
||
if step_h: | ||
assert isinstance(step_h,list) and len(step_h) == num_layer, \ |
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.
assert
-> raise ValueError('xxx')
python/paddle/v2/fluid/layers/nn.py
Outdated
reshaped.shape | ||
>> [-1, 96, 32] | ||
""" | ||
assert isinstance(axis, list), "axis should be list." |
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 raise a ValueError instead.
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 have removed this function.
fc0ad2a
to
02a9bfc
Compare
python/paddle/v2/fluid/layers/nn.py
Outdated
>> [-1, 1024] | ||
""" | ||
assert len(input.shape) > axis and axis > 0, \ | ||
"the axis should be litter than input.shape's." |
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.
litter --> smaller
input.shape's --> arity of input's shape
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
python/paddle/v2/fluid/layers/nn.py
Outdated
be two-dimension. The axis is used to indicate where to split the dimension. | ||
|
||
Args: | ||
input(variable): The input tensor. |
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.
input(variable) --> input (Variable)
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
""" | ||
**Prior_boxes** | ||
|
||
Generate prior boxes for SSD(Single Shot MultiBox Detector) algorithm. |
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.
This comment is a little obscure, please refine it.
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
|
||
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. |
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.
image(variable) --> image (Variable)
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
229ea69
to
15e35fb
Compare
15e35fb
to
d641d5a
Compare
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.
@chengduoZH Thank you!
] | ||
|
||
|
||
def prior_boxes(inputs, |
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.
prior_boxes -> prior_box
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
|
||
__all__ = [ | ||
'prior_box', | ||
'prior_boxes', |
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.
remove prior_boxes
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
main(use_cuda=False) | ||
|
||
def test_cuda(self): | ||
main(use_cuda=True) |
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.
-
Need to move test to https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/fluid/tests/test_detection.py
-
box and var shape can be checked without exe.run
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
20f7fdf
to
c1082c9
Compare
c1082c9
to
5ccab2d
Compare
… feature/add_prior_box_py
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
d551be9
to
7a05263
Compare
… feature/add_prior_box_py
7a05263
to
dff1bf3
Compare
fix #8333
related issue #7488