anatools.annotations.annotations module

class Annotations

Bases: object

Generates annotations given a dataset directory, an output directory and mapping file. The dataset directory must include the Ana annotations, images and metadata folders. Examples of mapfiles are in the example channel at /ana/channels/example/mapfiles/.

bounding_box_2d(image_path, out_dir, object_ids=None, object_types=None)

Generates images annotated with 2d bounding boxes for datasets downloaded from the Platform. Optional filter on object_ids or object_types (must choose a single filter).

Parameters
  • image_path (str) – Path to of specific image file to draw the boxes for.

  • out_dir (str) – File path to directory where the image should be saved to.

  • object_ids (list[int]) – List of object id’s to annotate. If not provided, all objects will get annotated. Choose either id or type filter.

  • object_types (list[str]) – Filter for the object types to annotate. If not provided, all object types will get annotated. Choose either id or type filter.

check_lists(actual, expected, name_to_check)

Helper function that checks if one list is in another for validation on bounding box annotating inputs.

Parameters
  • actual (list) – The list of actual values found in either annotation or metadata file.

  • expected (list) – The expected list that is provided from the user.

  • name_to_check (str) – Name of parameter to check (either object_id or object_type).

Returns

True if lists are matching, False otherwise.

Return type

bool

dump_coco(datadir, outdir, mapfile)

Generates annotations in the format of COCO Object Detection. See https://cocodataset.org/#format-data.

Parameters
  • datadir (str) – The location of the Ana dataset.

  • outdir (str) – The location to output the annotation files to.

  • mapfile (str) – The location of the mapping file.

dump_kitti(datadir, outdir, mapfile)

Generates annotations in the format of KITTI. See https://docs.nvidia.com/metropolis/TLT/archive/tlt-20/tlt-user-guide/text/preparing_data_input.html.

Parameters
  • datadir (str) – The location of the Ana dataset.

  • outdir (str) – The location to output the annotation files to.

  • mapfile (str) – The location of the mapping file.

dump_pascal(datadir, outdir, mapfile)

Generates annotations in the format of PASCAL VOC. See https://pjreddie.com/media/files/VOC2012_doc.pdf.

Parameters
  • datadir (str) – The location of the Ana dataset.

  • outdir (str) – The location to output the annotation files to.

  • mapfile (str) – The location of the mapping file.