-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Current Situation
Current and future segmentation datasets
coco_segmentation_datasetoxfordiiitpet_segmentation_dataset- ...
have default segmentation annotations file content that are not ready fordraw_segmentation_mask()function.
In order to ease usage of draw_segmentation_mask, we currently apply a specific hidden target_transform within each dataset function :
Lines 130 to 145 in 8acd690
| masks <- lapply(seq_len(nrow(anns)), function(i) { | |
| seg <- anns$segmentation[[i]] | |
| if (is.list(seg) && length(seg) > 0) { | |
| mask <- coco_polygon_to_mask(seg, height = H, width = W) | |
| if (inherits(mask, "torch_tensor") && mask$ndim == 2) return(mask) | |
| } | |
| NULL | |
| }) | |
| masks <- Filter(function(m) inherits(m, "torch_tensor") && m$ndim == 2, masks) | |
| if (length(masks) > 0) { | |
| masks_tensor <- torch::torch_stack(masks) | |
| } else { | |
| masks_tensor <- torch::torch_zeros(c(0, H, W), dtype = torch::torch_bool()) | |
| } |
torchvision/R/dataset-oxfordiiitpet.R
Lines 155 to 160 in 978ffa6
| masks <- png::readPNG(mask_path) * 255 | |
| masks <- torch_tensor(masks) | |
| mask1 <- (masks==1) | |
| mask2 <- (masks==2) | |
| mask3 <- (masks==3) | |
| masks <- torch_stack(list(mask1, mask2, mask3))$to(dtype = torch_bool()) |
Design driver
- try to adhere to (py) torchvision guidelines "Torchvision datasets preserve the data structure and types as it was intended by the datasets authors. So by default, the output structure may not always be compatible with the models or the transforms."
- clean and easy-to-understand workflow for the end-user to load the dataset and draw a segmented image and to infer with a asegmentation model and draw the result.
- not having to perform hidden complex target-transformation of raw annotation into the
image_with_segmentation_maskdata format
Expected situation
- add two target transform functions :
Metadata
Metadata
Assignees
Labels
No labels