tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Adding some audio transforms and augmentations to tonic

Open MinaKh opened this issue 7 months ago • 24 comments

This branch includes following updates in tonic/develop:

  • Three transforms are added to audio_transforms.py:

    • SwapAxes, AmplitudeScale and robustAmplitudeScale
  • A new script is added: audio_augmentations.py containing wrapper classes for following audio augmentations:

    • RandomAmplitudeScale
    • RandomPitchShift
    • RandomTimeStreatch
    • RIR: adding room impulse response (echo effect)
    • AddWhiteNoise
  • corresponding tests added: test_audio_trnasform.py

  • A new script added for testing audio augmentations ---> test_audio_augmentations.py

  • A tutorial notebook is added in docs/tutorials/

MinaKh avatar Nov 24 '23 12:11 MinaKh

@MinaKh I think you should add torchaudio to the test requirements.txt, 'cause it fails as dependency in the CI tests.

fabrizio-ottati avatar Nov 24 '23 15:11 fabrizio-ottati

@MinaKh I think you should add torchaudio to the test requirements.txt, 'cause it fails as dependency in the CI tests.

Thanks, just did!

MinaKh avatar Nov 24 '23 15:11 MinaKh

It seems that the tests now are running using CUDA. Maybe it is better to run them with everything on CPU? Or we could modify the requirements.txt to install the GPU version of PyTorch (both vision and audio).

fabrizio-ottati avatar Nov 24 '23 15:11 fabrizio-ottati

It seems that the tests now are running using CUDA. Maybe it is better to run them with everything on CPU? Or we could modify the requirements.txt to install the GPU version of PyTorch (both vision and audio).

@fabrizio-ottati No, I can set them to run on cpu. Also there are other tests that I passed on my machine but fail on CI. I need to fix without need to install extra packages. Thanks!

MinaKh avatar Nov 24 '23 15:11 MinaKh

The Github Actions test suite doens't have a GPU installed, therefore there's no point in installing any CUDA dependencies. Tests should always run on CPU please. Thank you

biphasic avatar Nov 25 '23 13:11 biphasic

The Github Actions test suite doens't have a GPU installed, therefore there's no point in installing any CUDA dependencies. Tests should always run on CPU please. Thank you

Thanks @biphasic, As far as I checked my tests are not running on GPU. The error might be caused by general imports of torch and torchaudio, or by the difference in my local version and the installed one on the server. So I included the versions in the requirements. At this point I need to be able to run tests on GitHub to understand the issue better and fix it. Currently tests are not running automatically after my pushes (perhaps needs to be authorized every time by you and other admins?).

MinaKh avatar Nov 27 '23 10:11 MinaKh

@MinaKh are the tests passing on your local machine?

biphasic avatar Nov 28 '23 17:11 biphasic

Also I just relaxed the Github actions approval to the minimum level possible, I hope it now works without my manual approval!

biphasic avatar Nov 28 '23 18:11 biphasic

Hi @biphasic, Thanks for facilitating this! It seems that we need to explicitly install cpu version of torchaudio in ci-pipeline.yml. Lines 24, 45 and 66 need to be updated to following: pip install torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cpu I tried to do that but apparently I don't have permission to update the workflow:

(refusing to allow a Personal Access Token to create or update workflow .github/workflows/ci-pipeline.ymlwithoutworkflow scope)

How shall we proceed?

MinaKh avatar Dec 04 '23 16:12 MinaKh

where do you see that error? I see a different error, again related to CUDA https://github.com/neuromorphs/tonic/actions/runs/7089430652/job/19294156537?pr=273

biphasic avatar Dec 05 '23 07:12 biphasic

where do you see that error? I see a different error, again related to CUDA https://github.com/neuromorphs/tonic/actions/runs/7089430652/job/19294156537?pr=273

MinaKh avatar Dec 05 '23 09:12 MinaKh

where do you see that error? I see a different error, again related to CUDA https://github.com/neuromorphs/tonic/actions/runs/7089430652/job/19294156537?pr=273

@biphasic Yes I see this error and I think its because we don't specify the cpu version while installing torchaudio. To fix that I proposed that update in the ci-pipeline.yml And the error that I included in the last message is what I see in my pc, not being able to push to ci-pipeline.yml . I am not authorized to push to workflow! sorry I accidentally closed the previous comment and don't know how to undo that!

MinaKh avatar Dec 05 '23 09:12 MinaKh

Will get on it! On 5 Dec 2023, at 10:54, Mina Khoei @.***> wrote:

where do you see that error? I see a different error, again related to CUDA https://github.com/neuromorphs/tonic/actions/runs/7089430652/job/19294156537?pr=273

@biphasic Yes I see this error and I think what causes that is we dont specify the cpu version while installing torchaudio. Tofix that I proposed that update in the ci-pipeline.yml And the error that I included in the last message is what I see in my pc. not being able to push to ci-pipeline.yml . I am not authorized to push to workflow

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

fabrizio-ottati avatar Dec 05 '23 09:12 fabrizio-ottati

@fabrizio-ottati Thanks Fabrizio, sorry I just accidentally closed this PR :D Can you undo that?

MinaKh avatar Dec 05 '23 10:12 MinaKh

Ok, reopened! sorry for the inconvenience!

MinaKh avatar Dec 05 '23 10:12 MinaKh

@MinaKh I need to sit and do it properly. I will update you this afternoon

fabrizio-ottati avatar Dec 05 '23 10:12 fabrizio-ottati

image

I don't know why but it keeps installing the CUDA version even if I have specificied to use the CPU wheel of PyTorch.

fabrizio-ottati avatar Dec 05 '23 11:12 fabrizio-ottati

Okay, it seems I convinced it @MinaKh :)

fabrizio-ottati avatar Dec 05 '23 11:12 fabrizio-ottati

Codecov Report

Attention: Patch coverage is 97.19626% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 77.72%. Comparing base (e5bd291) to head (0af124a). Report is 22 commits behind head on develop.

Files Patch % Lines
tonic/audio_transforms.py 92.00% 2 Missing :warning:
tonic/audio_augmentations.py 98.78% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #273      +/-   ##
===========================================
+ Coverage    76.84%   77.72%   +0.88%     
===========================================
  Files           53       55       +2     
  Lines         3001     3174     +173     
===========================================
+ Hits          2306     2467     +161     
- Misses         695      707      +12     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Dec 05 '23 11:12 codecov-commenter

Okay, it seems I convinced it @MinaKh :)

Okay, it seems I convinced it @MinaKh :)

Thanks @fabrizio-ottati

MinaKh avatar Dec 05 '23 12:12 MinaKh

@biphasic all the tests are passing now. I have created a separate test/torch_requirements.txt so that I can pull the CPU wheel of PyTorch. Moreover, following torchaudio documentation, specific combinations of torch and torchaudio versions need to be used to ensure safe installation.

Now the code is ready to be reviewed and CI should be safe.

fabrizio-ottati avatar Dec 05 '23 12:12 fabrizio-ottati

Most transforms are encapsulated enough so that I can add them, but some stuff that uses QUTNoise things I won't be able to merge like that, unless it is made a bit more general. For example, maybe Tonic has a AddNoise class, but then in your user code at SynSense you call it with AddNoise(QUTNoise), after the principle of dependency injection

@biphasic I removed those classes (noise augmentations) from this branch. currently it is very specific and I will prepare another PR later for that.

MinaKh avatar Dec 05 '23 13:12 MinaKh

What's the status on this PR? :)

fabrizio-ottati avatar Jan 21 '24 22:01 fabrizio-ottati

What's the status on this PR? :)

It is ready for final review...

MinaKh avatar Jan 22 '24 09:01 MinaKh