omniloader.transforms.crop

Sequence cropping transforms (random window for train, center for eval).

Both crops take a fixed-length window along the sequence axis. A single shared offset is applied across every targeted sequence key, so time-aligned features and per-step targets stay in sync. Keys shorter than the requested window are padded back to length with their placeholder value.

Classes

RandomCrop

Crop a random contiguous window of the sequence (training augmentation).

CenterCrop

Crop the centered window of the sequence (deterministic; used for eval).

Module Contents

class omniloader.transforms.crop.RandomCrop(length: int, keys: collections.abc.Sequence[str] | None = None, schema: omniloader.schema.spec.UnifiedSchema | None = None)[source]

Bases: omniloader.transforms.base.Transform

Crop a random contiguous window of the sequence (training augmentation).

Parameters:
  • length – Window length along the sequence axis.

  • keys – Sequence keys to crop with a shared offset. When None, every sequence key in the schema (features and aligned targets) is cropped together (requires schema).

  • schema – Schema used to resolve keys when it is None.

apply(sample: omniloader.transforms.base.Sample, generator: torch.Generator | None) → omniloader.transforms.base.Sample[source]

Crop all targeted keys at one random offset within the valid region.

class omniloader.transforms.crop.CenterCrop(length: int, keys: collections.abc.Sequence[str] | None = None, schema: omniloader.schema.spec.UnifiedSchema | None = None)[source]

Bases: omniloader.transforms.base.Transform

Crop the centered window of the sequence (deterministic; used for eval).

Parameters:
  • length – Window length along the sequence axis.

  • keys – Sequence keys to crop. When None, every sequence key in the schema is cropped (requires schema).

  • schema – Schema used to resolve keys when it is None.

apply(sample: omniloader.transforms.base.Sample, generator: torch.Generator | None) → omniloader.transforms.base.Sample[source]

Crop all targeted keys at the centered offset within the valid region.