Utility helpers shared by the data package.
This package collects public helper APIs used by dataset creation, parsing, loading, exporting, validation, and visualization. The utilities are grouped by the part of the data workflow they support:
| Group | Public APIs |
|---|---|
| Task keys | task_is_metadata, split_task, get_task_name, get_task_type,
and task_type_iterator parse and filter "task_name/task_type"
labels. |
| Storage and parser enums | BucketStorage, BucketType, MediaType, ImageType,
UpdateMode, ParserIssue, and ParserIssueMessage. |
| Dataframe and parquet helpers | ParquetFileManager, ParquetRecord, duplicate detection, class
distributions, missing-annotation summaries, heatmaps, and UUID
merging. |
| Remote media | RemoteFileDownloader and download_remote_file copy supported
remote files to local paths and validate image inputs. |
| Visualization | visualize, color-map helpers, image concatenation, augmentation
footers, and dataset-statistic plots. |
| Equivalence and augmentation inspection | LDF equivalence checks and AugmentationsCollector summaries for
configured augmentation pipelines. |
The task-key helpers follow the same convention as LuxonisLoader: labels are
addressed by "task_name/task_type" and metadata labels use
"task_name/metadata/key" or "metadata/key" when no task name is
present.
| Module | augmentations |
No module docstring; 1/1 class documented |
| Module | cli |
No module docstring; 2/5 functions documented |
| Module | constants |
Undocumented |
| Module | data |
Undocumented |
| Module | enums |
Undocumented |
| Module | ldf |
Undocumented |
| Module | parquet |
Undocumented |
| Module | plot |
No module docstring; 3/3 functions documented |
| Module | remote |
Undocumented |
| Module | task |
Undocumented |
| Module | visualizations |
No module docstring; 16/16 functions, 1/1 class documented |
From __init__.py:
| Class | |
Collect augmentation names that were applied to a sample. |
| Class | |
Supported COCO directory layouts. |
| Class | |
Manage append-style writes across partitioned parquet files. |
| Class | |
Single annotation row written to parquet. |
| Class | |
Download remote files with optional image validation. |
| Function | download |
Download a remote file to the requested destination. |
| Function | find |
Collect duplicate UUID and annotation information. |
| Function | get |
Return class distribution information for non-classification tasks. |
| Function | get |
Return duplicate UUID and annotation information. |
| Function | get |
Generate heatmaps for boxes, keypoints, and segmentation masks. |
| Function | get |
Return file paths that have no annotations. |
| Function | get |
Return the task name from a task string. |
| Function | get |
Return the task type from a task string. |
| Function | infer |
Undocumented |
| Function | merge |
Merge multiple UUIDs into a single deterministic UUID, independent of order. |
| Function | plot |
Plot a class distribution bar chart. |
| Function | plot |
Plot a heatmap. |
| Function | rgb |
Convert an RGB segmentation mask to boolean class masks. |
| Function | split |
Split a task into task name and task type. |
| Function | task |
Check whether a task is a metadata task. |
| Function | task |
Iterate over labels of a specific task type. |
| Function | warn |
Log warnings for duplicate UUIDs and annotations. |
str, destination: Path, *, timeout: float = 30.0, validate_image: bool = False) -> Path:
¶
Download a remote file to the requested destination.
| Parameters | |
url:str | Source URL. |
destination:Path | Local destination path. |
timeout:float | HTTP request timeout in seconds. |
validatebool | Whether to validate image content and format compatibility after download. |
| Returns | |
Path | Local destination path. |
| Raises | |
ValueError | If the URL scheme is unsupported or image validation fails. |
Collect duplicate UUID and annotation information.
| Parameters | |
df:pl.LazyFrame | Dataset information. |
| Returns | |
Dictionary with |
|
Return class distribution information for non-classification tasks.
| Parameters | |
df:pl.LazyFrame | Dataset information. |
| Returns | |
dict[ | Class counts grouped by task name and task type. |
Return duplicate UUID and annotation information.
| Parameters | |
df:pl.LazyFrame | Dataset information. |
| Returns | |
Dictionary with duplicate UUID and annotation details |
|
pl.LazyFrame, sample_size: int | None = None, downsample_factor: int = 5) -> dict[ str, dict[ str, list[ list[ int]]]]:
¶
Generate heatmaps for boxes, keypoints, and segmentation masks.
Heatmaps are accumulated on a fixed 15×15 grid over normalized image coordinates. Bounding boxes contribute their center points, keypoints contribute visible points, and segmentation masks contribute foreground pixels after optional downsampling.
| Parameters | |
df:pl.LazyFrame | Dataset information. |
sampleint | None | Optional number of samples used to generate heatmaps. |
downsampleint | Factor used to downsample segmentation masks. A value of 5 keeps every fifth row and column. |
| Returns | |
dict[ | Heatmaps grouped by task name and task type. Each heatmap is a 15×15 nested list of counts. |
Return file paths that have no annotations.
| Parameters | |
df:pl.LazyFrame | Dataset information. |
| Returns | |
list[ | File paths with no annotations. |
Return the task name from a task string.
Examples
>>> get_task_name("detector/boundingbox") 'detector' >>> get_task_name("classification") 'classification'
| Parameters | |
task:str | Task string. |
| Returns | |
str | Task name. |
Return the task type from a task string.
Example
>>> get_task_type("task_name/type") 'type' >>> get_task_type("metadata/name") 'metadata/name' >>> get_task_type("task_name/metadata/name") 'metadata/name'
| Parameters | |
task:str | Task string, such as "task_name/type". |
| Returns | |
str | Task type. Metadata tasks are returned as "metadata/type". |
str, class_name: str | None, current_classes: dict[ str, dict[ str, int]]) -> str:
¶
Undocumented
Merge multiple UUIDs into a single deterministic UUID, independent of order.
Examples
>>> first = "00000000-0000-0000-0000-000000000001" >>> second = "00000000-0000-0000-0000-000000000002" >>> merge_uuids([first, second]) == merge_uuids([second, first]) True >>> isinstance(merge_uuids([first]), uuid.UUID) True
| Parameters | |
uuids:Iterable[ | UUID strings to merge. |
| Returns | |
uuid.UUID | Deterministic merged UUID. |
Plot a class distribution bar chart.
| Parameters | |
ax:plt.Axes | Axis to plot on. |
taskstr | Task type. |
tasklist[ | Class distribution records. |
plt.Axes, fig: plt.Figure, task_type: str, heatmap_data: list[ list[ float]] | None):
¶
Plot a heatmap.
| Parameters | |
ax:plt.Axes | Axis to plot on. |
fig:plt.Figure | Figure containing the axis. |
taskstr | Task type. |
heatmaplist[ | Heatmap values to plot. |
np.ndarray, class_colors: dict[ str, RGB], add_background_class: bool = False) -> Iterator[ tuple[ str, np.ndarray]]:
¶
Convert an RGB segmentation mask to boolean class masks.
Example
>>> segmentation_mask = np.array([ ... [[0, 0, 0], [255, 0, 0], [0, 255, 0]], ... [[0, 0, 0], [0, 255, 0], [0, 0, 255]], ... ], dtype=np.uint8) >>> class_colors = { ... "red": (255, 0, 0), ... "green": (0, 255, 0), ... "blue": (0, 0, 255), ... } >>> for class_name, mask in rgb_to_bool_masks( ... segmentation_mask, ... class_colors, ... add_background_class=True, ... ): ... print(class_name, np.array2string(mask, separator=", ")) background [[ True, False, False], [ True, False, False]] red [[False, True, False], [False, False, False]] green [[False, False, True], [False, True, False]] blue [[False, False, False], [False, False, True]]
| Parameters | |
segmentationnp.ndarray | RGB segmentation mask where each pixel color identifies its class. |
classdict[ | Mapping from class names to RGB colors. |
addbool | Whether to add a "background" mask for pixels that do not belong to any class. The background mask is yielded first. |
| Returns | |
Iterator[ | Iterator of class names and their boolean masks. |
Split a task into task name and task type.
Examples
>>> split_task("detector/boundingbox") ('detector', 'boundingbox') >>> split_task("classification") ('', 'classification')
| Parameters | |
task:str | Task to split. |
| Returns | |
tuple[ | Task name and task type. |
Check whether a task is a metadata task.
Examples
>>> task_is_metadata("metadata/weather") True >>> task_is_metadata("camera/metadata/weather") True >>> task_is_metadata("camera/boundingbox") False
| Parameters | |
task:str | Task to check. |
| Returns | |
bool | Whether the task is a metadata task. |
Iterate over labels of a specific task type.
Examples
>>> labels = { ... "detector/boundingbox": np.array([1]), ... "pose/keypoints": np.array([2]), ... } >>> [(task, arr.tolist()) for task, arr in task_type_iterator(labels, "keypoints")] [('pose/keypoints', [2])]
| Parameters | |
labels:Labels | Labels to iterate over. |
taskTaskType | Label type to yield. |
| Returns | |
Iterator[ | Iterator over matching labels. |