Dataset

Module providing dataset loaders from various source formats.

Functions

load_coco_dataset(path, image_folder[, ...])

Load COCO dataset (2017 version).

load_pascalvoc_dataset(annotation_folder, ...)

Load PASCAL-VOC dataset (version 2012).

load_via_dataset(path)

Load VGG Image Annotator (VIA) dataset.

load_yolo_dataset(folder_path, class_path)

Load YOLO dataset.

polygon_to_mask(polygons, width, height)

Helper function to generate image mask from a list of polygons.

read_class_names(txt_path)

Helper function to parse text file and extract class names.

Details

ikomia.dnn.dataset.load_coco_dataset(path: str, image_folder: str, task: str = 'instance_segmentation', output_folder: str = '') dict

Load COCO dataset (2017 version). COCO dataset consists in a JSON file describing annotations and an image folder.

Parameters:
  • path (str) – path to the JSON annotation file

  • image_folder (str) – path to the image folder

  • task (str) – task of the dataset, must be one of the following “detection”, “instance_segmentation”, “semantic_segmentation” or “keypoints”

  • output_folder (str) – path to output folder only for semantic segmentation

Returns:

Ikomia dataset structure. See IkDatasetIO.

Return type:

dict

ikomia.dnn.dataset.load_pascalvoc_dataset(annotation_folder: str, img_folder: str, instance_seg_folder: str, class_path: str) dict

Load PASCAL-VOC dataset (version 2012). PASCAL-VOC dataset is structured in different folders:

  • image folder

  • annotation folder: text files (same name as corresponding image files)

  • instance segmentation folder: image file (same name as corresponding image files)

Parameters:
  • annotation_folder (str) – path to annotations folder

  • img_folder (str) – path to images folder

  • instance_seg_folder – path to segmentation masks folder

  • class_path – path to text file containing class names

Returns:

Ikomia dataset structure. See IkDatasetIO.

Return type:

dict

ikomia.dnn.dataset.load_via_dataset(path: str) dict

Load VGG Image Annotator (VIA) dataset. VIA dataset is a single JSON file containing all information.

Parameters:

path (str) – path to the JSON file

Returns:

Ikomia dataset structure. See IkDatasetIO.

Return type:

dict

ikomia.dnn.dataset.load_yolo_dataset(folder_path: str, class_path: str) dict

Load YOLO dataset. YOLO dataset consists of a list of text files with the same name as the corresponding image. Each line represent a bounding box with the following information:

  • class number x_center y_center width height

Note that center coordinates and box size are relative to the image size.

Parameters:
  • folder_path (str) – path to the dataset folder (image + text files)

  • class_path (str) – path the text file containing all class names

Returns:

Ikomia dataset structure. See IkDatasetIO.

Return type:

dict

ikomia.dnn.dataset.polygon_to_mask(polygons: list, width: int, height: int) ndarray

Helper function to generate image mask from a list of polygons. The function assumes that each polygon is a list of xy coordinates.

Parameters:
  • polygons – list of polygons

  • width (int) – width of the future mask

  • height (int) – height of the future mask

Returns:

image mask

Return type:

numpy array

ikomia.dnn.dataset.read_class_names(txt_path: str) list

Helper function to parse text file and extract class names. The text file must be structured so that one line = one class name.

Parameters:

txt_path (str) – path to the text file

Returns:

list of class names

Return type:

str[]