Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any built-in data augmentation function? #49

Closed
LeeYongHyeok opened this issue Sep 24, 2020 · 7 comments
Closed

Is there any built-in data augmentation function? #49

LeeYongHyeok opened this issue Sep 24, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@LeeYongHyeok
Copy link

Hi, I'm so impressed by your wonderful project.
But, I want to know how can i augment the training data (ex. SNR control, time-stretch, speed perturbation, volume or pitch control, specaugment ...)
In the torchaudio, there are built-in parameter for the data transformations. https://pytorch.org/tutorials/beginner/audio_preprocessing_tutorial.html#transformations
Is there any built-in function or parameter for the data augmentation?

@KinWaiCheuk
Copy link
Owner

Hi YongHyeok, thanks for you question. Unfortunately, there is no build in data augmentation in nnAudio at the moment. If you have the augmentation function, however, you can apply it to the PyTorch tensor returned by nnAudio.

@LeeYongHyeok
Copy link
Author

@KinWaiCheuk
Thanks for your detailed answer. Do you have the to-do plan about these function?

@KinWaiCheuk
Copy link
Owner

Yes, I do wish to expand nnAudio by adding more features to it (data augmentation is one of the items on my mind). But we are lack of manpower at the moment (me and my current collaborator are occupied with improving the GriffinLim reconstruction accuracy).

If you know anyone who are interested in contributing, please let me know, it would be a great help for us!

@KinWaiCheuk KinWaiCheuk added the enhancement New feature or request label Oct 20, 2020
@hbredin
Copy link

hbredin commented Oct 21, 2020

Regarding audio augmentation, you might want to join forces with https://github.com/asteroid-team/torch-audiomentations.

@KinWaiCheuk
Copy link
Owner

Regarding audio augmentation, you might want to join forces with https://github.com/asteroid-team/torch-audiomentations.

Wow, it is a really awesome project! If it is the case, I think a build-in data augmentation is not necessary for nnAudio? Since you can always keep one line of code as audio-domain augmentation, another line of code for nnAudio, e.g.

import torch
from torch_audiomentations import Gain
from nnAudio import Spectrogram
class MyModel():
    def __init___(args):
        self.augmentation_layer = Gain(min_gain_in_db=-15.0, max_gain_in_db=5.0, p=0.5)
        self.nnaudio_layer = Spectrogram.STFT()
        self.neuralnet = SomeNeuralNet()

    def forward(x):
        x = self.augmentation_layer(x)
        x = self.nnaudio_layer(x)
        x = self.neuralnet(x)
        return x

Is there any augmentation that cannot be done in this way?

@hbredin
Copy link

hbredin commented Oct 21, 2020

I am sure that someone will eventualy come up with a new augmentation technique that must be done in a different way but I don't know of any for now.

@fdroessler
Copy link

There is also Kornia, I guess that could be used as long as they provide the necessary Augmentations:
https://kornia.readthedocs.io/en/latest/tutorials/data_augmentation.html
and: https://arxiv.org/pdf/2011.09832.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants