tlc.export.exporters.coco¶
Exporter for the COCO format.
Module Contents¶
Classes¶
Class |
Description |
|---|---|
Exporter for the COCO format. |
API¶
- class CocoExporter¶
Bases:
tlc.export.exporter.SerializingExporterExporter for the COCO format.
Tables which are originally instances of the TableFromCoco class will be compatible with this exporter.
- can_export( ) bool¶
Check if the table can be exported to the COCO format.
Can not be 100% accurate, as we don’t know if the user has supplied additional arguments, such as annotation_column_name, or image_column_name.
- priority = 3¶
- serialize(
- table: Table,
- output_url: Url,
- weight_threshold: float = 0.0,
- image_folder: Url | str = '',
- absolute_image_paths: bool = False,
- annotation_column_name: str | None = None,
- image_column_name: str | None = None,
- per_image_extras: Sequence[str] | None = None,
- indent: int = 4,
- **kwargs: Any,
Serialize a table to the COCO format.
Default behavior is to write a COCO file with image paths relative to the (output) annotations file. Written paths can be further configured with the
absolute_image_pathsandimage_folderargument.Note that for a coco file to be valid, the image paths should be absolute or relative w.r.t. the annotations file itself.
- Parameters:
table – The table to serialize
output_url – The output URL
weight_threshold – The weight threshold
image_folder – Make image paths relative to a specific folder. Note that this may produce an annotations file that needs special handling. This option is mutually exclusive with
absolute_image_paths.absolute_image_paths – Make image paths absolute. If this is set to True, the
image_foldercannot be set.annotation_column_name – Optional column name to use for annotations instead of the defaults (
bbs,segmentations, orkeypoints_2d). The content of the column determines the annotation mode (bounding boxes, segmentations, or keypoints) based on its structure.image_column_name – Optional column name to use for image URLs. Defaults to
image.per_image_extras – Image-level column names to include in the COCO image dicts. These should correspond to top-level table columns (e.g. columns originally imported via the importer’s
per_image_extrasparameter). When None, no extra image fields are written.indent – The number of spaces to use for indentation in the output.
**kwargs – Any additional arguments
- Returns:
The serialized table
- supported_format = coco¶