View source: R/target-transforms-detection.R
| target_transform_resize | R Documentation |
Adjusts the bounding box coordinates in a detection target to match a
resized image. The target is expected to contain a boxes field with
shape (N, 4) in xyxy format and an orig_size field with the original
image dimensions (H, W).
target_transform_resize(target, size)
## S3 method for class 'object_detection_target'
target_transform_resize(target, size)
target |
An
|
size |
Desired output size. If |
This function should be composed with a transform_resize() in the
transform pipeline having the same size to ensure resized bounding boxes
remain aligned with the resized image.
A list with the same structure as the input target, where:
boxes are rescaled according to the resize factors
orig_size is updated to the new dimensions
Other target_transforms_detection:
prepare_sahi_split(),
target_transform_affine(),
target_transform_rotate()
## Not run:
target <- list(
boxes = torch_tensor(matrix(c(10, 20, 50, 60), ncol = 4)),
labels = torch_tensor(1L, dtype = torch_long()),
image_height = 100L,
image_width = 100L
)
class(target) <- c("object_detection_target", "list")
# Resize to fixed size
transform_fn <- target_transform_resize(c(200L, 200L))
new_target <- transform_fn(target)
# Resize with proportional scaling
transform_fn <- target_transform_resize(50L)
new_target <- transform_fn(target)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.