HeatmapDataset

class hybrid_learning.datasets.custom.coco.heatmap_dataset.HeatmapDataset(body_parts, force_rebuild=False, pt_radius=None, masks_root=None, masks_root_root=None, lazy_mask_generation=True, img_size=None, mask_size=None, device=None, **kwargs)[source]

Bases: ConceptDataset

Data handle for ground truth heatmaps of centroids of visual concepts (body parts) generated from COCO keypoints. Works the same as the hybrid_learning.datasets.custom.coco.mask_dataset.ConceptDataset only with different MASKS_ROOT_ROOT and different annotations_to_mask() method. See there for details on how the centroid heatmaps look like.

Public Data Attributes:

MASKS_ROOT_ROOT

Usual parent to all heatmap folders for all body parts; sibling to images folder

Inherited from : py: class:ConceptDataset

MASKS_ROOT_ROOT

Usual parent to all heatmap folders for all body parts; sibling to images folder

settings

Settings to reproduce the instance.

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

Settings to reproduce the instance.

license_mapping

The mapping of image IDs to license descriptions and URLs.

Inherited from : py: class:BaseDataset

settings

Settings to reproduce the instance.

Public Methods:

ANNOTATION_TRANSFORM(annotations, ...[, ...])

Create a heatmap marking the centroids of the linked keypoints from the annotations list.

Inherited from : py: class:ConceptDataset

getitem(i)

Get image and mask by index i in dataset.

load_orig_mask(i)

Load and return unmodified mask as image by index in dataset.

mask_exists(i)

Check whether a mask for the specified index already exists.

mask_filepath(i)

Provide the path under which the mask for the given image ID should lie.

ANNOTATION_TRANSFORM(annotations, ...[, ...])

Create a heatmap marking the centroids of the linked keypoints from the annotations list.

annotations_to_mask(orig_img_wh, annotations)

Create mask of all configured keypoints from annotations.

generate_masks([force_rebuild, ...])

Generate and save the masks for the images in this dataset.

save_mask(i, mask)

Save the given mask according to the given index in the dataset.

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)

Get image and mask by index i in dataset.

Inherited from : py: class:BaseDataset

getitem(i)

Get image and mask by index i in dataset.

descriptor(i)

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

Special Methods:

Inherited from : py: class:ConceptDataset

__init__(body_parts[, force_rebuild, ...])

Init.

Inherited from : py: class:COCODataset

__init__(body_parts[, force_rebuild, ...])

Init.

__len__()

Length is given by the length of the index mapping.

Inherited from : py: class:BaseDataset

__init__(body_parts[, force_rebuild, ...])

Init.

__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)


ANNOTATION_TRANSFORM(annotations, keypoint_idxs, skeleton, pt_radius=0.025, link_width=None)

Callable used to transform a list of annotations into a heatmap mask. Create a heatmap of all body parts given by keypoints in the annotations.

Warning

Currently, all keypoints occurring in the body parts are treated separately! Centroids of body parts consisting of more than one keypoint are not supported yet.

For details see annotations_to_heatmap().

Parameters
Return type

Image

classmethod get_default_transforms(img_size=None, mask_size=None, device=None)[source]

Default transformation that pads and resizes both images and masks, and binarizes the masks.

Parameters
Return type

Callable[[Image, Image], Tuple[Tensor, Tensor]]

MASKS_ROOT_ROOT = 'kpt_heatmaps'

Usual parent to all heatmap folders for all body parts; sibling to images folder

__parameters__ = ()