@@ -736,7 +736,7 @@ def random_pixel_value_scale(image,
736
736
737
737
Args:
738
738
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
739
- with pixel values varying between [0, 1 ].
739
+ with pixel values varying between [0, 255 ].
740
740
minval: lower ratio of scaling pixel values.
741
741
maxval: upper ratio of scaling pixel values.
742
742
seed: random seed.
@@ -759,7 +759,7 @@ def random_pixel_value_scale(image,
759
759
preprocess_vars_cache )
760
760
761
761
image = tf .multiply (image , color_coef )
762
- image = tf .clip_by_value (image , 0.0 , 1 .0 )
762
+ image = tf .clip_by_value (image , 0.0 , 255 .0 )
763
763
764
764
return image
765
765
@@ -825,7 +825,7 @@ def random_rgb_to_gray(image,
825
825
826
826
Args:
827
827
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
828
- with pixel values varying between [0, 1 ].
828
+ with pixel values varying between [0, 255 ].
829
829
probability: the probability of returning a grayscale image.
830
830
The probability should be a number between [0, 1].
831
831
seed: random seed.
@@ -862,11 +862,11 @@ def random_adjust_brightness(image,
862
862
preprocess_vars_cache = None ):
863
863
"""Randomly adjusts brightness.
864
864
865
- Makes sure the output image is still between 0 and 1 .
865
+ Makes sure the output image is still between 0 and 255 .
866
866
867
867
Args:
868
868
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
869
- with pixel values varying between [0, 1 ].
869
+ with pixel values varying between [0, 255 ].
870
870
max_delta: how much to change the brightness. A value between [0, 1).
871
871
seed: random seed.
872
872
preprocess_vars_cache: PreprocessorCache object that records previously
@@ -886,8 +886,8 @@ def random_adjust_brightness(image,
886
886
preprocessor_cache .PreprocessorCache .ADJUST_BRIGHTNESS ,
887
887
preprocess_vars_cache )
888
888
889
- image = tf .image .adjust_brightness (image , delta )
890
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
889
+ image = tf .image .adjust_brightness (image / 255 , delta ) * 255
890
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
891
891
return image
892
892
893
893
@@ -898,11 +898,11 @@ def random_adjust_contrast(image,
898
898
preprocess_vars_cache = None ):
899
899
"""Randomly adjusts contrast.
900
900
901
- Makes sure the output image is still between 0 and 1 .
901
+ Makes sure the output image is still between 0 and 255 .
902
902
903
903
Args:
904
904
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
905
- with pixel values varying between [0, 1 ].
905
+ with pixel values varying between [0, 255 ].
906
906
min_delta: see max_delta.
907
907
max_delta: how much to change the contrast. Contrast will change with a
908
908
value between min_delta and max_delta. This value will be
@@ -923,8 +923,8 @@ def random_adjust_contrast(image,
923
923
generator_func ,
924
924
preprocessor_cache .PreprocessorCache .ADJUST_CONTRAST ,
925
925
preprocess_vars_cache )
926
- image = tf .image .adjust_contrast (image , contrast_factor )
927
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
926
+ image = tf .image .adjust_contrast (image / 255 , contrast_factor ) * 255
927
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
928
928
return image
929
929
930
930
@@ -934,11 +934,11 @@ def random_adjust_hue(image,
934
934
preprocess_vars_cache = None ):
935
935
"""Randomly adjusts hue.
936
936
937
- Makes sure the output image is still between 0 and 1 .
937
+ Makes sure the output image is still between 0 and 255 .
938
938
939
939
Args:
940
940
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
941
- with pixel values varying between [0, 1 ].
941
+ with pixel values varying between [0, 255 ].
942
942
max_delta: change hue randomly with a value between 0 and max_delta.
943
943
seed: random seed.
944
944
preprocess_vars_cache: PreprocessorCache object that records previously
@@ -955,8 +955,8 @@ def random_adjust_hue(image,
955
955
delta = _get_or_create_preprocess_rand_vars (
956
956
generator_func , preprocessor_cache .PreprocessorCache .ADJUST_HUE ,
957
957
preprocess_vars_cache )
958
- image = tf .image .adjust_hue (image , delta )
959
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
958
+ image = tf .image .adjust_hue (image / 255 , delta ) * 255
959
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
960
960
return image
961
961
962
962
@@ -967,11 +967,11 @@ def random_adjust_saturation(image,
967
967
preprocess_vars_cache = None ):
968
968
"""Randomly adjusts saturation.
969
969
970
- Makes sure the output image is still between 0 and 1 .
970
+ Makes sure the output image is still between 0 and 255 .
971
971
972
972
Args:
973
973
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
974
- with pixel values varying between [0, 1 ].
974
+ with pixel values varying between [0, 255 ].
975
975
min_delta: see max_delta.
976
976
max_delta: how much to change the saturation. Saturation will change with a
977
977
value between min_delta and max_delta. This value will be
@@ -992,20 +992,20 @@ def random_adjust_saturation(image,
992
992
generator_func ,
993
993
preprocessor_cache .PreprocessorCache .ADJUST_SATURATION ,
994
994
preprocess_vars_cache )
995
- image = tf .image .adjust_saturation (image , saturation_factor )
996
- image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 1 .0 )
995
+ image = tf .image .adjust_saturation (image / 255 , saturation_factor ) * 255
996
+ image = tf .clip_by_value (image , clip_value_min = 0.0 , clip_value_max = 255 .0 )
997
997
return image
998
998
999
999
1000
1000
def random_distort_color (image , color_ordering = 0 , preprocess_vars_cache = None ):
1001
1001
"""Randomly distorts color.
1002
1002
1003
1003
Randomly distorts color using a combination of brightness, hue, contrast
1004
- and saturation changes. Makes sure the output image is still between 0 and 1 .
1004
+ and saturation changes. Makes sure the output image is still between 0 and 255 .
1005
1005
1006
1006
Args:
1007
1007
image: rank 3 float32 tensor contains 1 image -> [height, width, channels]
1008
- with pixel values varying between [0, 1 ].
1008
+ with pixel values varying between [0, 255 ].
1009
1009
color_ordering: Python int, a type of distortion (valid values: 0, 1).
1010
1010
preprocess_vars_cache: PreprocessorCache object that records previously
1011
1011
performed augmentations. Updated in-place. If this
0 commit comments