Skip to content

Add Visualization utilities article - #397

Closed
srishtiii28 wants to merge 1 commit into
mlverse:mainfrom
srishtiii28:feat/vignette-visualization-utils
Closed

Add Visualization utilities article#397
srishtiii28 wants to merge 1 commit into
mlverse:mainfrom
srishtiii28:feat/vignette-visualization-utils

Conversation

@srishtiii28

@srishtiii28 srishtiii28 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fix #383.

Adds a Visualization utilities article mirroring PyTorch's tutorial: vision_make_grid(), draw_bounding_boxes() with RF-DETR, draw_segmentation_masks() with FCN ResNet-50, and draw_keypoints().

Fix #113

@srishtiii28

Copy link
Copy Markdown
Contributor Author

Instance segmentation is left out here because Mask R-CNN's masks never cross the 0.5 threshold, so the figures come out blank. Should I work on fixing that? @cregouby

@cregouby

cregouby commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Yes, both Mask R-CNN and Faster R-CNN are very sensitive to score threshold and nms threshold (see examples or each function).
Please open an issue with it, and then you may fix it.

@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 Very nice vignette, thank you !
todo see inline

quick way to eyeball a batch coming out of a `dataloader()`.

```{r}
grid <- vision_make_grid(torch_stack(list(dog1, dog2)), num_rows = 2)

@cregouby cregouby Aug 26, 2026

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.

thought Should we wait for #394 Solution 2 available in #398 and have a nice looking grid <- vision_make_grid(dog1, dog2, num_rows = 2) ?

c(210, 150, 350, 430)
), dtype = torch_float())

boxed <- draw_bounding_boxes(dog1, boxes, colors = c("red", "yellow"), width = 5)

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.

suggestion could we add labels = c("label_1", ...) to visually explain all the features of the function ?

Comment on lines +69 to +72
batch <- torch_stack(list(
transform_normalize(dog1, norm_mean, norm_std),
transform_normalize(dog2, norm_mean, norm_std)
))

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.

suggestion if I'm not wrong, transform_normalize() accepts batches, so I would demonstrate it and I would apply it once after torch_strack()

Comment on lines +86 to +96
draw_detection <- function(image, detection) {
keep <- as.logical(as.array(detection$scores > 0.5))
draw_bounding_boxes(
image,
detection$boxes[keep, , drop = FALSE],
labels = coco_classes(as.integer(detection$labels[keep])),
colors = "yellow",
width = 5,
font_size = 30
)
}

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.

thought I'm not in favor of defining new functions wrapping visualization utilities in an article where the intent is to demonstrate how good the visualization utilities are. That said, I've no better idea to not have a lot of boilerplate code.
suggestion We should at least explain the why of this function, and what each step does.
suggestion a small size, naive visualization of the direct model output (normalized image and unfiltered bbox) would allow a good justification of the why this function

height and width.

```{r}
resized <- lapply(list(dog1, dog2), transform_resize, size = c(520, 520))

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 simplification clarity transform_resize is also accepting batches. So please demonstrate the piping of transforms after stacking the images.

@cregouby
cregouby self-requested a review September 1, 2026 11:33
@cregouby cregouby closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants