Feat: item transform resize - #380
Merged
Merged
Conversation
# 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
requested changes
Aug 10, 2026
| 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)) |
Collaborator
There was a problem hiding this comment.
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)) |
Collaborator
There was a problem hiding this comment.
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)) |
Collaborator
There was a problem hiding this comment.
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
+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) |
Collaborator
There was a problem hiding this comment.
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #362
Added
item_transform_resizefor 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.