Removed the +1 and divide by 2 to allow for random offset padding #564
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In reference to Issue #562
I learned that RandomCrop, when you set
pad_if_needed
toTrue
does not RandomPad. a-la, whereas random crop applies a crop at a random offset to the image, pad_if_needed performs a centered padding, which does not randomly place the image in the padded image. The goal for this method, regardless of whether or not the image is too big or too small, is that the resulting image should be the right size, contain as much of the image as possible, and at random offset.Imagine the image, whatever size, on an infinite canvas.
Apply a random offset, and a random crop, to that canvas, such that:
if the crop is bigger than the original image, all of the original image remains in the output.
if the crop is smaller than the original image, all of the output is part of the original image.
The fix is just to pad the image by double the previous amount, such that there is enough padding for the random cropping function to apply the offset.