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

Add resize to transforms.py #22634

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ivy/functional/frontends/paddle/vision/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,34 @@ def test_paddle_vflip(
img=x[0],
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,
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),
)
Loading