AudioLDM 2¶
AudioLDM 2 was proposed in AudioLDM 2: Learning Holistic Audio Generation with Self-supervised Pretraining by Haohe Liu et al. AudioLDM 2 takes a text prompt as input and predicts the corresponding audio. It can generate text-conditional sound effects, human speech and music.
Inspired by Stable Diffusion, AudioLDM 2 is a text-to-audio latent diffusion model (LDM) that learns continuous audio representations from text embeddings. Two text encoder models are used to compute the text embeddings from a prompt input: the text-branch of CLAP and the encoder of Flan-T5. These text embeddings are then projected to a shared embedding space by an AudioLDM2ProjectionModel. A GPT2 language model (LM) is used to auto-regressively predict eight new embedding vectors, conditional on the projected CLAP and Flan-T5 embeddings. The generated embedding vectors and Flan-T5 text embeddings are used as cross-attention conditioning in the LDM. The UNet of AudioLDM 2 is unique in the sense that it takes two cross-attention embeddings, as opposed to one cross-attention conditioning, as in most other LDMs.
The abstract of the paper is the following:
Although audio generation shares commonalities across different types of audio, such as speech, music, and sound effects, designing models for each type requires careful consideration of specific objectives and biases that can significantly differ from those of other types. To bring us closer to a unified perspective of audio generation, this paper proposes a framework that utilizes the same learning method for speech, music, and sound effect generation. Our framework introduces a general representation of audio, called "language of audio" (LOA). Any audio can be translated into LOA based on AudioMAE, a self-supervised pre-trained representation learning model. In the generation process, we translate any modalities into LOA by using a GPT-2 model, and we perform self-supervised audio generation learning with a latent diffusion model conditioned on LOA. The proposed framework naturally brings advantages such as in-context learning abilities and reusable self-supervised pretrained AudioMAE and latent diffusion models. Experiments on the major benchmarks of text-to-audio, text-to-music, and text-to-speech demonstrate state-of-the-art or competitive performance against previous approaches. Our code, pretrained model, and demo are available at this https URL.
This pipeline was contributed by sanchit-gandhi and Nguyễn Công Tú Anh. The original codebase can be found at haoheliu/audioldm2.
Tips¶
Choosing a checkpoint¶
AudioLDM2 comes in three variants. Two of these checkpoints are applicable to the general task of text-to-audio generation. The third checkpoint is trained exclusively on text-to-music generation.
All checkpoints share the same model size for the text encoders and VAE. They differ in the size and depth of the UNet. See table below for details on the three checkpoints:
Checkpoint | Task | UNet Model Size | Total Model Size | Training Data / h |
---|---|---|---|---|
audioldm2 | Text-to-audio | 350M | 1.1B | 1150k |
audioldm2-large | Text-to-audio | 750M | 1.5B | 1150k |
audioldm2-music | Text-to-music | 350M | 1.1B | 665k |
audioldm2-gigaspeech | Text-to-speech | 350M | 1.1B | 10k |
audioldm2-ljspeech | Text-to-speech | 350M | 1.1B |
Constructing a prompt¶
- Descriptive prompt inputs work best: use adjectives to describe the sound (e.g. "high quality" or "clear") and make the prompt context specific (e.g. "water stream in a forest" instead of "stream").
- It's best to use general terms like "cat" or "dog" instead of specific names or abstract objects the model may not be familiar with.
- Using a negative prompt can significantly improve the quality of the generated waveform, by guiding the generation away from terms that correspond to poor quality audio. Try using a negative prompt of "Low quality."
Controlling inference¶
- The quality of the predicted audio sample can be controlled by the
num_inference_steps
argument; higher steps give higher quality audio at the expense of slower inference. - The length of the predicted audio sample can be controlled by varying the
audio_length_in_s
argument.
Evaluating generated waveforms:¶
- The quality of the generated waveforms can vary significantly based on the seed. Try generating with different seeds until you find a satisfactory generation.
- Multiple waveforms can be generated in one go: set
num_waveforms_per_prompt
to a value greater than 1. Automatic scoring will be performed between the generated waveforms and prompt text, and the audios ranked from best to worst accordingly.
The following example demonstrates how to construct good music and speech generation using the aforementioned tips: example.
Tip
Make sure to check out the Schedulers guide to learn how to explore the tradeoff between scheduler speed and quality, and see the reuse components across pipelines section to learn how to efficiently load the same components into multiple pipelines.
mindone.diffusers.AudioLDM2Pipeline
¶
Bases: DiffusionPipeline
Pipeline for text-to-audio generation using AudioLDM2.
This model inherits from [DiffusionPipeline
]. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving etc.).
PARAMETER | DESCRIPTION |
---|---|
vae |
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.
TYPE:
|
text_encoder |
First frozen text-encoder. AudioLDM2 uses the joint audio-text embedding model CLAP, specifically the laion/clap-htsat-unfused variant. The text branch is used to encode the text prompt to a prompt embedding. The full audio-text model is used to rank generated waveforms against the text prompt by computing similarity scores.
TYPE:
|
text_encoder_2 |
Second frozen text-encoder. AudioLDM2 uses the encoder of T5, specifically the google/flan-t5-large variant. Second frozen text-encoder use for TTS. AudioLDM2 uses the encoder of Vits.
TYPE:
|
projection_model |
A trained model used to linearly project the hidden-states from the first and second text encoder models and insert learned SOS and EOS token embeddings. The projected hidden-states from the two text encoders are concatenated to give the input to the language model. A Learned Position Embedding for the Vits hidden-states
TYPE:
|
language_model |
An auto-regressive language model used to generate a sequence of hidden-states conditioned on the projected outputs from the two text encoders.
TYPE:
|
tokenizer |
Tokenizer to tokenize text for the first frozen text-encoder.
TYPE:
|
tokenizer_2 |
Tokenizer to tokenize text for the second frozen text-encoder.
TYPE:
|
feature_extractor |
Feature extractor to pre-process generated audio waveforms to log-mel spectrograms for automatic scoring.
TYPE:
|
unet |
A
TYPE:
|
scheduler |
A scheduler to be used in combination with
TYPE:
|
vocoder |
Vocoder of class
TYPE:
|
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
|
mindone.diffusers.AudioLDM2Pipeline.__call__(prompt=None, transcription=None, audio_length_in_s=None, num_inference_steps=200, guidance_scale=3.5, negative_prompt=None, num_waveforms_per_prompt=1, eta=0.0, generator=None, latents=None, prompt_embeds=None, negative_prompt_embeds=None, generated_prompt_embeds=None, negative_generated_prompt_embeds=None, attention_mask=None, negative_attention_mask=None, max_new_tokens=None, return_dict=False, callback=None, callback_steps=1, cross_attention_kwargs=None, output_type='np')
¶
The call function to the pipeline for generation.
PARAMETER | DESCRIPTION |
---|---|
prompt |
The prompt or prompts to guide audio generation. If not defined, you need to pass
TYPE:
|
transcription |
\ The transcript for text to speech.
TYPE:
|
audio_length_in_s |
The length of the generated audio sample in seconds.
TYPE:
|
num_inference_steps |
The number of denoising steps. More denoising steps usually lead to a higher quality audio at the expense of slower inference.
TYPE:
|
guidance_scale |
A higher guidance scale value encourages the model to generate audio that is closely linked to the text
TYPE:
|
negative_prompt |
The prompt or prompts to guide what to not include in audio generation. If not defined, you need to
pass
TYPE:
|
num_waveforms_per_prompt |
The number of waveforms to generate per prompt. If
TYPE:
|
eta |
Corresponds to parameter eta (η) from the DDIM paper. Only applies
to the [
TYPE:
|
generator |
A
TYPE:
|
latents |
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for spectrogram
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random
TYPE:
|
prompt_embeds |
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the
TYPE:
|
negative_prompt_embeds |
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
not provided,
TYPE:
|
generated_prompt_embeds |
Pre-generated text embeddings from the GPT2 langauge model. Can be used to easily tweak text inputs,
e.g. prompt weighting. If not provided, text embeddings will be generated from
TYPE:
|
negative_generated_prompt_embeds |
Pre-generated negative text embeddings from the GPT2 language model. Can be used to easily tweak text
inputs, e.g. prompt weighting. If not provided, negative_prompt_embeds will be computed from
TYPE:
|
attention_mask |
Pre-computed attention mask to be applied to the
TYPE:
|
negative_attention_mask |
Pre-computed attention mask to be applied to the
TYPE:
|
max_new_tokens |
Number of new tokens to generate with the GPT2 language model. If not provided, number of tokens will be taken from the config of the model.
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
callback |
A function that calls every
TYPE:
|
callback_steps |
The frequency at which the
TYPE:
|
cross_attention_kwargs |
A kwargs dictionary that if specified is passed along to the [
TYPE:
|
output_type |
The output format of the generated audio. Choose between
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
[ |
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
|
mindone.diffusers.AudioLDM2Pipeline.disable_vae_slicing()
¶
Disable sliced VAE decoding. If enable_vae_slicing
was previously enabled, this method will go back to
computing decoding in one step.
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
202 203 204 205 206 207 |
|
mindone.diffusers.AudioLDM2Pipeline.enable_model_cpu_offload()
¶
Offloads all models to CPU using accelerate, reducing memory usage with a low impact on performance. Compared
to enable_sequential_cpu_offload
, this method moves one whole model at a time to the GPU when its forward
method is called, and the model remains in GPU until the next model runs. Memory savings are lower than with
enable_sequential_cpu_offload
, but performance is much better due to the iterative execution of the unet
.
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
209 210 211 212 213 214 215 216 217 218 219 |
|
mindone.diffusers.AudioLDM2Pipeline.enable_vae_slicing()
¶
Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
194 195 196 197 198 199 |
|
mindone.diffusers.AudioLDM2Pipeline.encode_prompt(prompt, num_waveforms_per_prompt, do_classifier_free_guidance, transcription=None, negative_prompt=None, prompt_embeds=None, negative_prompt_embeds=None, generated_prompt_embeds=None, negative_generated_prompt_embeds=None, attention_mask=None, negative_attention_mask=None, max_new_tokens=None)
¶
Encodes the prompt into text encoder hidden states.
PARAMETER | DESCRIPTION |
---|---|
prompt |
prompt to be encoded
TYPE:
|
transcription |
transcription of text to speech
TYPE:
|
num_waveforms_per_prompt |
number of waveforms that should be generated per prompt
TYPE:
|
do_classifier_free_guidance |
whether to use classifier free guidance or not
TYPE:
|
negative_prompt |
The prompt or prompts not to guide the audio generation. If not defined, one has to pass
TYPE:
|
prompt_embeds |
Pre-computed text embeddings from the Flan T5 model. Can be used to easily tweak text inputs, e.g.
prompt weighting. If not provided, text embeddings will be computed from
TYPE:
|
negative_prompt_embeds |
Pre-computed negative text embeddings from the Flan T5 model. Can be used to easily tweak text inputs,
e.g. prompt weighting. If not provided, negative_prompt_embeds will be computed from
TYPE:
|
generated_prompt_embeds |
Pre-generated text embeddings from the GPT2 langauge model. Can be used to easily tweak text inputs,
e.g. prompt weighting. If not provided, text embeddings will be generated from
TYPE:
|
negative_generated_prompt_embeds |
Pre-generated negative text embeddings from the GPT2 language model. Can be used to easily tweak text
inputs, e.g. prompt weighting. If not provided, negative_prompt_embeds will be computed from
TYPE:
|
attention_mask |
Pre-computed attention mask to be applied to the
TYPE:
|
negative_attention_mask |
Pre-computed attention mask to be applied to the
TYPE:
|
max_new_tokens |
The number of new tokens to generate with the GPT2 language model.
TYPE:
|
Example:
>>> import scipy
>>> from mindone.diffusers import AudioLDM2Pipeline
>>> repo_id = "cvssp/audioldm2"
>>> pipe = AudioLDM2Pipeline.from_pretrained(repo_id, torch_dtype=mindspore.float16)
>>> # Get text embedding vectors
>>> prompt_embeds, attention_mask, generated_prompt_embeds = pipe.encode_prompt(
... prompt="Techno music with a strong, upbeat tempo and high melodic riffs",
... do_classifier_free_guidance=True,
... )
>>> # Pass text embeddings to pipeline for text-conditional audio generation
>>> audio = pipe(
... prompt_embeds=prompt_embeds,
... attention_mask=attention_mask,
... generated_prompt_embeds=generated_prompt_embeds,
... num_inference_steps=200,
... audio_length_in_s=10.0,
... ).audios[0]
>>> # save generated audio sample
>>> scipy.io.wavfile.write("techno.wav", rate=16000, data=audio)
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
mindone.diffusers.AudioLDM2Pipeline.generate_language_model(inputs_embeds=None, max_new_tokens=8, **model_kwargs)
¶
Generates a sequence of hidden-states from the language model, conditioned on the embedding inputs.
PARAMETER | DESCRIPTION |
---|---|
inputs_embeds |
The sequence used as a prompt for the generation.
TYPE:
|
max_new_tokens |
Number of new tokens to generate.
TYPE:
|
model_kwargs |
Ad hoc parametrization of additional model-specific kwargs that will be forwarded to the
TYPE:
|
Return
inputs_embeds (
mindspore.tensorof shape
(batch_size, sequence_length, hidden_size)`):
The sequence of generated hidden-states.
Source code in mindone/diffusers/pipelines/audioldm2/pipeline_audioldm2.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
mindone.diffusers.AudioLDM2ProjectionModel
¶
Bases: ModelMixin
, ConfigMixin
A simple linear projection model to map two text embeddings to a shared latent space. It also inserts learned
embedding vectors at the start and end of each text embedding sequence respectively. Each variable appended with
_1
refers to that corresponding to the second text encoder. Otherwise, it is from the first.
PARAMETER | DESCRIPTION |
---|---|
text_encoder_dim |
Dimensionality of the text embeddings from the first text encoder (CLAP).
TYPE:
|
text_encoder_1_dim |
Dimensionality of the text embeddings from the second text encoder (T5 or VITS).
TYPE:
|
langauge_model_dim |
Dimensionality of the text embeddings from the language model (GPT2).
TYPE:
|
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
mindone.diffusers.AudioLDM2UNet2DConditionModel
¶
Bases: ModelMixin
, ConfigMixin
, UNet2DConditionLoadersMixin
A conditional 2D UNet model that takes a noisy sample, conditional state, and a timestep and returns a sample
shaped output. Compared to the vanilla [UNet2DConditionModel
], this variant optionally includes an additional
self-attention layer in each Transformer block, as well as multiple cross-attention layers. It also allows for up
to two cross-attention embeddings, encoder_hidden_states
and encoder_hidden_states_1
.
This model inherits from [ModelMixin
]. Check the superclass documentation for it's generic methods implemented
for all models (such as downloading or saving).
PARAMETER | DESCRIPTION |
---|---|
sample_size |
Height and width of input/output sample.
TYPE:
|
in_channels |
Number of channels in the input sample.
TYPE:
|
out_channels |
Number of channels in the output.
TYPE:
|
flip_sin_to_cos |
Whether to flip the sin to cos in the time embedding.
TYPE:
|
freq_shift |
The frequency shift to apply to the time embedding.
TYPE:
|
down_block_types |
The tuple of downsample blocks to use.
TYPE:
|
mid_block_type |
Block type for middle of UNet, it can only be
TYPE:
|
up_block_types |
The tuple of upsample blocks to use.
TYPE:
|
only_cross_attention |
Whether to include self-attention in the basic transformer blocks, see
[
TYPE:
|
block_out_channels |
The tuple of output channels for each block.
TYPE:
|
layers_per_block |
The number of layers per block.
TYPE:
|
downsample_padding |
The padding to use for the downsampling convolution.
TYPE:
|
mid_block_scale_factor |
The scale factor to use for the mid block.
TYPE:
|
act_fn |
The activation function to use.
TYPE:
|
norm_num_groups |
The number of groups to use for the normalization.
If
TYPE:
|
norm_eps |
The epsilon to use for the normalization.
TYPE:
|
cross_attention_dim |
The dimension of the cross attention features.
TYPE:
|
transformer_layers_per_block |
The number of transformer blocks of type [
TYPE:
|
attention_head_dim |
The dimension of the attention heads.
TYPE:
|
num_attention_heads |
The number of attention heads. If not defined, defaults to
TYPE:
|
resnet_time_scale_shift |
Time scale shift config
for ResNet blocks (see [
TYPE:
|
class_embed_type |
The type of class embedding to use which is ultimately summed with the time embeddings. Choose from
TYPE:
|
num_class_embeds |
Input dimension of the learnable embedding matrix to be projected to
TYPE:
|
time_embedding_type |
The type of position embedding to use for timesteps. Choose from
TYPE:
|
time_embedding_dim |
An optional override for the dimension of the projected time embedding.
TYPE:
|
time_embedding_act_fn |
Optional activation function to use only once on the time embeddings before they are passed to the rest of
the UNet. Choose from
TYPE:
|
timestep_post_act |
The second activation function to use in timestep embedding. Choose from
TYPE:
|
time_cond_proj_dim |
The dimension of
TYPE:
|
conv_in_kernel |
The kernel size of
TYPE:
|
conv_out_kernel |
The kernel size of
TYPE:
|
projection_class_embeddings_input_dim |
The dimension of the
TYPE:
|
class_embeddings_concat |
Whether to concatenate the time embeddings with the class embeddings.
TYPE:
|
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
mindone.diffusers.AudioLDM2UNet2DConditionModel.attn_processors: Dict[str, AttentionProcessor]
property
¶
RETURNS | DESCRIPTION |
---|---|
Dict[str, AttentionProcessor]
|
|
Dict[str, AttentionProcessor]
|
indexed by its weight name. |
mindone.diffusers.AudioLDM2UNet2DConditionModel.construct(sample, timestep, encoder_hidden_states, class_labels=None, timestep_cond=None, attention_mask=None, cross_attention_kwargs=None, encoder_attention_mask=None, return_dict=True, encoder_hidden_states_1=None, encoder_attention_mask_1=None)
¶
The [AudioLDM2UNet2DConditionModel
] forward method.
PARAMETER | DESCRIPTION |
---|---|
sample |
The noisy input tensor with the following shape
TYPE:
|
timestep |
The number of timesteps to denoise an input.
TYPE:
|
encoder_hidden_states |
The encoder hidden states with shape
TYPE:
|
encoder_attention_mask |
A cross-attention mask of shape
TYPE:
|
return_dict |
Whether or not to return a [
TYPE:
|
cross_attention_kwargs |
A kwargs dictionary that if specified is passed along to the [
TYPE:
|
encoder_hidden_states_1 |
A second set of encoder hidden states with shape
TYPE:
|
encoder_attention_mask_1 |
A cross-attention mask of shape
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Union[UNet2DConditionOutput, Tuple]
|
[ |
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
mindone.diffusers.AudioLDM2UNet2DConditionModel.set_attention_slice(slice_size)
¶
Enable sliced attention computation.
When this option is enabled, the attention module splits the input tensor in slices to compute attention in several steps. This is useful for saving some memory in exchange for a small decrease in speed.
PARAMETER | DESCRIPTION |
---|---|
slice_size |
When
TYPE:
|
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
mindone.diffusers.AudioLDM2UNet2DConditionModel.set_attn_processor(processor)
¶
Sets the attention processor to use to compute attention.
PARAMETER | DESCRIPTION |
---|---|
processor |
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for all If
TYPE:
|
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
mindone.diffusers.AudioLDM2UNet2DConditionModel.set_default_attn_processor()
¶
Disables custom attention processors and sets the default attention implementation.
Source code in mindone/diffusers/pipelines/audioldm2/modeling_audioldm2.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
|
mindone.diffusers.pipelines.AudioPipelineOutput
dataclass
¶
Bases: BaseOutput
Output class for audio pipelines.
Source code in mindone/diffusers/pipelines/pipeline_utils.py
100 101 102 103 104 105 106 107 108 109 110 |
|