Skip to content

Feat: item transform resize - #380

Merged
cregouby merged 7 commits into
mlverse:mainfrom
srishtiii28:feat/item_transform_resize
Aug 22, 2026
Merged

Feat: item transform resize#380
cregouby merged 7 commits into
mlverse:mainfrom
srishtiii28:feat/item_transform_resize

Conversation

@srishtiii28

Copy link
Copy Markdown
Contributor

Closes #362

Added item_transform_resize for detection item, dataset and segmentation item dataset. The boxes are rescaled by the factors actually applied to the image and masks are resized with nearest-neighbour sampling so their discrete values are preserved.

srishtiii28 and others added 5 commits August 10, 2026 00:06
# Conflicts:
#	NAMESPACE
#	NEWS.md
#	R/item-transforms-geometry.R
#	man/item_transform_center_crop.Rd
#	man/item_transform_hflip.Rd
#	man/item_transform_rotate.Rd
#	man/item_transform_vflip.Rd
#	tests/testthat/test-item-transforms-geometry.R

@cregouby cregouby left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise a very important transform. Thanks !
todo few simple changes.

expect_equal(result$y$image_height, 100L)
expect_equal(result$y$image_width, 200L)
expect_true(torch_equal(result$x, transform_resize(original_img, size = c(100L, 200L))))
expect_equal_to_r(result$y$boxes[1, ], c(60, 35, 90, 65))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_equal_to_r(result$y$boxes[1, ], c(60, 35, 90, 65))
expect_equal_to_r(result$y$boxes[1, ], boxes / 2)

Comment on lines +1399 to +1407
boxes <- matrix(c(120, 70, 180, 130), ncol = 4)
item <- make_detection_item(boxes, image_size = c(200L, 400L))

result <- item_transform_resize(item, size = 100)

expect_tensor_shape(result$x, c(3, 100, 200))
expect_equal(result$y$image_height, 100L)
expect_equal(result$y$image_width, 200L)
expect_equal_to_r(result$y$boxes[1, ], c(60, 35, 90, 65))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo duplicated This is a duplicate of L1362-L1375. Please remove
suggestion you may integrate this test title in as a comment into the previous.

expect_equal(result$y$image_height, 100L)
expect_equal(result$y$image_width, 200L)
expect_true(torch_equal(result$x, transform_resize(original_img, size = c(100L, 200L))))
expect_equal_to_r(result$y$boxes[1, ], c(60, 35, 90, 65))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect_equal_to_r(result$y$boxes[1, ], c(60, 35, 90, 65))
expect_equal_to_r(result$y$boxes[1, ], boxes / 2)

Comment thread R/item-transforms-geometry.R Outdated
Comment on lines +1114 to +1115
item_transform_resize.image_with_rotated_box <- function(x, size, interpolation = 2) {
item_transform_resize.image_with_bounding_box(x, size = size, interpolation = interpolation)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo Could be even more simpler :

Suggested change
item_transform_resize.image_with_rotated_box <- function(x, size, interpolation = 2) {
item_transform_resize.image_with_bounding_box(x, size = size, interpolation = interpolation)
item_transform_resize.image_with_rotated_box <- item_transform_resize.image_with_bounding_box

@srishtiii28 srishtiii28 changed the title item transform resize Feat: item transform resize Aug 12, 2026
@srishtiii28
srishtiii28 requested a review from cregouby August 18, 2026 15:26
@cregouby
cregouby merged commit bea807a into mlverse:main Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add item_transform_resize

2 participants