addons icon indicating copy to clipboard operation
addons copied to clipboard

tfa.rotate() doesn't work in tf.data.Dataset.map()

Open nicolas-gervais opened this issue 3 years ago • 5 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • TensorFlow version and how it was installed (source or binary): 2.3 binary
  • TensorFlow-Addons version and how it was installed (source or binary): 0.13.0 binary
  • Python version: 3.8.1
  • Is GPU used? (yes/no): yes

Describe the bug

tfa.image.rotate() doesn't work in tf.data.Dataset.map()

Code to reproduce the issue

import tensorflow as tf
import tensorflow_addons as tfa
import tensorflow_datasets as tfds

mnist = tfds.load('mnist', split='test', as_supervised=True)

ds = mnist.map(lambda x, y: (tfa.image.rotate(x, 10), y))

NotImplementedError: Cannot convert a symbolic Tensor (rotate/angles_to_projective_transforms/strided_slice_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

nicolas-gervais avatar Jul 22 '21 21:07 nicolas-gervais

Can you try with this: https://github.com/tensorflow/models/blob/master/official/vision/beta/ops/augment.py#L190:L218

bhack avatar Jul 23 '21 20:07 bhack

/cc @yarri-oss @theadactyl At some point we could handle these duplicates in the ecosystem.

bhack avatar Jul 23 '21 23:07 bhack

+1 for putting a process together to catch such duplication issues. I know Sean wanted to discuss this. I wonder if we could create a pre-submit test for this somehow?

On Fri, Jul 23, 2021 at 4:24 PM bhack @.***> wrote:

/cc @yarri-oss https://github.com/yarri-oss @theadactyl https://github.com/theadactyl At some point we could handle these duplicates in the ecosystem.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tensorflow/addons/issues/2529#issuecomment-885959402, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATUWYYZCJ2O7SXNSJKCMHPTTZH2Z3ANCNFSM5A2ZJKYA .

yarri-oss avatar Jul 24 '21 00:07 yarri-oss

!pip install -U tf-models-official

import tensorflow as tf
from official.vision.beta.ops import augment as tfm
import tensorflow_datasets as tfds

mnist = tfds.load('mnist', split='test', as_supervised=True)
ds = mnist.map(lambda x, y: (tfm.rotate(x, 10), y))

bhack avatar Jul 28 '21 00:07 bhack

I found this while searching how to use tfa.image.rotate. I tried this using tensorflow==2.6.0 and tensorflow-addons==0.14.0 but I cannot reproduce this issue.

colab link: https://colab.research.google.com/drive/1MsywxouFx2Ikfh0nO-svjgeYgePdBarB?usp=sharing

jeongukjae avatar Sep 02 '21 06:09 jeongukjae

TensorFlow Addons is transitioning to a minimal maintenance and release mode. New features will not be added to this repository. For more information, please see our public messaging on this decision: TensorFlow Addons Wind Down

Please consider sending feature requests / contributions to other repositories in the TF community with a similar charters to TFA: Keras Keras-CV Keras-NLP

seanpmorgan avatar Mar 01 '23 04:03 seanpmorgan