Skip to content

tf.image.resize_with_pad raises InvalidArgumentError but the behavior is not documented #56333

@kyamagu

Description

@kyamagu
Click to expand!

Issue Type

Documentation Bug

Source

binary

Tensorflow Version

v2.9.0-18-gd8ce9f9c301 2.9.1

Custom Code

No

OS Platform and Distribution

macOS 12.4

Mobile device

No response

Python version

3.9

Bazel version

No response

GCC/Compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

The documentation only states `tf.image.resize_with_pad` raises `ValueError`.
https://www.tensorflow.org/api_docs/python/tf/image/resize_with_pad#raises

The function actually raises `InvalidArgumentError` if the resized image becomes too small (zero width or zero height). The function should raise a `ValueError` corresponding to this situation, or at least document that the function raises `InvalidArgumentError`.

The same applies `tf.image.resize` with `preserve_aspect_ratio=True`.

Standalone code to reproduce the issue

import tensorflow as tf
tf.image.resize_with_pad(tf.ones((1, 100, 1)), target_height=10, target_width=10)


### Relevant log output

```shell
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
/var/folders/xx/0bq30ljn7dz9055_2f5kd2csqm1fwc/T/ipykernel_41817/1900687440.py in <module>
----> 1 tf.image.resize_with_pad(tf.ones((1, 100, 1)), target_height=10, target_width=10)

~/projects/ailab-psd-processing/.venv/lib/python3.7/site-packages/tensorflow/python/util/traceback_utils.py in error_handler(*args, **kwargs)
    151     except Exception as e:
    152       filtered_tb = _process_traceback_frames(e.__traceback__)
--> 153       raise e.with_traceback(filtered_tb) from None
    154     finally:
    155       del filtered_tb

~/projects/ailab-psd-processing/.venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   7162 def raise_from_not_ok_status(e, name):
   7163   e.message += (" name: " + name if name is not None else "")
-> 7164   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   7165 
   7166 

InvalidArgumentError: output dimensions must be positive [Op:ResizeBilinear]
</details>

Metadata

Metadata

Labels

comp:opsOPs related issuesstaleThis label marks the issue/pr stale - to be closed automatically if no activitystat:awaiting responseStatus - Awaiting response from authortype:docs-bugDocument issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions