CenterCrop¶
- class torchrl.envs.transforms.CenterCrop(w: int, h: int = None, in_keys: Sequence[NestedKey] | None = None, out_keys: Sequence[NestedKey] | None = None)[source]¶
Crops the center of an image.
- Parameters:
w (int) – resulting width
h (int, optional) – resulting height. If None, then w is used (square crop).
in_keys (sequence of NestedKey, optional) – the entries to crop. If none is provided,
["pixels"]
is assumed.out_keys (sequence of NestedKey, optional) – the cropped images keys. If none is provided,
in_keys
is assumed.
- transform_observation_spec(observation_spec: TensorSpec) TensorSpec [source]¶
Transforms the observation spec such that the resulting spec matches transform mapping.
- Parameters:
observation_spec (TensorSpec) – spec before the transform
- Returns:
expected spec after the transform