add image resize operator and support batch_size #13611
add image resize operator and support batch_size #13611
Conversation
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.
Thanks. Few comments inline
@zhreshold @apeforest - Can you help take a review? |
@mxnet-label-bot add[Operator, pr-awaiting-review] |
DMLC_DECLARE_FIELD(size) | ||
.set_default(nnvm::Tuple<int>()) | ||
.describe("Size of new image. Could be (width, height) or (size)"); | ||
DMLC_DECLARE_FIELD(keep_ratio) |
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 not setting set_default for keep_ratio ?
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.
python fronted will have a default value for keep_ratio
but no hurt to set default value here
src/operator/image/resize.cc
Outdated
DMLC_REGISTER_PARAMETER(ResizeParam); | ||
|
||
NNVM_REGISTER_OP(_image_resize) | ||
.describe(R"code()code" ADD_FILELINE) |
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.
can we add some usage examples.
data_expected = image.imresize(data_in, 200, 200, 1) | ||
assert_almost_equal(out_nd.asnumpy(), data_expected.asnumpy()) | ||
# test 4D input | ||
data_bath_in = nd.random.uniform(0, 255, (3, 300, 200, 3)).astype('uint8') |
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.
can we test for one other dtype apart from uint8
MSHADOW_TYPE_SWITCH(outputs[0].type_flag_, DType, { | ||
cv::Mat buf(inputs[0].shape_[kH], inputs[0].shape_[kW], cv_type, | ||
inputs[0].dptr<DType>() + input_index); | ||
cv::Mat dst(outputs[0].shape_[kH], outputs[0].shape_[kW], cv_type, |
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.
are these calls thread safe ?
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.
for each iteration, we access different address of the input and write the result back to the different address as well. It's thread safe
@stu1130 Can you look into failing CI builds? Thanks |
Close the PR to implement GPU support, will reopen once it's done |
Description
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments
@sandeep-krishnamurthy