Skip to content

Conversation

surgan12
Copy link
Contributor

@surgan12 surgan12 commented Jun 27, 2019

This PR includes:

  1. Making Random Erasing out of place by default.
  2. Test for checking the non-alteration of the unerased portion.
  3. Test for verifying the optional in-place behaviour

cc: @fmassa

@surgan12 surgan12 changed the title Tests Improvisations for Random Erasing Test Improvisations for Random Erasing Jun 27, 2019
@codecov-io
Copy link

codecov-io commented Jun 27, 2019

Codecov Report

Merging #1060 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1060      +/-   ##
==========================================
- Coverage   63.95%   63.91%   -0.04%     
==========================================
  Files          66       66              
  Lines        5279     5282       +3     
  Branches      793      794       +1     
==========================================
  Hits         3376     3376              
- Misses       1672     1674       +2     
- Partials      231      232       +1
Impacted Files Coverage Δ
torchvision/transforms/transforms.py 81.56% <100%> (-0.57%) ⬇️
torchvision/transforms/functional.py 72.14% <100%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 427633a...0acffcf. Read the comment docs.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, having more tests is always better!

I just realized that there is a problem with the current RandomErasing: it performs the operation in-place. I think that we might want to do it out-of-place, because in-place operations are generally not expected.

Given that RandomErasing has not been in any release yet, I think it's ok to make it out-of-place right away.

Can you update the PR fixing it, and modifying the tests for the new behavior?

# Check if the unerased region is preserved
img_output = F.erase(img, i, j, h, w, v)
erased_region = torch.zeros([3, 60, 60], dtype=torch.float32)
erased_region[:, i:i + h, j:j + w] = v
Copy link
Member

Choose a reason for hiding this comment

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

Looks like erased_region is all zeros, as v is zero?

erased_region = torch.zeros([3, 60, 60], dtype=torch.float32)
erased_region[:, i:i + h, j:j + w] = v

assert torch.equal(img - img_output, erased_region)
Copy link
Member

Choose a reason for hiding this comment

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

if erased_region is all zeros, this means that img is equal to img_output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, will change the value in the tests.

@surgan12
Copy link
Contributor Author

@fmassa sure ! will make it out of place.

@surgan12 surgan12 changed the title Test Improvisations for Random Erasing Making RandomErasing Out of place by default and improvising tests for the same Jun 28, 2019
@surgan12
Copy link
Contributor Author

@fmassa ready for a review !!

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot!

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.

3 participants