AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

PyTorch Image Transforms

Sample a transform. Trace the order. Check the target.

Your transform

Enabled. Settings apply on the next run. Changing a disabled block’s settings only changes its future configuration.

Probability of applying the whole mirror, not a fraction of pixels. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Selected sampled stage: Run needed.

Run needed for current settings. Setting changes invalidate the previous result.

Your image pipeline

Prepare the entire photo as RGB 224×224, which can change its aspect ratio. Then apply enabled stages in order. This browser simulation does not execute PyTorch: its RNG, nearest-neighbor geometry and byte rounding differ from Python/PIL.

Prepared RGB 224×224
Settings changed or photo loading. Press Run pipeline when ready.

Pixel signature not sampled

Current composed result
Settings changed or photo loading. Press Run pipeline when ready.

Pixel signature not sampled

Signatures summarize display bytes for comparison; equal signatures are not mathematical proof of equal images. ToTensor changes representation, so it keeps the display signature.

A reproducible browser draw, not a torch seed. Each operation has its own keyed stream so moving it keeps its sampled parameters fixed. It does not guarantee Python will draw the same values. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Transform pipeline, in order

Enable a block to include it in the code. Move up/down works with mouse or keyboard. ToTensor and RandomErasing occupy the final type-safe positions.

  1. Final position
  2. Final position

Output representation

Configured output type; requires a successful run to observe it.

CHW

float32 [3,224,224] · byte/255

The browser displays byte pixels; Python creates the real tensor.

Retained target

One-hot target: a 1 only at class 0, cat.

[1,0,0,0]

The caller retains the selected target.

An unchanged target does not guarantee a transform suits the task.

Sampled stages

Every row receives the previous row’s pixels. Changed-pixel counts compare a stage to its own input, not to the original photo. A sampled operation may leave pixels unchanged (for example Identity); enabled and visibly changed are different.

No current sampled trace. Run the valid pipeline.

Python configuration and simulation limits

Runnable torchvision v1 reference configuration for an RGB PIL input after explicit square preparation. Replace example.jpg with your image. It uses Python’s RNG and torchvision/PIL kernels; the browser seed, samples and pixel signatures are not reproduced by this code. Enabled stages have the required types and order.

from PIL import Image
from torchvision import transforms as T

# torchvision v1 API. Python uses its own random draws.
# Square preparation resizes the full photo, including its aspect ratio.
prepare = T.Resize((224, 224))
pipeline = T.Compose([
    T.RandomHorizontalFlip(p=0),
    T.ToTensor(),
])
image = prepare(Image.open("example.jpg").convert("RGB"))
result = pipeline(image)
# The caller retains the class target only when these changes suit the task.

Browser geometries use nearest-neighbor sampling with black fill, crop rejection/fallback and reflected 5×5 Gaussian blur. Color operations use per-stage display-byte arithmetic. Python/PIL interpolation, float precision and RNG differ. All fourteen predefined policy operations are available: Identity, ShearX/Y, TranslateX/Y, Rotate, Brightness, Color, Contrast, Sharpness, Posterize, Solarize, AutoContrast, Equalize. RandAugment names may repeat; no learning is performed.