KeypointsDataset
- class hybrid_learning.datasets.custom.coco.keypoints_dataset.KeypointsDataset(**kwargs)[source]
Bases:
COCODatasetHandler for (a subset of) a COCO keypoints dataset. Input images are the original COCO images. Annotations are the keypoint annotations for the images.
This is essentially a wrapper around a COCO handle following the scheme of
BaseDatasetand allowing for restriction to specific licenses.Public Data Attributes:
Inherited from : py: class:COCODataset
COMMERCIAL_LICENSE_IDSIDs of COCO image licenses that allow for commercial use.
DATASET_ROOT_TEMPLDefault root directory template for image files that accepts the
split('train'or'val').ANNOTATION_FP_TEMPLDefault template for the annotation file path that accepts the
split('train'or'val') and therootdirectory.DEFAULT_IMG_SIZEDefault target size of images to use for the default transforms as
(height, width).settingsReturn information to init new dataset.
license_mappingThe mapping of image IDs to license descriptions and URLs.
Inherited from : py: class:BaseDataset
settingsReturn information to init new dataset.
Public Methods:
getitem(i)Collect the image and the keypoint annotations at position
i.Inherited from : py: class:COCODataset
subset(*[, license_ids, body_parts, num, ...])Restrict the items by the given selection criteria and an optional custom condition.
shuffle()Wrapper around
subset()that only shuffles the instance.to_raw_anns([description, save_as])Create the content of a new valid annotations file restricted to the current image IDs.
copy_to([root_root, description, overwrite, ...])Create a new dataset by copying used images and annotations to new root folder.
load_orig_image(i)Load unmodified image by index in dataset.
descriptor(i)Return the image file name for the item at index
i.image_filepath(i)Path to image file at index
i.image_attribution(i)Get attribution information for image at index
i.image_meta(i)Load the dict with meta information for image at index
i.raw_anns(i)Return the list of raw annotations for image at index
i.getitem(i)Collect the image and the keypoint annotations at position
i.Inherited from : py: class:BaseDataset
getitem(i)Collect the image and the keypoint annotations at position
i.descriptor(i)Return the image file name for the item at index
i.Special Methods:
__init__(**kwargs)Init.
Inherited from : py: class:COCODataset
__init__(**kwargs)Init.
__len__()Length is given by the length of the index mapping.
Inherited from : py: class:BaseDataset
__init__(**kwargs)Init.
__len__()Length is given by the length of the index mapping.
__getitem__(idx)Get item from
idxin dataset with transformations applied.__repr__()Nice printing function.
Inherited from : py: class:Dataset
__getitem__(idx)Get item from
idxin dataset with transformations applied.__add__(other)
- __init__(**kwargs)[source]
Init.
- Parameters
spec – Specification
kwargs – Arguments for super class
- classmethod get_default_transforms(img_size, device=None)[source]
Return the default transformation, which is pad and resize.
- Parameters
- Return type
- getitem(i)[source]
Collect the image and the keypoint annotations at position
i. Used for__getitem__().
- __parameters__ = ()
- after_cache_transforms: Callable
Transformation function applied after consulting the cache (no matter, whether the tuples was retrieved from cache or not). Use these transformations instead of
transformsto ensure the transformation is always applied, regardless of caching. By default, tensor gradients are disabled and tensors are moved to a common device (see_get_default_after_cache_trafo()).
- coco: COCO
Internal COCO handle.
- dataset_root: str
Assuming the dataset is saved in some storage location, a root from which to navigate to the dataset information.
- img_ann_ids: List[Tuple[int, List[int]]]
Mapping of indices in this dataset to COCO image and annotation IDs. Each entry in the list is a tuple of the form
(image_id, [annotation_id, ...])where the annotations belong to the corresponding image.
- split: Optional[DatasetSplit]
Optional specification what use-case this dataset is meant to represent, e.g. training, validation, or testing.
- transforms: Callable
Transformation function applied to each item tuple before return. Applied in
__getitem__(). Default transformations are sub-class-specific. Items transformed usingtransformscan be cached by settingtransforms_cache. If the transformations should be applied always, regardless of caching, useafter_cache_transforms.
- transforms_cache: Optional[Cache]
Cache for the transformed
(input, target)tuples. If set,__getitem__()will first try to load the tuple from cache before loading and transforming it normally. Items not in the cache are put in there aftertransformsis applied.