Shortcuts

JPEG

class torchvision.transforms.v2.JPEG(quality: Union[int, Sequence[int]])[source]

Apply JPEG compression and decompression to the given images.

If the input is a torch.Tensor, it is expected to be of dtype uint8, on CPU, and have […, 3 or 1, H, W] shape, where … means an arbitrary number of leading dimensions.

Parameters:

quality (sequence or number) – JPEG quality, from 1 to 100. Lower means more compression. If quality is a sequence like (min, max), it specifies the range of JPEG quality to randomly select from (inclusive of both ends).

Returns:

image with JPEG compression.

Examples using JPEG:

Illustration of transforms

Illustration of transforms

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