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.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.value new_width_const = size_const_as_shape.dims.value
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.
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.