dgs.models.dataset.posetrack21.extract_pt21_image_crops

dgs.models.dataset.posetrack21.extract_pt21_image_crops(dataset_dir: str = './data/PoseTrack21', individually: bool = True, **kwargs) None[source]

This function will extract the image crops and image-crop-local key-point coordinates, given the full PoseTrack21 dataset. The whole function takes about 30 minutes to complete on the whole dataset.

Parameters:
  • dataset_dir (FilePath) – Path to the directory containing the dataset. Default “./data/PoseTrack21”.

  • individually (bool) – Whether to compute the image crops within the test folders at once or one by one. True may be used if the Computer has decent hardware and GPU support. Still, running the function individually is not that much slower. Default True.

Keyword Arguments:
  • anno_dir (FilePath) – A dataset-local path pointing to the directory containing the annotations. Default “./posetrack_data/”.

  • crop_size (ImgShape) – The target shape of the image crops. Defaults to (256, 256).

  • device (Device) – Device to run the cropping on. Defaults to “cuda” if available “cpu” otherwise.

  • transform (tvt.Compose) – A torchvision transform given as Compose to get the crops from the original image. Defaults to a version of CustomCropResize.

  • crop_mode (str) – Defines the resize mode in the transform function. Has to be in the modes of CustomToAspect. Default “zero-pad”.

  • quality (int) – The quality to save the jpegs as. Default 90. The default of torchvision is 75.

Notes

There is no batched variant of the extract_crops… functions. Either all images in the folder are stacked and processed, or only one image is computed at a time. Depending on your processing power and (v)RAM, computing the stack of up to 1000 images is quite bad for performance. Therefore, it is possible to use the individually=True flag, to compute the crop of every image individually. Adding a little overhead by running the transforms more often, but it might still be faster in the end.

Notes

For further information about the kwargs see the functions: extract_all_bboxes() and extract_crops_from_json_annotation().