Skip to content

Feat: Add roi_align_rotated - #36

Open
DerrickUnleashed wants to merge 4 commits into
mlverse:mainfrom
DerrickUnleashed:feat/roiAlignedRotate
Open

Feat: Add roi_align_rotated#36
DerrickUnleashed wants to merge 4 commits into
mlverse:mainfrom
DerrickUnleashed:feat/roiAlignedRotate

Conversation

@DerrickUnleashed

Copy link
Copy Markdown

Adds ops_roi_align_rotated() / nn_roi_align_rotated(), a CPU RoI align pooling op for rotated boxes, ported from mmcv (Apache-2.0). Includes dispatcher + autograd kernels, R API + docs, and tests.

Closes #32

@DerrickUnleashed

Copy link
Copy Markdown
Author
url <- "https://upload.wikimedia.org/wikipedia/commons/b/b6/Felis_catus-cat_on_snow.jpg"
arr <- base_loader(url)                           
input <- torch_tensor(arr)$permute(c(3, 1, 2))$unsqueeze(1)     

size <- get_image_size(input)
H <- size[2]/2; W <- size[1]/2
rois <- torch_tensor(matrix(c(
  0, 3*W/2, 3*H/2, W, H, pi,
  0, W/2,   3*H/2, W, H, pi,
  0, 3*W/2, H/2, W, H, pi,
  0, W/2,   H/2, W, H, pi
), ncol = 6, byrow = TRUE), dtype = torch_float32())

out <- ops_roi_align_rotated(input, rois, c(128, 128), spatial_scale = 1, sampling_ratio = 2)

grid <- vision_make_grid(out, num_rows = 2, padding = 6, pad_value = 1)

tensor_image_browse(grid)   
file339407cbfb

@DerrickUnleashed
DerrickUnleashed marked this pull request as ready for review August 2, 2026 21:13
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.

implement roi_aligned_rotated

1 participant