nvidia.dali.fn.segmentation.select_masks — NVIDIA DALI (original) (raw)

nvidia.dali.fn.segmentation.select_masks(__mask_ids, __polygons, __vertices, /, *, bytes_per_sample_hint=[0], preserve=False, reindex_masks=False, device=None, name=None)#

Selects a subset of polygons by their mask ids.

The operator expects three inputs describing multiple segmentation mask polygons belonging to different mask ids and a list of selected mask ids.

Each sample can contain several polygons belonging to different masks, and each polygon can be composed by an arbitrary number of vertices (at least 3). The masks polygons are described by the inputs polygons and vertices and the operator produces output polygons and vertices where only the polygons associated with the selected masks are present.

Note

The format of polygons and vertices is the same as produced by COCOReader.

Examples:

Let us assume the following input mask, where symbolic coordinates are used for a clearer example:

polygons = [[0, 0, 3], [1, 3, 7], [2, 7, 10]] vertices = [[x0, y0], [x1, y1], [x2, y2], [x3, y3], [x4, y4], [x5, y5], [x6, y6], [x7, y7], [x8, y8], [x9, y9]]

Example 1: Selecting a single mask with id 1, maintaining the original id:

mask_ids = [1], :paramref:~nvidia.dali.fn.segmentation.select_masks.reindex_masks = False out_polygons = [[1, 0, 4]] out_vertices = [[x3, y3], [x4, y4], [x5, y5], [x6, y6]]

Example 2: Selecting two out of the three masks, replacing the mask ids with the indices at which they appeared in mask_ids input:

mask_ids = [2, 0] reindex_masks = True out_polygons = [[0, 3, 6], [1, 0, 3]] out_vertices = [[x0, y0], [x1, y1], [x2, y2], [x7, y7], [x8, y8], [x9, y9]]

Supported backends

Parameters:

Keyword Arguments: