asteroid-team / torch-audiomentations

Fast audio data augmentation in PyTorch. Inspired by audiomentations. Useful for deep learning.
MIT License
928 stars 87 forks source link

feat: add Identity transform #130

Closed hbredin closed 2 years ago

hbredin commented 2 years ago

This PR adds the Identity transform that basically does nothing (i.e. returns its input unchanged).

One benefit is to simplify codebase of other libraries using torch_audiomentations (pyannote.audio, I am looking at you ;)):

Before:

if use_augmentation:
    augmentation = MyAugmentation(...)

for samples in dataloader:

  if use_augmentation:
     augmented = augmentation(samples, ...)
  else:
     augmented = samples

After:

augmentation = MyAugmentation(...) if use_augmentation else Identity()

for samples in dataloader:
   augmented = augmentation(samples, ...)
iver56 commented 2 years ago

Sure, why not ^^ Thanks for the contribution