Commit Graph

224 Commits

Author SHA1 Message Date
Hye Soo Yang
be10b788f7 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 15 (class PSNRTest, SSIMTest)

PiperOrigin-RevId: 338354491
Change-Id: I3a447655b93c597c2c15dcb5e8c0db39b2968fb4
2020-10-21 16:19:07 -07:00
Saurabh Saxena
f41a9a9335 Support constant folding across Arg nodes during shape inference on nested function calls.
PiperOrigin-RevId: 337992497
Change-Id: If480c605fa34def3586a62105c5517c02c2f73e6
2020-10-19 21:27:26 -07:00
TensorFlower Gardener
c031923133 Merge pull request from yongtang:42129-tf.image.crop_and_resize
PiperOrigin-RevId: 337926784
Change-Id: I64c86f53021e0588c72fcc4142b7cb8947c19d4a
2020-10-19 14:02:19 -07:00
Hye Soo Yang
de10689433 Fix DecodeImage issue where decoding animated GIF fails if first frame does not fill the canvas.
PiperOrigin-RevId: 337830066
Change-Id: Iecdf4cb7f6815f65e7abceb85b61e8d85d80fa9e
2020-10-19 04:44:25 -07:00
Mihai Maruseac
1816c43041
Merge branch 'master' into 42129-tf.image.crop_and_resize 2020-10-18 11:19:38 -07:00
Hye Soo Yang
9ef7492f43 Add checks to prevent image decoding ops from decoding with wrong op type.
More specifically,
1) Only `decode_bmp` or `decode_image` ops should be able to decode BMP data.
2) `decode_and_crop_jpeg` should only work on JPEG data.

Note: By the API, `decode_jpeg`, `decode_png` and `decode_gif` can decode any of JPEG, PNG and GIF formats.
PiperOrigin-RevId: 337546579
Change-Id: I2a9cd3271c26fc8d4099c86bfb0f84f87bdcdf87
2020-10-16 11:48:48 -07:00
Hye Soo Yang
2ef29a9389 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 12 (class JpegTest)

PiperOrigin-RevId: 333790802
Change-Id: Ia6c885bf93f51d0965200a9da426135634f98175
2020-09-25 13:12:14 -07:00
Hye Soo Yang
94e6d3349d Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 13 (class PngTest, GifTest, ConvertImageTest)

PiperOrigin-RevId: 333790780
Change-Id: I731fd63ddfc049a4b73f1ef17affdfd59c942010
2020-09-25 13:04:38 -07:00
Hye Soo Yang
63f9f9aca7 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 10 (class ResizeImageWithPadV1Test, ResizeImageWithPadV2Test)

PiperOrigin-RevId: 333566241
Change-Id: Ifddb6734ec8a2fd76573ad5f1eb2a17b310d3f0a
2020-09-24 12:11:14 -07:00
Hye Soo Yang
8fe8554a80 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 8 (class ResizeImagesV2Test)

PiperOrigin-RevId: 333565709
Change-Id: I9f6594d79d35585c1ec6b5772d988e880b3c2103
2020-09-24 12:06:55 -07:00
Hye Soo Yang
62ae8dd081 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 11 (class ResizeImageWithCropOrPadTest)

PiperOrigin-RevId: 333130228
Change-Id: Ic719dc2dc3495e37d40485673d37687c3b102299
2020-09-22 12:12:24 -07:00
Hye Soo Yang
3db52f724a Rollback of https://github.com/tensorflow/tensorflow/pull/41472. The change introduces regression. Reason is that, with the change, the decoder treats number of channels as an indicator for deciding whether to decode png images as palette based or not; if desired channel is 1, then it would decode in palette mode, it not then in rgb mode. However, this fails for grascale rgb images where there exists only 1 channel and don't want palette mode.
PiperOrigin-RevId: 330994095
Change-Id: I1e3f20266fd6d575dfa31ed736e04a1a8064ce93
2020-09-10 12:45:14 -07:00
Hye Soo Yang
5acc217811 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 9 (class ResizeImagesTest)

PiperOrigin-RevId: 329966227
Change-Id: I2b2c607727ae7e1d946d7c451851cfe0c2c7699d
2020-09-03 12:21:51 -07:00
Hye Soo Yang
75a60c70b2 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 2 (class FlipTransposeRotateTest)

PiperOrigin-RevId: 329356686
Change-Id: I8a5423f6063cc5c8d3917588f397f8020f04d713
2020-08-31 12:53:05 -07:00
Hye Soo Yang
90786174ce Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 7 (class SelectDistortedCropBoxTest)

PiperOrigin-RevId: 329355806
Change-Id: I9719362f78d816f54f40be1423d13cdb3484f757
2020-08-31 12:41:40 -07:00
Hye Soo Yang
5388285ebd Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 6 (class PadToBoundingBoxTest)

PiperOrigin-RevId: 329355523
Change-Id: I77c4ad71689e62a84f07eb39897258b26a441f5d
2020-08-31 12:37:05 -07:00
Hye Soo Yang
f717ab8219 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 4 (class CropToBoundingBoxTest)

PiperOrigin-RevId: 329346840
Change-Id: If81004c565af0f6b9c235d7fefc613f0e8b98101
2020-08-31 11:58:40 -07:00
Reed
355d6b55b2
Merge branch 'master' into tf32_test_fix 2020-08-25 10:30:06 -07:00
Yong Tang
3ade2efec2 Fix segmentation fault in tf.image.crop_and_resize when boxes is inf or nan
This fix tries to address the issue raised in 42129 where segmentation fault
happened in tf.image.crop_and_resize when boxes is inf or nan.

This fix adds the check to make sure boxes is not inf or nan (isfinite)

This fix fixes 42129.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-08-25 16:17:22 +00:00
Hye Soo Yang
dec61a8d2a Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 5 (class CentralCropTest)

PiperOrigin-RevId: 327844469
Change-Id: I721261c203fe6ec4be4c99e4584a50d47a3528c9
2020-08-21 11:38:21 -07:00
Hye Soo Yang
fdd4791c15 Eager execution coverage for image_ops_test.py. Removed run_deprecated_v1 decorators.
Part 3 (class PerImageWhiteningTest, AdjustContrastTest)

PiperOrigin-RevId: 327840359
Change-Id: I121a029fccc446f9b3d007dcbeaac71c0fe949f2
2020-08-21 11:22:25 -07:00
Hye Soo Yang
fa9564ee72 Eager execution coverage for image_ops_test.py (class AdjustGamma). Removed run_deprecated_v1 decorators. Part 1.
PiperOrigin-RevId: 327043549
Change-Id: I3e5921b9b9a01d878cc4f60333f30a3b943017ff
2020-08-17 10:11:29 -07:00
Reed
f1c1a294f1 Fix tests when TF32 is enabled 2020-08-13 21:17:36 -07:00
Hye Soo Yang
f3e8f1f3f1 Add stateless_sample_distorted_bounding_box op which is deterministic; it guarantees the same results independent of how many times the they are called, and independent of global seed settings.
PiperOrigin-RevId: 325943656
Change-Id: Ia1c3e6f95862c175dcc55be672fd878a4130f3c4
2020-08-10 20:27:13 -07:00
Hye Soo Yang
1cc134c8bf Add stateless versions for remaining tf.image.random* functions. New functions added are:
tf.image.stateless_random_brightness
tf.image.stateless_random_contrast
tf.image.stateless_random_hue
tf.image.stateless_random_saturation
tf.image.stateless_random_jpeg_quality

These functions are deterministic unlike the existing `tf.image.random*` functions, which reuse same kernel if called with the same arguments and keep internal counter. The new functions, given the same seed, guarantee the same results independent of how many times the they are called, and independent of global seed settings.

Added tests for the new stateless functions.

PiperOrigin-RevId: 324015264
Change-Id: I4bc1464d3551aeddc8046776b6edc6d50b87d0b1
2020-07-30 09:17:30 -07:00
Hye Soo Yang
d227b141aa Add tf.image.stateless_random_flip_left_right and tf.image.stateless_random_flip_up_down to tf.image ops. These functions are deterministic unlike the existing tf.image_random_flip_* functions which reuse same kernel if called with the same arguments and keep internal counter. The new functions guarantee the same results independent of how many times the they are called, and independent of global seed settings.
PiperOrigin-RevId: 323711929
Change-Id: I2f972f40607a919ea10f747167b3505df3e9aad2
2020-07-28 20:57:17 -07:00
TensorFlower Gardener
fa41a1f07a Merge pull request from yongtang:28256-tf.image.decode_png-palette
PiperOrigin-RevId: 322161866
Change-Id: I40dab744ca7d8088215665962f0a8e954aa1c19e
2020-07-20 09:52:43 -07:00
TensorFlower Gardener
4f69f62c61 Merge pull request from yongtang:40580-tf.image.flip_left_right-unknown-rank
PiperOrigin-RevId: 322161000
Change-Id: I4ef47553e2a2656d950fdb65567f04601387cd05
2020-07-20 09:44:06 -07:00
Yong Tang
f6940f2195 Change tf.constant to np.array inside generator to avoid unexpected error
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-07-16 22:22:02 +00:00
Yong Tang
fc0f5e4b11 Add palette-based png support for tf.image.decode_png
This PR tries to address the issue raised in 28256 where
tf.image.decode_png process palette-based png image
incorrectly.

The issue was an redundant call png_set_rgb_to_gray in
tensorflow/core/lib/png/png_io.cc. This PR fixes the issue.

This PR fixes 28256.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-07-16 21:57:34 +00:00
Hye Soo Yang
0859ec0386 - Fix for https://github.com/tensorflow/tensorflow/issues/40839.
`decode_bmp` has never supported decoding images with 3 channels to output 4 channels (or vice versa) when the API guarantees it.
https://www.tensorflow.org/api_docs/python/tf/io/decode_bmp
- This github issue was requesting for supporting this functionality similar to how `decode_png` is supporting it.
https://www.tensorflow.org/api_docs/python/tf/io/decode_png
- Added tests.

PiperOrigin-RevId: 319809581
Change-Id: I336901562599934ba675f19eabde435ec6047e3f
2020-07-06 10:50:42 -07:00
Gaurav Jain
016bb3fc99 Remove unnecessary eval() calls
The assertAll* statements already evaluate the arguments.

PiperOrigin-RevId: 319130109
Change-Id: I0034bdfa87a974613561a39e0d4a4223292245c7
2020-06-30 17:18:32 -07:00
Gaurav Jain
f618ab4955 Move away from deprecated asserts
- assertEquals -> assertEqual
- assertRaisesRegexp -> assertRegexpMatches
- assertRegexpMatches -> assertRegex

PiperOrigin-RevId: 319118081
Change-Id: Ieb457128522920ab55d6b69a7f244ab798a7d689
2020-06-30 16:10:22 -07:00
Hye Soo Yang
dacf32e8fd Register image decoding ops to new DecodeImageV2Op kernel. This change:
- Registers existing Decode* ops to DecodeImageV2Op kernel.
- Removes `decode_bmp_op.cc` as a newer version of its implementation exists in `decode_image_op.cc`. Removes all references to the deleted file.

PiperOrigin-RevId: 318397665
Change-Id: I30daaa535e8f99655e836d635f627cbac3086694
2020-06-25 19:44:05 -07:00
Yong Tang
6dac692f13 Convert from next(iter(dataset)) to get_single_element(dataset.take(1)) to avoid graph mode failure
Also specify the full shape to try to fix internal failure

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-06-24 18:04:04 +00:00
Yong Tang
7eed107f52 Fix error caused by incorrect rank assumption in tf.image.flip_left_right
This PR tries to address the issue raised in 40580 where an error
was thrown out when tf.image.flip_left_right process a tensor of unknown
rank.

The reason was that tf.image.flip_left_right assumes rank == 3 in case
of unknown rank.

This PR adjust to use array_ops.rank(image) to obtain the true rank
when unknown rank is present.

This PR fixes 40580.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2020-06-23 18:35:19 +00:00
Hye Soo Yang
e4d6335bcb Refactor DecodeImageOp for the purpose of removing redundant data parsing and format checks from python wrapper and having them take place only in kernels. Remove security concerns. This change:
- Creates new op kernel (`DecodeImageV2Op`) that can decode all four image formats (jpg, png, gif, bmp). `DecodeImage` is the op name. `DecodeBmpOp` is moved into `DecodeImageV2Op`. (Now we have `gen_image_ops.decode_image` as opposed to previous `decode_image` which was a pure python implementation.)
- Updates GIF decoder to take in `expand_animation` flag for decoding just one frame.
- Removes data parsing and format checking logic from python layer entirely.
- Updates magic bytes for detecting image formats.
- Replicates portions of `convert_image_dtype` functionality in kernel (for optionally converting uint8/uint16 -> float32).

PiperOrigin-RevId: 317891936
Change-Id: I84f18e053f6dad845d9f2a61e1119f4de131c85d
2020-06-23 10:25:38 -07:00
A. Unique TensorFlower
834f2bd726 Enable tf.image.ssim to run on tensor-like inputs and add SSIM name space.
PiperOrigin-RevId: 317676190
Change-Id: I08408eaf397ace235b5f50513096cbd9ba46d5a8
2020-06-22 10:41:49 -07:00
Vijay Vasudevan
86c745a112 Add more error information about the current shape that isn't correct.
PiperOrigin-RevId: 314962826
Change-Id: Ie45124beb74238bc683f45f4438df21247b299ca
2020-06-05 11:30:33 -07:00
Jinliang Wei
ad692522e7 Fixed a few bugs in non_max_suppression_padded.
Properly deal with boxes that are suppressed by score_threshold when canonicalizing coordinates.

Also suppress boxes whose score equals to the score_threshold to be compatible with previous implementation's behavior.

Computing `num_boxes_after_padding // tile_size` is moved outside of loop condition to make it easier for Grappler's constant folding optimization.

Output is always padded to max_output_size even when the input size (number of boxes) is less than max_output_size.

Properly handle inputs with dynamic shapes.

Due to issues with TFLite conversion, we set a forward compatibility window of 3 weeks. Until 2020/4/20, calling non_max_suppression_padded defaults to the old implementation.

PiperOrigin-RevId: 303791501
Change-Id: I7307634bf493e0fb971b50e71548fd97e27e2073
2020-03-30 12:10:46 -07:00
A. Unique TensorFlower
448a04e7c4 Replace non_max_suppression_padded with a new implementation that supports batched inputs. This new implementation is considerably faster than previous implementations on TPU and GPU.
PiperOrigin-RevId: 302730463
Change-Id: I3ff9a1204dc892b7c6688b6b400281ff9cd5331f
2020-03-24 13:12:38 -07:00
A. Unique TensorFlower
d3e5a16f32 Add bfloat16 support to UpSampling2D
PiperOrigin-RevId: 299891642
Change-Id: Iff74ea78c21cbf63fa1342a16dfad93f6c8c94a0
2020-03-09 11:49:23 -07:00
A. Unique TensorFlower
06a2520ab0 Add bfloat16 support to UpSampling2D
PiperOrigin-RevId: 299251968
Change-Id: I8c579200060780762f993c1df8656440e3742861
2020-03-05 19:12:13 -08:00
A. Unique TensorFlower
3dfef3632b Add bfloat16 support to UpSampling2D
PiperOrigin-RevId: 299247191
Change-Id: I6365c5c9c8eecc24aca82ff480680fe1e602151b
2020-03-05 18:37:07 -08:00
TensorFlower Gardener
97dbd5d7d4 Merge pull request from fsx950223:fix_image
PiperOrigin-RevId: 299116503
Change-Id: I2e9a2b86d39d088bc4c70e0fd7114e5918910325
2020-03-05 09:11:01 -08:00
fsx950223
37e00a3454 convert sixe to tensor 2020-03-04 09:10:56 +08:00
fsx950223
82f4a2e82f refact test case 2020-03-03 10:05:47 +08:00
fsx950223
c9415ea5dd fix test 2020-03-03 09:53:46 +08:00
fsx950223
59d372a825 add test case 2020-02-27 16:20:00 +08:00
A. Unique TensorFlower
525e091431 Internal change
PiperOrigin-RevId: 297466825
Change-Id: I8f4990d992478b4783c00119e4c1a23cff699d81
2020-02-26 16:38:57 -08:00