tlc.core.export.exporters.coco#

Exporter for the COCO format.

Module Contents#

Classes#

Class

Description

COCOExporter

Exporter for the COCO format.

Functions#

Function

Description

parse_include_segmentation_arg

API#

tlc.core.export.exporters.coco.parse_include_segmentation_arg(include_segmentation: bool | str | None) bool | None#
class tlc.core.export.exporters.coco.COCOExporter#

Bases: tlc.core.export.exporter.Exporter

Exporter for the COCO format.

Tables which are originally instances of the TableFromCoco class will be compatible with this exporter.

supported_format = coco#
priority = 3#
classmethod can_export(table: tlc.core.objects.table.Table, output_url: tlc.core.url.Url) bool#
classmethod serialize(table: tlc.core.objects.table.Table, output_url: tlc.core.url.Url, weight_threshold: float = 0.0, image_folder: tlc.core.url.Url | str = '', absolute_image_paths: bool = False, include_segmentation: bool | None = None, indent: int = 4, **kwargs: Any) str#

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_paths and image_folder argument.

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_folder cannot be set.

  • include_segmentation – Whether to include segmentation in the exported COCO file. If this flag is True, segmentation poly-lines will be generated directly from the bounding box annotations. If this flag is False, no segmentations are written. If this flag is None, segmentation info will be copied directly from the input Table.

  • indent – The number of spaces to use for indentation in the output.

  • kwargs – Any additional arguments

Returns:

The serialized table