tfm.vision.layers.MaskSampler
Stay organized with collections
Save and categorize content based on your preferences.
Samples and creates mask training targets.
tfm.vision.layers.MaskSampler(
mask_target_size: int, num_sampled_masks: int, **kwargs
)
Methods
call
View source
call(
candidate_rois: tf.Tensor,
candidate_gt_boxes: tf.Tensor,
candidate_gt_classes: tf.Tensor,
candidate_gt_indices: tf.Tensor,
gt_masks: tf.Tensor
)
Samples and creates mask targets for training.
| Args |
candidate_rois
|
A tf.Tensor of shape of [batch_size, N, 4], where N is
the number of candidate RoIs to be considered for mask sampling. It
includes both positive and negative RoIs. The
num_mask_samples_per_image positive RoIs will be sampled to create
mask training targets.
|
candidate_gt_boxes
|
A tf.Tensor of shape of [batch_size, N, 4], storing
the corresponding groundtruth boxes to the candidate_rois.
|
candidate_gt_classes
|
A tf.Tensor of shape of [batch_size, N], storing
the corresponding groundtruth classes to the candidate_rois. 0 in the
tensor corresponds to the background class, i.e. negative RoIs.
|
candidate_gt_indices
|
A tf.Tensor of shape [batch_size, N], storing the
corresponding groundtruth instance indices to the candidate_gt_boxes,
i.e. gt_boxes[candidate_gt_indices[:, i]] = candidate_gt_boxes[:, i],
where gt_boxes which is of shape [batch_size, MAX_INSTANCES, 4], M >=
N, is the superset of candidate_gt_boxes.
|
gt_masks
|
A tf.Tensor of [batch_size, MAX_INSTANCES, mask_height,
mask_width] containing all the groundtruth masks which sample masks are
drawn from. after sampling. The output masks are resized w.r.t the
sampled RoIs.
|
| Returns |
foreground_rois
|
A tf.Tensor of shape of [batch_size, K, 4] storing the
RoI that corresponds to the sampled foreground masks, where
K = num_mask_samples_per_image.
|
foreground_classes
|
A tf.Tensor of shape of [batch_size, K] storing the
classes corresponding to the sampled foreground masks.
|
cropoped_foreground_masks
|
A tf.Tensor of shape of
[batch_size, K, mask_target_size, mask_target_size] storing the
cropped foreground masks used for training.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2026-11-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-06 UTC."],[],[]]