KeypointsDatasetWithDesc

class hybrid_learning.experimentation.fuzzy_exp.fuzzy_exp_helpers.KeypointsDatasetWithDesc(img_size, device=None, use_boxes=True, reduce_gt_masks=True, **kwargs)[source]

Bases: KeypointsDataset

Wrapper around coco dataset class returning tuples of (descriptor, (image, anns)). Default trafo turns images into tensors, anns into mask tensors and resizes all to img_size. In case a transform is given that should apply on (image, anns), don’t forget to use a trafos.UnfoldTuple() transform.

Public Data Attributes:

Inherited from : py: class:COCODataset

COMMERCIAL_LICENSE_IDS

IDs of COCO image licenses that allow for commercial use.

DATASET_ROOT_TEMPL

Default root directory template for image files that accepts the split ('train' or 'val').

ANNOTATION_FP_TEMPL

Default template for the annotation file path that accepts the split ('train' or 'val') and the root directory.

DEFAULT_IMG_SIZE

Default target size of images to use for the default transforms as (height, width).

settings

Return information to init new dataset.

license_mapping

The mapping of image IDs to license descriptions and URLs.

Inherited from : py: class:BaseDataset

settings

Return information to init new dataset.

Public Methods:

getitem(i)

Return tuple of (descriptor, (image, anns)).

Inherited from : py: class:KeypointsDataset

getitem(i)

Return tuple of (descriptor, (image, anns)).

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)

Return tuple of (descriptor, (image, anns)).

Inherited from : py: class:BaseDataset

getitem(i)

Return tuple of (descriptor, (image, anns)).

descriptor(i)

Return the image file name for the item at index i.

Special Methods:

__init__(img_size[, device, use_boxes, ...])

Overwrite the default transform.

Inherited from : py: class:KeypointsDataset

__init__(img_size[, device, use_boxes, ...])

Overwrite the default transform.

Inherited from : py: class:COCODataset

__init__(img_size[, device, use_boxes, ...])

Overwrite the default transform.

__len__()

Length is given by the length of the index mapping.

Inherited from : py: class:BaseDataset

__init__(img_size[, device, use_boxes, ...])

Overwrite the default transform.

__len__()

Length is given by the length of the index mapping.

__getitem__(idx)

Get item from idx in dataset with transformations applied.

__repr__()

Nice printing function.

Inherited from : py: class:Dataset

__getitem__(idx)

Get item from idx in dataset with transformations applied.

__add__(other)


__init__(img_size, device=None, use_boxes=True, reduce_gt_masks=True, **kwargs)[source]

Overwrite the default transform.

Parameters
getitem(i)[source]

Return tuple of (descriptor, (image, anns)).

Parameters

i (int) –

Return type

Tuple[str, Tuple[Image, List[Dict]]]

__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 transforms to 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 using transforms can be cached by setting transforms_cache. If the transformations should be applied always, regardless of caching, use after_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 after transforms is applied.