Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf.image.resize/resize_with_crop_or_pad/pad_to_bounding_box/extract_glimpse crash(abort) #46890

Closed
DNXie opened this issue Feb 3, 2021 · 8 comments
Assignees
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:bug Bug

Comments

@DNXie
Copy link

DNXie commented Feb 3, 2021

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below):2.1.0
  • Python version:3.7.6
  • Bazel version (if compiling from source):N/A
  • GCC/Compiler version (if compiling from source):N/A
  • CUDA/cuDNN version:N/A
  • GPU model and memory:N/A

Describe the current behavior
The following APIs crash(abortion) when the given size is large

  • tf.image.resiz
  • tf.image.resize_with_crop_or_pad
  • tf.image.pad_to_bounding_box
  • tf.image.extract_glimpse
  • tf.keras.backend.resize_images

Describe the expected behavior
expect exception messages if the input is not expected instead of crash

Standalone code to reproduce the issue

tf.image.resize

import tensorflow as tf
import numpy as np
tf.image.resize(images=np.ones((5,5,5)), size=[2065374891,1145309325])

Output:

2021-02-03 17:41:13.484992: F tensorflow/core/framework/tensor_shape.cc:353] Check failed: 0 <= new_num_elements (0 vs. -6619278462293758741)
Aborted (core dumped)

tf.image.resize_with_crop_or_pad

import tensorflow as tf
import numpy as np
tf.image.resize_with_crop_or_pad(image=np.ones((1,1,1)), target_height=5191549470, target_width=5191549470)

Output:

2021-02-03 17:42:15.468265: F tensorflow/core/framework/tensor_shape.cc:353] Check failed: 0 <= new_num_elements (0 vs. -1)
Aborted (core dumped)

tf.image.pad_to_bounding_box

import tensorflow as tf
import numpy as np
tf.image.pad_to_bounding_box(image=np.ones((1,1,1)), target_height=5191549470, target_width=5191549470, offset_height=1, offset_width=1)

Output

2021-02-03 17:42:52.556583: F tensorflow/core/framework/tensor_shape.cc:353] Check failed: 0 <= new_num_elements (0 vs. -1)
Aborted (core dumped)

tf.image.extract_glimpse

import tensorflow as tf
import numpy as np
tf.image.extract_glimpse(input=np.ones((5,5,5,5)), size=[1574700351, 451745106], offsets=np.ones((5,2)))

Output:

2021-02-03 17:43:30.140277: F tensorflow/core/framework/tensor_shape.cc:338] Check failed: 0 <= n (0 vs. -662664649191246466)
Aborted (core dumped)

tf.keras.backend.resize_image

import tensorflow as tf
import numpy as np
tf.keras.backend.resize_images(x=np.ones((1,5,3,15)), height_factor=5628955348197345288, width_factor=5628955348197345288, data_format='channels_last')

Output:

2021-02-03 17:54:01.192819: F tensorflow/core/framework/tensor_shape.cc:353] Check failed: 0 <= new_num_elements (0 vs. -5948468124908472256)
Aborted (core dumped)
@DNXie DNXie added the type:bug Bug label Feb 3, 2021
@Saduf2019 Saduf2019 added TF 2.1 for tracking issues in 2.1 release comp:ops OPs related issues labels Feb 4, 2021
@Saduf2019
Copy link
Contributor

Saduf2019 commented Feb 4, 2021

@rmothukuru
I ran the code on tf 2.4 and nightly, colab crashes. please find the gist here

@Saduf2019 Saduf2019 assigned rmothukuru and unassigned Saduf2019 Feb 4, 2021
@rmothukuru rmothukuru added stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 labels Feb 5, 2021
@DNXie
Copy link
Author

DNXie commented Feb 5, 2021

BTW, I also find it in tf.image.crop_and_resize and tf.image.resize_with_pad

import tensorflow as tf
import numpy as np
tf.image.crop_and_resize(image=np.ones((1,1,1,1)), boxes=np.ones((11,4)), box_indices=np.ones((11)), crop_size=[2065374891,1145309325])

Output:

2021-02-05 17:02:57.884394: F tensorflow/core/framework/tensor_shape.cc:187] Non-OK-status: InitDims(dim_sizes) status: Internal: Encountered overflow when multiplying 22719123801 with 1145309325, result: -1
Aborted (core dumped)
import tensorflow as tf
import numpy as np
tf.image.resize_with_pad(image=np.ones((5,5,5)), target_height=1635057735, target_width=1635057735)

Output:

2021-02-19 22:28:03.322414: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2021-02-19 22:28:03.332536: F tensorflow/core/framework/tensor_shape.cc:353] Check failed: 0 <= new_num_elements (0 vs. -5079675089792900491)
Aborted (core dumped)

@sushreebarsa
Copy link
Contributor

Was able to reproduce the issue in TF 2.6.0-dev20210528 & colab crashes ,please find the gist here..Thanks !

@yongtang
Copy link
Member

Update:

  1. tf.image.resize fixed aleady
  2. tf.image.resize_with_crop_or_pad to be fixed (PR Fix crash of tf.image.pad_to_bounding_box with large input value. #51717)
  3. tf.image.pad_to_bounding_box to be fixed (PR Fix crash of tf.image.pad_to_bounding_box with large input value. #51717)
  4. tf.keras.backend.resize_image fixed already
  5. tf.image.crop_and_resize to be fixed (PR Fix crash of tf.image.crop_and_resize when input is large number #51732)
  6. tf.image.resize_with_pad fixed already

copybara-service bot pushed a commit that referenced this issue Aug 31, 2021
…number

Imported from GitHub PR #51732

This PR is part of the effort in #46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copybara import of the project:

--
c8d8705 by Yong Tang <yong.tang.github@outlook.com>:

Fix crash of tf.image.crop_and_resize when input is large number

This PR is part of the effort in 46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
COPYBARA_INTEGRATE_REVIEW=#51732 from yongtang:46890-tf.image.crop_and_resize c8d8705
PiperOrigin-RevId: 394109830
Change-Id: If049dad0844df9353722029ee95bc76819eda1f4
@sushreebarsa
Copy link
Contributor

@DNXie Could you please let us know if we can closed the issue with this PR ?Thank you!

@sushreebarsa sushreebarsa added the stat:awaiting response Status - Awaiting response from author label Sep 2, 2021
@mihaimaruseac
Copy link
Collaborator

There are still a few PRs that need to land here.

@sushreebarsa sushreebarsa removed the stat:awaiting response Status - Awaiting response from author label Sep 3, 2021
@sushreebarsa sushreebarsa removed the TF 2.1 for tracking issues in 2.1 release label Oct 23, 2021
@mihaimaruseac
Copy link
Collaborator

I think all of these landed

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

mihaimaruseac pushed a commit that referenced this issue Oct 28, 2021
…number

Imported from GitHub PR #51732

This PR is part of the effort in #46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copybara import of the project:

--
c8d8705 by Yong Tang <yong.tang.github@outlook.com>:

Fix crash of tf.image.crop_and_resize when input is large number

This PR is part of the effort in 46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
COPYBARA_INTEGRATE_REVIEW=#51732 from yongtang:46890-tf.image.crop_and_resize c8d8705
PiperOrigin-RevId: 394109830
Change-Id: If049dad0844df9353722029ee95bc76819eda1f4
mihaimaruseac pushed a commit that referenced this issue Oct 28, 2021
…number

Imported from GitHub PR #51732

This PR is part of the effort in #46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copybara import of the project:

--
c8d8705 by Yong Tang <yong.tang.github@outlook.com>:

Fix crash of tf.image.crop_and_resize when input is large number

This PR is part of the effort in 46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
COPYBARA_INTEGRATE_REVIEW=#51732 from yongtang:46890-tf.image.crop_and_resize c8d8705
PiperOrigin-RevId: 394109830
Change-Id: If049dad0844df9353722029ee95bc76819eda1f4
mihaimaruseac pushed a commit that referenced this issue Oct 28, 2021
…number

Imported from GitHub PR #51732

This PR is part of the effort in #46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copybara import of the project:

--
c8d8705 by Yong Tang <yong.tang.github@outlook.com>:

Fix crash of tf.image.crop_and_resize when input is large number

This PR is part of the effort in 46890 where
tf.image.crop_and_resize will crash if shape consists of large number.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
COPYBARA_INTEGRATE_REVIEW=#51732 from yongtang:46890-tf.image.crop_and_resize c8d8705
PiperOrigin-RevId: 394109830
Change-Id: If049dad0844df9353722029ee95bc76819eda1f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.4 for issues related to TF 2.4 type:bug Bug
Projects
None yet
Development

No branches or pull requests

6 participants