Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of contrast() seems wrong #1057

Open
EIFY opened this issue Jun 4, 2024 · 0 comments
Open

Implementation of contrast() seems wrong #1057

EIFY opened this issue Jun 4, 2024 · 0 comments

Comments

@EIFY
Copy link

EIFY commented Jun 4, 2024

L209 of autoaugment.py

# Compute the grayscale histogram, then compute the mean pixel value,
# and create a constant image size of that value. Use that as the
# blending degenerate target of the original image.
hist = tf.histogram_fixed_width(degenerate, [0, 255], nbins=256)
mean = tf.reduce_sum(tf.cast(hist, tf.float32)) / 256.0

and L278 of autoaugment_utils.py of the implementation of contrast()
# Compute the grayscale histogram, then compute the mean pixel value,
# and create a constant image size of that value. Use that as the
# blending degenerate target of the original image.
hist = tf.histogram_fixed_width(degenerate, [0, 255], nbins=256)
mean = tf.reduce_sum(tf.cast(hist, tf.float32)) / 256.0

seem wrong. mean is supposed to be the mean pixel value, but as it is it's just summing over the histogram (therefore equal to height * width), divided by 256. google-research/big_vision and tensorflow/models have the same bug so ideally should be fixed in the same way. See google-research/big_vision#109 for details including the manual tests I did.

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

No branches or pull requests

1 participant