Open smedegaard opened 3 years ago
https://github.com/keras-team/keras-preprocessing/blob/2310b4e4709a1e32095a6159b4c6defeba897e24/keras_preprocessing/image/affine_transformations.py#L325
I tried to apply random rotation on a tiff with shape (120,120,4) with the following function:
(120,120,4)
def augment_image(image, label): image = tf.keras.preprocessing.image.random_rotation( image, 180, row_axis=0, col_axis=1, channel_axis=2 ) image = tf.image.flip_left_right(image) image = tf.image.random_flip_up_down(image) return image, label
resulting in
AttributeError: in user code: /home/jupyter/sentinel2model/trainer/util.py:37 augment_image * image = tf.keras.preprocessing.image.random_rotation( /opt/conda/lib/python3.7/site-packages/keras_preprocessing/image/affine_transformations.py:56 random_rotation * x = apply_affine_transform(x, theta=theta, channel_axis=channel_axis, /opt/conda/lib/python3.7/site-packages/keras_preprocessing/image/affine_transformations.py:323 apply_affine_transform * x = np.rollaxis(x, channel_axis, 0) <__array_function__ internals>:6 rollaxis ** /opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py:1259 rollaxis n = a.ndim AttributeError: 'Tensor' object has no attribute 'ndim'
AttributeError: in user code:
/home/jupyter/sentinel2model/trainer/util.py:37 augment_image * image = tf.keras.preprocessing.image.random_rotation( /opt/conda/lib/python3.7/site-packages/keras_preprocessing/image/affine_transformations.py:56 random_rotation * x = apply_affine_transform(x, theta=theta, channel_axis=channel_axis, /opt/conda/lib/python3.7/site-packages/keras_preprocessing/image/affine_transformations.py:323 apply_affine_transform * x = np.rollaxis(x, channel_axis, 0) <__array_function__ internals>:6 rollaxis ** /opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py:1259 rollaxis n = a.ndim AttributeError: 'Tensor' object has no attribute 'ndim'
As far as I can see apply_affine_transform() does not convert the tf.Tensor to a np.Array and thus lacks the ndim attribute.
apply_affine_transform()
tf.Tensor
np.Array
ndim
I'm I misunderstanding something?
Kind regards, Anders
https://github.com/keras-team/keras-preprocessing/blob/2310b4e4709a1e32095a6159b4c6defeba897e24/keras_preprocessing/image/affine_transformations.py#L325
I tried to apply random rotation on a tiff with shape
(120,120,4)
with the following function:resulting in
As far as I can see
apply_affine_transform()
does not convert thetf.Tensor
to anp.Array
and thus lacks thendim
attribute.I'm I misunderstanding something?
Kind regards, Anders