Fix the bug of overflow in AutoContrast #643
Open
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.
Bug description
Fix the bug of data overflow in
AutoContrast
function when applyingRandaugment
. See this issue.Commit explanation
The root cause is the overflow caused by
np.uint8
. Specifically, inL40
of the following code:LAVIS/lavis/processors/randaugment.py
Lines 19 to 49 in ac8fc98
where
ch
is one channel of an image (thus typenp.uint8
), andlow
is of typenp.uint8
. Thereforeoffset = -low * scale
will cause an overflow since it cannot represent a negative number.The reason why this bug did not affect much on the performance is:
low
is0
most of the time.