tlc.core.export.exporters.coco#

Exporter for the COCO format.

Module Contents#

Classes#

Class

Description

COCOExporter

Exporter for the COCO format.

API#

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 – A path with which image filenames are relativized.

  • absolute_image_paths – Whether to use absolute image paths. If this is set to True, the image_folder cannot be set.

  • include_segmentation – Whether to include segmentation information. Currently only supports bounding box segmentation. By default it will take information from the table, but this can be overridden by setting a boolean

  • indent – The number of spaces to use for indentation

  • kwargs – Any additional arguments

Returns:

The serialized table