Skip to content

Commit 2aa1729

Browse files
committed
Fix the naming issue for autoaugment.
1 parent c7e15af commit 2aa1729

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

efficientdet/aug/autoaugment.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
1717
[1] Barret, et al. Learning Data Augmentation Strategies for Object Detection.
1818
Arxiv: https://arxiv.org/abs/1906.11172
19+
20+
To use autoaugmentation, please install tensorflow_addons by running
21+
- pip install tensorflow_addons
1922
"""
2023

2124
from __future__ import absolute_import
@@ -26,12 +29,8 @@
2629
import math
2730
from absl import logging
2831
import tensorflow.compat.v1 as tf
29-
32+
from tensorflow_addons import image as tfa_image
3033
import hparams_config
31-
try:
32-
import tensorflow_addons.image as contrib_image
33-
except:
34-
import tensorflow.contrib.image as contrib_image
3534

3635

3736
# This signifies the max integer that the controller RNN could predict for the
@@ -324,7 +323,7 @@ def rotate(image, degrees, replace):
324323
# In practice, we should randomize the rotation degrees by flipping
325324
# it negatively half the time, but that's done on 'degrees' outside
326325
# of the function.
327-
image = contrib_image.rotate(wrap(image), radians)
326+
image = tfa_image.rotate(wrap(image), radians)
328327
return unwrap(image, replace)
329328

330329

@@ -879,13 +878,13 @@ def rotate_with_bboxes(image, bboxes, degrees, replace):
879878

880879
def translate_x(image, pixels, replace):
881880
"""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])
883882
return unwrap(image, replace)
884883

885884

886885
def translate_y(image, pixels, replace):
887886
"""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])
889888
return unwrap(image, replace)
890889

891890

@@ -970,7 +969,7 @@ def shear_x(image, level, replace):
970969
# with a matrix form of:
971970
# [1 level
972971
# 0 1].
973-
image = contrib_image.transform(
972+
image = tfa_image.transform(
974973
wrap(image), [1., level, 0., 0., 1., 0., 0., 0.])
975974
return unwrap(image, replace)
976975

@@ -981,7 +980,7 @@ def shear_y(image, level, replace):
981980
# with a matrix form of:
982981
# [1 0
983982
# level 1].
984-
image = contrib_image.transform(
983+
image = tfa_image.transform(
985984
wrap(image), [1., 0., 0., level, 1., 0., 0., 0.])
986985
return unwrap(image, replace)
987986

0 commit comments

Comments
 (0)