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
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.
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
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
- 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
- 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.