Shortcuts

Crop

class torchrl.envs.transforms.Crop(w: int, h: int = None, top: int = 0, left: int = 0, in_keys: Sequence[NestedKey] | None = None, out_keys: Sequence[NestedKey] | None = None)[source]

Crops the input image at the specified location and output size.

Parameters:
  • w (int) – resulting width

  • h (int, optional) – resulting height. If None, then w is used (square crop).

  • top (int, optional) – top pixel coordinate to start cropping. Default is 0, i.e. top of the image.

  • left (int, optional) – left pixel coordinate to start cropping. Default is 0, i.e. left of the image.

  • 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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources