class_docstr: A customized version of `detectron2.data.DatasetMapper`
class_docstr_tok: ["A","customized","version","of","`","detectron2.data.DatasetMapper","`"]
docstr: Args:
      dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
  
  Returns:
      dict: a format that builtin models in detectron2 accept
docstr_tok: ["Args",":","dataset_dict","(","dict",")",":","Metadata","of","one","image",",","in","Detectron2","Dataset","format",".","Returns",":","dict",":","a","format","that","builtin","models","in","detectron2","accept"]
code: def __call__(self, dataset_dict):
      """
      Args:
          dataset_dict (dict): Metadata of one image, in Detectron2 Dataset format.
  
      Returns:
          dict: a format that builtin models in detectron2 accept
      """
      dataset_dict = copy.deepcopy(
          dataset_dict
      )  # it will be modified by code below
      image = utils.read_image(
          dataset_dict["file_name"], format=self.img_format
      )
      utils.check_image_size(dataset_dict, image)
  
      image, transforms = T.apply_transform_gens(
          self.augmentation, image
      )
      image_shape = image.shape[:2]  # h, w
      dataset_dict["image"] = torch.as_tensor(
          image.transpose(2, 0, 1).astype("float32")
      )
  
      if not self.is_train:
          dataset_dict.pop("annotations", None)
          return dataset_dict
  
      for anno in dataset_dict["annotations"]:
          if not self.mask_on:
              anno.pop("segmentation", None)
          if not self.keypoint_on:
              anno.pop("keypoints", None)
  
      # USER: Implement additional transformations if you have other types of data
      # USER: Don't call transpose_densepose if you don't need
      annos = [
          self._transform_densepose(
              utils.transform_instance_annotations(
                  obj,
                  transforms,
                  image_shape,
                  keypoint_hflip_indices=self.keypoint_hflip_indices,
              ),
              transforms,
          )
          for obj in dataset_dict.pop("annotations")
          if obj.get("iscrowd", 0) == 0
      ]
  
      if self.mask_on:
          self._add_densepose_masks_as_segmentation(annos, image_shape)
  
      instances = utils.annotations_to_instances(
          annos, image_shape, mask_format="bitmask"
      )
      densepose_annotations = [obj.get("densepose") for obj in annos]
      if densepose_annotations and not all(
          v is None for v in densepose_annotations
      ):
          instances.gt_densepose = DensePoseList(
              densepose_annotations, instances.gt_boxes, image_shape
          )
  
      dataset_dict["instances"] = instances[
          instances.gt_boxes.nonempty()
      ]
      return dataset_dict
  
file_path: detectron2/projects/DensePose/densepose/data/dataset_mapper.py
imports: import copy
  import logging
  from typing import Any, Dict, List, Tuple
  import torch
  from detectron2.data import MetadataCatalog
  from detectron2.data import detection_utils
  from detectron2.data import transforms
  from detectron2.layers import ROIAlign
  from detectron2.structures import BoxMode
  from detectron2.utils.file_io import PathManager
  from densepose.structures import DensePoseDataRelative, DensePoseList, DensePoseTransformData
label_desc: Use image node_id 2 for calling the DatasetMapper obj's underlying member method code with example usage: obj.__call__(dataset_dict) and returns: dataset_dict, dataset_dict