-
Notifications
You must be signed in to change notification settings - Fork 6k
add AudioDiffusionPipeline and LatentAudioDiffusionPipeline #1334
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f44a57a
add AudioDiffusionPipeline and LatentAudioDiffusionPipeline
teticio 2ad4d9e
add docs to toc
teticio 2e25d89
fix tests
teticio 54d6625
fix tests
teticio 0700c19
fix tests
teticio 13efb5b
fix tests
teticio e750dad
fix tests
teticio 499ff34
Update pr_tests.yml
teticio 55706de
parent 499ff34b3edc3e0c506313ab48f21514d8f58b09
teticio 6957b5a
move Mel to module in pipeline construction, make librosa optional
teticio 95e0908
fix imports
teticio 6a3d02f
fix copy & paste error in comment
teticio c15504c
fix style
teticio 2045310
add missing register_to_config
teticio f0c0a62
fix class docstrings
teticio 3971462
fix class docstrings
teticio 9e5ea5c
tweak docstrings
teticio e7be31c
tweak docstrings
teticio e9d4e43
update slow test
teticio b873540
merge with upstream
teticio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,4 +165,6 @@ tags | |
# DS_Store (MacOS) | ||
.DS_Store | ||
# RL pipelines may produce mp4 outputs | ||
*.mp4 | ||
*.mp4 | ||
|
||
hf-internal-testing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<!--Copyright 2022 The HuggingFace Team. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
--> | ||
|
||
# Audio Diffusion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool docs! |
||
|
||
## Overview | ||
|
||
[Audio Diffusion](https://github.com/teticio/audio-diffusion) by Robert Dargavel Smith. | ||
|
||
Audio Diffusion leverages the recent advances in image generation using diffusion models by converting audio samples to | ||
and from mel spectrogram images. | ||
|
||
The original codebase of this implementation can be found [here](https://github.com/teticio/audio-diffusion), including | ||
training scripts and example notebooks. | ||
|
||
## Available Pipelines: | ||
|
||
| Pipeline | Tasks | Colab | ||
|---|---|:---:| | ||
| [pipeline_audio_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/audio_diffusion/pipeline_audio_diffusion.py) | *Unconditional Audio Generation* | [](https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/audio_diffusion_pipeline.ipynb) | | ||
| [pipeline_latent_audio_diffusion.py](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/audio_diffusion/pipeline_latent_audio_diffusion.py) | *Unconditional Latent Audio Generation* | [](https://colab.research.google.com/github/teticio/audio-diffusion/blob/master/notebooks/audio_diffusion_pipeline.ipynb) | | ||
|
||
|
||
## Examples: | ||
|
||
### Audio Diffusion | ||
|
||
```python | ||
import torch | ||
from IPython.display import Audio | ||
from diffusers import DiffusionPipeline | ||
|
||
device = "cuda" if torch.cuda.is_available() else "cpu" | ||
pipe = DiffusionPipeline.from_pretrained("teticio/audio-diffusion-256").to(device) | ||
|
||
output = pipe() | ||
display(output.images[0]) | ||
display(Audio(output.audios[0], rate=mel.get_sample_rate())) | ||
``` | ||
|
||
### Latent Audio Diffusion | ||
|
||
```python | ||
import torch | ||
from IPython.display import Audio | ||
from diffusers import DiffusionPipeline | ||
|
||
device = "cuda" if torch.cuda.is_available() else "cpu" | ||
pipe = DiffusionPipeline.from_pretrained("teticio/latent-audio-diffusion-256").to(device) | ||
|
||
output = pipe() | ||
display(output.images[0]) | ||
display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate())) | ||
``` | ||
|
||
### Audio Diffusion with DDIM (faster) | ||
|
||
```python | ||
import torch | ||
from IPython.display import Audio | ||
from diffusers import DiffusionPipeline | ||
|
||
device = "cuda" if torch.cuda.is_available() else "cpu" | ||
pipe = DiffusionPipeline.from_pretrained("teticio/audio-diffusion-ddim-256").to(device) | ||
|
||
output = pipe() | ||
display(output.images[0]) | ||
display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate())) | ||
``` | ||
|
||
### Variations, in-painting, out-painting etc. | ||
|
||
```python | ||
output = pipe( | ||
raw_audio=output.audios[0, 0], | ||
start_step=int(pipe.get_default_steps() / 2), | ||
mask_start_secs=1, | ||
mask_end_secs=1, | ||
) | ||
display(output.images[0]) | ||
display(Audio(output.audios[0], rate=pipe.mel.get_sample_rate())) | ||
``` | ||
|
||
## AudioDiffusionPipeline | ||
[[autodoc]] AudioDiffusionPipeline | ||
- __call__ | ||
- encode | ||
- slerp | ||
|
||
|
||
## LatentAudioDiffusionPipeline | ||
[[autodoc]] LatentAudioDiffusionPipeline | ||
- __call__ | ||
|
||
|
||
## Mel | ||
[[autodoc]] Mel | ||
- audio_slice_to_image | ||
- image_to_audio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me @anton-l what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing @patrickvonplaten !