16
16
17
17
[1] Barret, et al. Learning Data Augmentation Strategies for Object Detection.
18
18
Arxiv: https://arxiv.org/abs/1906.11172
19
+
20
+ To use autoaugmentation, please install tensorflow_addons by running
21
+ - pip install tensorflow_addons
19
22
"""
20
23
21
24
from __future__ import absolute_import
26
29
import math
27
30
from absl import logging
28
31
import tensorflow .compat .v1 as tf
29
-
32
+ from tensorflow_addons import image as tfa_image
30
33
import hparams_config
31
- try :
32
- import tensorflow_addons .image as contrib_image
33
- except :
34
- import tensorflow .contrib .image as contrib_image
35
34
36
35
37
36
# This signifies the max integer that the controller RNN could predict for the
@@ -324,7 +323,7 @@ def rotate(image, degrees, replace):
324
323
# In practice, we should randomize the rotation degrees by flipping
325
324
# it negatively half the time, but that's done on 'degrees' outside
326
325
# of the function.
327
- image = contrib_image .rotate (wrap (image ), radians )
326
+ image = tfa_image .rotate (wrap (image ), radians )
328
327
return unwrap (image , replace )
329
328
330
329
@@ -879,13 +878,13 @@ def rotate_with_bboxes(image, bboxes, degrees, replace):
879
878
880
879
def translate_x (image , pixels , replace ):
881
880
"""Equivalent of PIL Translate in X dimension."""
882
- image = contrib_image .translate (wrap (image ), [- pixels , 0 ])
881
+ image = tfa_image .translate (wrap (image ), [- pixels , 0 ])
883
882
return unwrap (image , replace )
884
883
885
884
886
885
def translate_y (image , pixels , replace ):
887
886
"""Equivalent of PIL Translate in Y dimension."""
888
- image = contrib_image .translate (wrap (image ), [0 , - pixels ])
887
+ image = tfa_image .translate (wrap (image ), [0 , - pixels ])
889
888
return unwrap (image , replace )
890
889
891
890
@@ -970,7 +969,7 @@ def shear_x(image, level, replace):
970
969
# with a matrix form of:
971
970
# [1 level
972
971
# 0 1].
973
- image = contrib_image .transform (
972
+ image = tfa_image .transform (
974
973
wrap (image ), [1. , level , 0. , 0. , 1. , 0. , 0. , 0. ])
975
974
return unwrap (image , replace )
976
975
@@ -981,7 +980,7 @@ def shear_y(image, level, replace):
981
980
# with a matrix form of:
982
981
# [1 0
983
982
# level 1].
984
- image = contrib_image .transform (
983
+ image = tfa_image .transform (
985
984
wrap (image ), [1. , 0. , 0. , level , 1. , 0. , 0. , 0. ])
986
985
return unwrap (image , replace )
987
986
0 commit comments