Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
0eeeaf98
Commit
0eeeaf98
authored
Aug 27, 2021
by
Simon Geisler
Browse files
test: saturation
parent
784cbc7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
official/vision/beta/ops/preprocess_ops.py
official/vision/beta/ops/preprocess_ops.py
+8
-2
official/vision/beta/ops/preprocess_ops_test.py
official/vision/beta/ops/preprocess_ops_test.py
+8
-0
No files found.
official/vision/beta/ops/preprocess_ops.py
View file @
0eeeaf98
...
...
@@ -638,5 +638,11 @@ def random_saturation(image: tf.Tensor, saturation: Optional[float] = 0.,
assert
saturation
>=
0
,
'`saturation` must be positive'
saturation
=
tf
.
random
.
uniform
(
[],
max
(
0
,
1
-
saturation
),
1
+
saturation
,
seed
=
seed
,
dtype
=
tf
.
float32
)
return
augment
.
blend
(
tf
.
repeat
(
tf
.
image
.
rgb_to_grayscale
(
image
),
3
,
axis
=-
1
),
image
,
saturation
)
return
_saturation
(
image
,
saturation
)
def
_saturation
(
image
:
tf
.
Tensor
,
saturation
:
Optional
[
float
]
=
0.
)
->
tf
.
Tensor
:
return
augment
.
blend
(
tf
.
repeat
(
tf
.
image
.
rgb_to_grayscale
(
image
),
3
,
axis
=-
1
),
image
,
saturation
)
official/vision/beta/ops/preprocess_ops_test.py
View file @
0eeeaf98
...
...
@@ -235,6 +235,14 @@ class InputUtilsTest(parameterized.TestCase, tf.test.TestCase):
image
,
color_jitter
,
color_jitter
,
color_jitter
)
assert
jittered_image
.
shape
==
image
.
shape
@
parameterized
.
parameters
(
(
400
,
600
,
0
),
(
400
,
600
,
0.4
),
(
600
,
400
,
1
)
)
def
testSaturation
(
self
,
input_height
,
input_width
,
saturation
):
image
=
tf
.
convert_to_tensor
(
np
.
random
.
rand
(
input_height
,
input_width
,
3
))
jittered_image
=
preprocess_ops
.
_saturation
(
image
,
saturation
)
assert
jittered_image
.
shape
==
image
.
shape
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment