File tree Expand file tree Collapse file tree 1 file changed +1
-13
lines changed
algoperf/workloads/imagenet_resnet/imagenet_jax Expand file tree Collapse file tree 1 file changed +1
-13
lines changed Original file line number Diff line number Diff line change @@ -133,19 +133,7 @@ def color(image, factor):
133
133
134
134
def contrast (image , factor ):
135
135
"""Equivalent of PIL Contrast."""
136
- degenerate = tf .image .rgb_to_grayscale (image )
137
- # Cast before calling tf.histogram.
138
- degenerate = tf .cast (degenerate , tf .int32 )
139
-
140
- # Compute the grayscale histogram, then compute the mean pixel value,
141
- # and create a constant image size of that value. Use that as the
142
- # blending degenerate target of the original image.
143
- hist = tf .histogram_fixed_width (degenerate , [0 , 255 ], nbins = 256 )
144
- mean = tf .reduce_sum (tf .cast (hist , tf .float32 )) / 256.0
145
- degenerate = tf .ones_like (degenerate , dtype = tf .float32 ) * mean
146
- degenerate = tf .clip_by_value (degenerate , 0.0 , 255.0 )
147
- degenerate = tf .image .grayscale_to_rgb (tf .cast (degenerate , tf .uint8 ))
148
- return blend (degenerate , image , factor )
136
+ return tf .image .adjust_contrast (image , factor )
149
137
150
138
151
139
def brightness (image , factor ):
You can’t perform that action at this time.
0 commit comments