Importer

class cocohelper.importer.Importer[source]

Bases: object

Importer can generate COCOHelper objects from a generic interface.

We delegate to DatasetAdapter hierarchy the strategy used to load data from another dataset. Importer expect that a DatasetAdapter is provided and use it to load data in an understandable format, generating a new COCOHelper object.

This can be used to convert from an arbitrary dataset format to the COCO format.

Parameters:

adapter – DatasetAdapter to use.

Method List

create(out_coco_dir[, ann_dir, img_dir, ...])

Generate the new COCOHelper, and optionally save it.

Methods Details

create(out_coco_dir, ann_dir='annotations/', img_dir='images/', save_images=False)[source]

Generate the new COCOHelper, and optionally save it.

Parameters:
  • out_coco_dir (Union[str, Path]) – Root path to save the dataset.

  • ann_dir (Union[str, Path]) – Annotation directory (relative to out_coco_path).

  • img_dir (Union[str, Path]) – Image directory (relative to out_coco_path).

  • save_images (bool) – If True saves the image to out_coco_path.

Returns:

A new COCOHelper.

Return type:

COCOHelper