Skip to content

Implementation of contrast() seems wrong #1057

Description

@EIFY

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions