From 967fdec5afc8ee92b2fcb16eba419e82d5de6a1e Mon Sep 17 00:00:00 2001 From: alec-kr <52685467+alec-kr@users.noreply.github.com> Date: Sat, 26 Aug 2023 21:38:54 -0400 Subject: [PATCH 1/3] Add resize to transforms.py --- .../frontends/paddle/vision/transforms.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ivy/functional/frontends/paddle/vision/transforms.py b/ivy/functional/frontends/paddle/vision/transforms.py index 179262ce444a9..4ef1ee5137689 100644 --- a/ivy/functional/frontends/paddle/vision/transforms.py +++ b/ivy/functional/frontends/paddle/vision/transforms.py @@ -170,6 +170,21 @@ def normalize(img, mean, std, data_format="CHW", to_rgb=False): raise ValueError("Unsupported input format") +@with_supported_dtypes({"2.5.1 and below": ("float32", "float64", "uint8")}, "paddle") +@to_ivy_arrays_and_back +def resize(img, size, interpolation="bilinear"): + if ivy.is_array(img): + # Get the height and width of the original image + orig_height, orig_width = img.shape[-3], img.shape[-2] + + # Resize the image using Ivy's resize function + img_resized = ivy.resize(img, (orig_height * size[0], orig_width * size[1])) + + return img_resized + else: + raise ValueError("Unsupported input format") + + @with_supported_dtypes( {"2.5.1 and below": ("float32", "float64", "int32", "int64")}, "paddle" ) From 8bee326399f11b5266732fd1f97151e1665c4535 Mon Sep 17 00:00:00 2001 From: alec-kr <52685467+alec-kr@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:59:45 -0400 Subject: [PATCH 2/3] Added test for paddle resize --- .../test_vision/test_transforms.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index f869af563290a..3d1a172d0fae4 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -173,3 +173,25 @@ def test_paddle_hflip( backend_to_test=backend_fw, img=x[0], ) + +def test_paddle_resize( + *, + dtype_and_x, + size, + on_device, + fn_tree, + frontend, + test_flags, + backend_fw, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + backend_to_test=backend_fw, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + img=x[0], + size=(size, size), + ) From 144bc7b22e41a83d0eba5fcfd514abac63d06a89 Mon Sep 17 00:00:00 2001 From: alec-kr <52685467+alec-kr@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:07:58 -0400 Subject: [PATCH 3/3] Add missing decorator for test_paddle_resize function --- .../test_paddle/test_vision/test_transforms.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index ceffab9c2f1b3..5016180d19ac4 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -182,6 +182,15 @@ def test_paddle_vflip( backend_to_test=backend_fw, ) + +@handle_frontend_test( + fn_tree="paddle.vision.transforms.resize", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + shape=_chw_image_shape_helper(), + ), + size=helpers.ints(min_value=1, max_value=100), +) def test_paddle_resize( *, dtype_and_x,