View source: R/item-transforms-geometry.R
| item_transform_vflip | R Documentation |
Flips the image inside a dataset item vertically. For detection items, bounding box y-coordinates are adjusted to remain correct after the flip. For segmentation items, both the image and the masks are flipped.
item_transform_vflip(x)
x |
A dataset item, typically an |
A dataset item of the same class with the image and target vertically flipped.
Other item_unitary_transforms:
item_transform_affine(),
item_transform_center_crop(),
item_transform_crop(),
item_transform_hflip(),
item_transform_pad(),
item_transform_perspective(),
item_transform_resize(),
item_transform_rotate()
## Not run:
url <- "https://upload.wikimedia.org/wikipedia/commons/b/b6/Felis_catus-cat_on_snow.jpg"
img <- base_loader(url) |> transform_to_tensor()
boxes <- torch_tensor(matrix(c(600, 200, 2880, 1860), ncol = 4), dtype = torch_float32())
before <- list(x = img, y = list(boxes = boxes, labels = "cat"))
class(before) <- c("image_with_bounding_box", "list")
after <- item_transform_vflip(before)
before_plot <- draw_bounding_boxes(before, colors = "blue", width = 10)
after_plot <- draw_bounding_boxes(after, colors = "red", width = 10)
tensor_image_browse(vision_make_grid(before_plot, after_plot, scale = TRUE))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.