profile
viewpoint

Ask questionsTF1 tf.image.resize_image does not work with unbatched variable size image anymore since 1.12

(Sorry for not adhering to the template, I can point to the problematic commit)

I use tf.image.resize_images to resize variable sized images in an unbatched manner, like so:

tf.image.resize_images(
            tf.reshape(x, [-1, 100, 3]),
            size,
            method=tf.image.ResizeMethod.BILINEAR
        )

I.e. some images are 100x100, some 110x100 etc. Upon updating tensorflow I received the following error:

Traceback (most recent call last):
[...]
  File "data_preprocess_amass.py", line 32, in __init__
    method=tf.image.ResizeMethod.BILINEAR
  File "/mnt/HDD1/julian/anaconda3/envs/tensorflow/lib/python3.7/site-packages/tensorflow_core/python/ops/image_ops_impl.py", line 1187, in resize_images
    skip_resize_if_same=True)
  File "/mnt/HDD1/julian/anaconda3/envs/tensorflow/lib/python3.7/site-packages/tensorflow_core/python/ops/image_ops_impl.py", line 1053, in _resize_images_common
    new_height_const = size_const_as_shape.dims[0].value
TypeError: 'NoneType' object is not subscriptable

I investigated it and it seems that the commit f43d458a318d4d97298710654f1692f6e8364f82 is the culprit, introducing the following lines to image_ops_impl.py:

new_height_const = size_const_as_shape.dims[0].value
new_width_const = size_const_as_shape.dims[1].value

blame: https://github.com/tensorflow/tensorflow/blame/r1.15/tensorflow/python/ops/image_ops_impl.py#L1053

It is included since 1.12.1. Downgrading to 1.11 solved it for me. Might be a very special use case on a already deprecated function but I thought its worth reporting.

tensorflow/tensorflow

Answer questions hyeygit

The issue was that the line with the error was not v1/v2 TensorShape backwards compatible. It should be fixed at head now. I’ve verified it with tf-nightly version 2.3.0-dev20200515.

On older branches, we unfortunately need to wait until the next patch release to cherrypick it in (note: supported versions are 1.5, 2.0, 2.1, 2.2). If you need to work with TF versions >= 1.13 and <= 2.2, one interim possibility would be to build tf from source with the two liner fix.

useful!

Related questions

ModuleNotFoundError: No module named 'tensorflow.contrib' hot 8
Error occurred when finalizing GeneratorDataset iterator hot 6
ModuleNotFoundError: No module named 'tensorflow.contrib'
When importing TensorFlow, error loading Hadoop
tensorflow-gpu CUPTI errors hot 4
[TF 2.0] tf.keras.optimizers.Adam hot 4
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 4
TF2.0 AutoGraph issue hot 4
Tf.Keras metrics issue hot 4
module 'tensorflow' has no attribute 'ConfigProto' hot 4
TF 2.0 'Tensor' object has no attribute 'numpy' while using .numpy() although eager execution enabled by default hot 4
ModuleNotFoundError: No module named 'tensorflow.examples.tutorials' hot 4
AttributeError: module &#39;tensorflow.python.framework.op_def_registry&#39; has no attribute &#39;register_op_list&#39; hot 4
tf.keras.layers.Conv1DTranspose ? hot 4
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 3
Github User Rank List