Shortcuts

PackInputs

class mmpretrain.datasets.transforms.PackInputs(input_key='img', algorithm_keys=(), meta_keys=('sample_idx', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'flip', 'flip_direction'))[source]

Pack the inputs data.

Required Keys:

  • input_key

  • *algorithm_keys

  • *meta_keys

Deleted Keys:

All other keys in the dict.

Added Keys:

  • inputs (torch.Tensor): The forward data of models.

  • data_samples (DataSample): The annotation info of the sample.

Parameters:
  • input_key (str) – The key of element to feed into the model forwarding. Defaults to ‘img’.

  • algorithm_keys (Sequence[str]) – The keys of custom elements to be used in the algorithm. Defaults to an empty tuple.

  • meta_keys (Sequence[str]) – The keys of meta information to be saved in the data sample. Defaults to PackInputs.DEFAULT_META_KEYS.

Default algorithm keys

Besides the specified algorithm_keys, we will set some default keys into the output data sample and do some formatting. Therefore, you don’t need to set these keys in the algorithm_keys.

  • gt_label: The ground-truth label. The value will be converted into a 1-D tensor.

  • gt_score: The ground-truth score. The value will be converted into a 1-D tensor.

  • mask: The mask for some self-supervise tasks. The value will be converted into a tensor.

Default meta keys

  • sample_idx: The id of the image sample.

  • img_path: The path to the image file.

  • ori_shape: The original shape of the image as a tuple (H, W).

  • img_shape: The shape of the image after the pipeline as a tuple (H, W).

  • scale_factor: The scale factor between the resized image and the original image.

  • flip: A boolean indicating if image flip transform was used.

  • flip_direction: The flipping direction.

transform(results)[source]

Method to pack the input data.

Read the Docs v: latest
Versions
latest
stable
mmcls-1.x
mmcls-0.x
dev
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.