Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

add image resize operator and support batch_size #13611

Closed

Conversation

stu1130
Copy link
Contributor

@stu1130 stu1130 commented Dec 11, 2018

Description

  1. move the logic from python to C++ and change the Resize as HybridBlock
  2. support batch_size for resize
  3. add unit tests

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

Comments

@sandeep-krishnamurthy

Copy link
Contributor

@sandeep-krishnamurthy sandeep-krishnamurthy left a 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

src/operator/image/image_random-inl.h Outdated Show resolved Hide resolved
src/operator/image/image_random-inl.h Outdated Show resolved Hide resolved
src/operator/image/image_random-inl.h Outdated Show resolved Hide resolved
src/operator/image/image_random-inl.h Outdated Show resolved Hide resolved
@sandeep-krishnamurthy
Copy link
Contributor

@zhreshold @apeforest - Can you help take a review?

@roywei
Copy link
Member

roywei commented Dec 12, 2018

@mxnet-label-bot add[Operator, pr-awaiting-review]

@marcoabreu marcoabreu added Operator pr-awaiting-review PR is waiting for code review labels Dec 12, 2018
@stu1130 stu1130 changed the title add image resize operator and unit test add image resize operator and support batch_size Dec 12, 2018
@stu1130 stu1130 mentioned this pull request Dec 18, 2018
5 tasks
@stu1130 stu1130 mentioned this pull request Dec 20, 2018
5 tasks
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)
Copy link
Member

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 ?

Copy link
Contributor Author

@stu1130 stu1130 Dec 21, 2018

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

DMLC_REGISTER_PARAMETER(ResizeParam);

NNVM_REGISTER_OP(_image_resize)
.describe(R"code()code" ADD_FILELINE)
Copy link
Member

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')
Copy link
Member

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

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 ?

Copy link
Contributor Author

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

@Roshrini
Copy link
Member

Roshrini commented Jan 2, 2019

@stu1130 Can you look into failing CI builds? Thanks

@stu1130
Copy link
Contributor Author

stu1130 commented Jan 24, 2019

Close the PR to implement GPU support, will reopen once it's done

@stu1130 stu1130 closed this Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Operator pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants