@@ -726,7 +726,7 @@ def random_pixel_value_scale(image,
726
726
727
727
Args:
728
728
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
729
- with pixel values varying between [0, 1 ].
729
+ with pixel values varying between [0, 255 ].
730
730
minval: lower ratio of scaling pixel values.
731
731
maxval: upper ratio of scaling pixel values.
732
732
seed: random seed.
@@ -749,7 +749,7 @@ def random_pixel_value_scale(image,
749
749
preprocess_vars_cache )
750
750
751
751
image = tf .multiply (image , color_coef )
752
- image = tf .clip_by_value (image , 0.0 , 1 .0 )
752
+ image = tf .clip_by_value (image , 0.0 , 255 .0 )
753
753
754
754
return image
755
755
@@ -815,7 +815,7 @@ def random_rgb_to_gray(image,
815
815
816
816
Args:
817
817
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
818
- with pixel values varying between [0, 1 ].
818
+ with pixel values varying between [0, 255 ].
819
819
probability: the probability of returning a grayscale image.
820
820
The probability should be a number between [0, 1].
821
821
seed: random seed.
@@ -852,11 +852,11 @@ def random_adjust_brightness(image,
852
852
preprocess_vars_cache = None ):
853
853
"""Randomly adjusts brightness.
854
854
855
- Makes sure the output image is still between 0 and 1 .
855
+ Makes sure the output image is still between 0 and 255 .
856
856
857
857
Args:
858
858
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
859
- with pixel values varying between [0, 1 ].
859
+ with pixel values varying between [0, 255 ].
860
860
max_delta: how much to change the brightness. A value between [0, 1).
861
861
seed: random seed.
862
862
preprocess_vars_cache: PreprocessorCache object that records previously
@@ -876,8 +876,8 @@ def random_adjust_brightness(image,
876
876
preprocessor_cache .PreprocessorCache .ADJUST_BRIGHTNESS ,
877
877
preprocess_vars_cache )
878
878
879
- image = tf .image .adjust_brightness (image , delta )
880
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
879
+ image = tf .image .adjust_brightness (image / 255 , delta ) * 255
880
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
881
881
return image
882
882
883
883
@@ -888,11 +888,11 @@ def random_adjust_contrast(image,
888
888
preprocess_vars_cache = None ):
889
889
"""Randomly adjusts contrast.
890
890
891
- Makes sure the output image is still between 0 and 1 .
891
+ Makes sure the output image is still between 0 and 255 .
892
892
893
893
Args:
894
894
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
895
- with pixel values varying between [0, 1 ].
895
+ with pixel values varying between [0, 255 ].
896
896
min_delta: see max_delta.
897
897
max_delta: how much to change the contrast. Contrast will change with a
898
898
value between min_delta and max_delta. This value will be
@@ -913,8 +913,8 @@ def random_adjust_contrast(image,
913
913
generator_func ,
914
914
preprocessor_cache .PreprocessorCache .ADJUST_CONTRAST ,
915
915
preprocess_vars_cache )
916
- image = tf .image .adjust_contrast (image , contrast_factor )
917
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
916
+ image = tf .image .adjust_contrast (image / 255 , contrast_factor ) * 255
917
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
918
918
return image
919
919
920
920
@@ -924,11 +924,11 @@ def random_adjust_hue(image,
924
924
preprocess_vars_cache = None ):
925
925
"""Randomly adjusts hue.
926
926
927
- Makes sure the output image is still between 0 and 1 .
927
+ Makes sure the output image is still between 0 and 255 .
928
928
929
929
Args:
930
930
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
931
- with pixel values varying between [0, 1 ].
931
+ with pixel values varying between [0, 255 ].
932
932
max_delta: change hue randomly with a value between 0 and max_delta.
933
933
seed: random seed.
934
934
preprocess_vars_cache: PreprocessorCache object that records previously
@@ -945,8 +945,8 @@ def random_adjust_hue(image,
945
945
delta = _get_or_create_preprocess_rand_vars (
946
946
generator_func , preprocessor_cache .PreprocessorCache .ADJUST_HUE ,
947
947
preprocess_vars_cache )
948
- image = tf .image .adjust_hue (image , delta )
949
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
948
+ image = tf .image .adjust_hue (image / 255 , delta ) * 255
949
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
950
950
return image
951
951
952
952
@@ -957,11 +957,11 @@ def random_adjust_saturation(image,
957
957
preprocess_vars_cache = None ):
958
958
"""Randomly adjusts saturation.
959
959
960
- Makes sure the output image is still between 0 and 1 .
960
+ Makes sure the output image is still between 0 and 255 .
961
961
962
962
Args:
963
963
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
964
- with pixel values varying between [0, 1 ].
964
+ with pixel values varying between [0, 255 ].
965
965
min_delta: see max_delta.
966
966
max_delta: how much to change the saturation. Saturation will change with a
967
967
value between min_delta and max_delta. This value will be
@@ -982,20 +982,20 @@ def random_adjust_saturation(image,
982
982
generator_func ,
983
983
preprocessor_cache .PreprocessorCache .ADJUST_SATURATION ,
984
984
preprocess_vars_cache )
985
- image = tf .image .adjust_saturation (image , saturation_factor )
986
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
985
+ image = tf .image .adjust_saturation (image / 255 , saturation_factor ) * 255
986
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
987
987
return image
988
988
989
989
990
990
def random_distort_color (image , color_ordering = 0 , preprocess_vars_cache = None ):
991
991
"""Randomly distorts color.
992
992
993
993
Randomly distorts color using a combination of brightness, hue, contrast
994
- and saturation changes. Makes sure the output image is still between 0 and 1 .
994
+ and saturation changes. Makes sure the output image is still between 0 and 255 .
995
995
996
996
Args:
997
997
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
998
- with pixel values varying between [0, 1 ].
998
+ with pixel values varying between [0, 255 ].
999
999
color_ordering: Python int, a type of distortion (valid values: 0, 1).
1000
1000
preprocess_vars_cache: PreprocessorCache object that records previously
1001
1001
performed augmentations. Updated in-place. If this
0 commit comments