data.datasets.detection package

Submodules

data.datasets.detection.base_detection module

class data.datasets.detection.base_detection.BaseDetectionDataset(opts: Namespace, *args, **kwargs)[source]

Bases: BaseImageDataset

Base Dataset class for Object Dection datasets.

Parameters:

opts – Command-line arguments

__init__(opts: Namespace, *args, **kwargs) None[source]
classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add dataset-specific arguments

data.datasets.detection.coco_base module

class data.datasets.detection.coco_base.COCODetection(opts, *args, **kwargs)[source]

Bases: BaseDetectionDataset

Base class for the MS COCO Object Detection Dataset. Sub-classes should implement training and validation transform functions.

Parameters:

opts – command-line arguments

Note

This class implements basic functions (e.g., reading image and annotations), and does not implement training/validation transforms. Detector specific sub-classes should extend this class and implement those methods. See coco_ssd.py as an example for SSD.

__init__(opts, *args, **kwargs) None[source]
share_dataset_arguments() Dict[str, Any][source]

Returns the number of classes in detection dataset along with super-class arguments.

classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add dataset-specific arguments

get_boxes_and_labels(image_id: int, image_width: int, image_height: int, *args, include_masks=False, **kwargs) Tuple[ndarray, ndarray, ndarray | None][source]

Get the boxes and label information for a given image_id

Parameters:
  • image_id – Image ID

  • image_width – Width of the image

  • image_height – Height of the image

  • include_masks – Return instance masks or not

Returns:

  • Numpy array containing bounding box information in xyxy format.

    The shape of array is [Num_of_boxes, 4].

  • Numpy array containing labels for each of the box. The shape of array is [Num_of_boxes]

  • When include_masks is enabled, a numpy array of instance masks is returned. The shape of the

    array is [Num_of_boxes, image_height, image_width]

Return type:

A tuple of length 3

get_image(image_id: int) Tuple[source]

Return the PIL image for a given image id

extra_repr() str[source]

Extra information to be represented in __repr__. Each line in the output string should be prefixed with \t.

static class_names() List[str][source]

Name of the classes in the COCO dataset

data.datasets.detection.coco_mask_rcnn module

class data.datasets.detection.coco_mask_rcnn.COCODetectionMaskRCNN(opts: Namespace, *args, **kwargs)[source]

Bases: COCODetection

Dataset class for the MS COCO Object Detection using Mask RCNN .

Parameters:

opts – Command-line arguments

__init__(opts: Namespace, *args, **kwargs) None[source]
classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add dataset-specific arguments

data.datasets.detection.coco_mask_rcnn.coco_mask_rcnn_collate_fn(batch: List[Mapping[str, Tensor | Mapping[str, Tensor]]], opts: Namespace, *args, **kwargs) Mapping[str, List[Tensor] | Mapping[str, List[Tensor]]][source]

Combines a list of dictionaries into a single dictionary by concatenating matching fields.

For expected keys, see the keys in the output of __getitem__ function of COCODetectionMaskRCNN class.

Parameters:
  • batch – A list of dictionaries

  • opts – Command-line arguments

Returns:

A dictionary with samples and targets as keys.

data.datasets.detection.coco_ssd module

class data.datasets.detection.coco_ssd.COCODetectionSSD(opts: Namespace, *args, **kwargs)[source]

Bases: COCODetection

Dataset class for the MS COCO Object Detection using Single Shot Object Detector (SSD).

Parameters:

opts – Command-line arguments

__init__(opts: Namespace, *args, **kwargs) None[source]
generate_anchors(height: int, width: int) Tensor[source]

Given the height and width of the input to the SSD model, generate anchors

Parameters:
  • height – Height of the input image to the SSD model

  • width – Width of the input image to the SSD model

Returns:

Tensor containing anchor locations

extra_repr() str[source]

Extra information to be represented in __repr__. Each line in the output string should be prefixed with \t.

data.datasets.detection.coco_ssd.coco_ssd_collate_fn(batch: List[Mapping[str, Tensor | Mapping[str, Tensor]]], opts: Namespace) Mapping[str, Tensor | Mapping[str, Tensor]][source]

Combines a list of dictionaries into a single dictionary by concatenating matching fields.

For expected keys, see the keys in the output of __getitem__ function of COCODetectionSSD class.

Parameters:
  • batch – A list of dictionaries

  • opts – Command-line arguments

Returns:

A dictionary with samples and targets as keys.

Module contents