tlc.data_types.semantic_segmentation¶
The semantic-segmentation domain type and its class-role surface.
A semantic segmentation is a dense (H, W) integer label map — an exhaustive
partition of the image. The user-facing piece in this module is the
SemanticSegmentation carrier (the read form and the optional explicit write
wrapper).
Class roles are not expressed by building a special value map; they are plain background
and void id keyword arguments on every public entry point — the column schema
(tlc.schemas.SemanticSegmentationRleSchema), the table front door
(tlc.Table.from_semantic_segmentation()), and the metrics helper
(tlc.metrics.semantic_segmentation.semantic_segmentation_metrics()). The internal
builders/readers below translate those ids into the persisted value map and back; callers never
touch them.
The (de)serializer that converts between this type and the RLE wire format lives in
tlc.sample_types.SemanticSegmentationSampleType.
Two classes carry meaning beyond “a label”. Background (the implicit/default fill) is
not a class at all: it is omitted from the value map and the wire, and its id is recorded in
the column schema’s metadata — consulted only at the (de)serialization boundary. Void
(a.k.a. border / ignore — excluded from metrics, not a prediction target, GT-only) stays in
the value map, tagged by a reserved internal_name constant rather than a new role field.
Module Contents¶
Classes¶
Class |
Description |
|---|---|
The semantic-segmentation carrier: a dense |
Data¶
Data |
Description |
|---|---|
API¶
- class SemanticSegmentation¶
The semantic-segmentation carrier: a dense
(H, W)integer label map.This is a thin, public type with two jobs:
Read form —
from_row()always returns one, so the sample view of a semseg column has a single, stable shape regardless of how the row was authored. Read.maskfor the dense label map and.present_class_idsfor the classes present.Explicit write wrapper — you rarely need it on write. The write path is lenient (see
accepts()): hand a bare(H, W)numpy array or a single-channelPIL.Imagestraight to aTableWriter, or useTable.from_semantic_segmentation(). Reach for this wrapper only to say something the bare array can’t — today that means pinning an explicitbackground_id.
maskis a(H, W)integer array where each pixel holds a class id;image_widthandimage_heightare inferred from it when omitted.background_idnames the class treated as the implicit background — the “absence of a labeled object” canvas. It is a pure write-time instruction, never persisted. The background is omitted from the wire whenever it can be recovered on read: id0is always recovered byfrom_row()’s fill, and a background at any other id is recovered from the id recorded in the column schema’smetadata(the table read path binds that schema). Used standalone with no bound schema, only an id-0background is recoverable, so a non-zero one is kept as an ordinary layer (never unusable).Nonekeeps every present class, including any at id 0.
- TLC_SEMSEG_VOID = __tlc_semseg_void__¶