text stringlengths 0 5.54k |
|---|
provided, text embeddings will be generated from prompt input argument. negative_prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, e.g. prompt |
weighting. If not provided, negative_prompt_embeds will be generated from negative_prompt input |
argument. pooled_prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated pooled text embeddings. Can be used to easily tweak text inputs, e.g. prompt weighting. |
If not provided, pooled text embeddings will be generated from prompt input argument. negative_pooled_prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated negative pooled text embeddings. Can be used to easily tweak text inputs, e.g. prompt |
weighting. If not provided, pooled negative_prompt_embeds will be generated from negative_prompt |
input argument. lora_scale (float, optional) β |
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded. clip_skip (int, optional) β |
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that |
the output of the pre-final layer will be used for computing the prompt embeddings. Encodes the prompt into text encoder hidden states. get_guidance_scale_embedding < source > ( w embedding_dim = 512 dtype = torch.float32 ) β torch.FloatTensor Parameters timesteps (torch.Tensor) β |
generate embedding vectors at these timesteps embedding_dim (int, optional, defaults to 512) β |
dimension of the embeddings to generate |
dtype β |
data type of the generated embeddings Returns |
torch.FloatTensor |
Embedding vectors with shape (len(timesteps), embedding_dim) |
See https://github.com/google-research/vdm/blob/dc27b98a554f65cdc654b800da5aa1846545d41b/model_vdm.py#L298 |
MusicLDM MusicLDM was proposed in MusicLDM: Enhancing Novelty in Text-to-Music Generation Using Beat-Synchronous Mixup Strategies by Ke Chen, Yusong Wu, Haohe Liu, Marianna Nezhurina, Taylor Berg-Kirkpatrick, Shlomo Dubnov. |
MusicLDM takes a text prompt as input and predicts the corresponding music sample. Inspired by Stable Diffusion and AudioLDM, |
MusicLDM is a text-to-music latent diffusion model (LDM) that learns continuous audio representations from CLAP |
latents. MusicLDM is trained on a corpus of 466 hours of music data. Beat-synchronous data augmentation strategies are applied to the music samples, both in the time domain and in the latent space. Using beat-synchronous data augmentation strategies encourages the model to interpolate between the training samples, but ... |
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations. text_encoder (ClapModel) β |
Frozen text-audio embedding model (ClapTextModel), specifically the |
laion/clap-htsat-unfused variant. tokenizer (PreTrainedTokenizer) β |
A RobertaTokenizer to tokenize text. feature_extractor (ClapFeatureExtractor) β |
Feature extractor to compute mel-spectrograms from audio waveforms. unet (UNet2DConditionModel) β |
A UNet2DConditionModel to denoise the encoded audio latents. scheduler (SchedulerMixin) β |
A scheduler to be used in combination with unet to denoise the encoded audio latents. Can be one of |
DDIMScheduler, LMSDiscreteScheduler, or PNDMScheduler. vocoder (SpeechT5HifiGan) β |
Vocoder of class SpeechT5HifiGan. Pipeline for text-to-audio generation using MusicLDM. This model inherits from DiffusionPipeline. Check the superclass documentation for the generic methods |
implemented for all pipelines (downloading, saving, running on a particular device, etc.). __call__ < source > ( prompt: Union = None audio_length_in_s: Optional = None num_inference_steps: int = 200 guidance_scale: float = 2.0 negative_prompt: Union = None num_waveforms_per_prompt: Optional = 1 eta: float = 0.0 gene... |
The prompt or prompts to guide audio generation. If not defined, you need to pass prompt_embeds. audio_length_in_s (int, optional, defaults to 10.24) β |
The length of the generated audio sample in seconds. num_inference_steps (int, optional, defaults to 200) β |
The number of denoising steps. More denoising steps usually lead to a higher quality audio at the |
expense of slower inference. guidance_scale (float, optional, defaults to 2.0) β |
A higher guidance scale value encourages the model to generate audio that is closely linked to the text |
prompt at the expense of lower sound quality. Guidance scale is enabled when guidance_scale > 1. negative_prompt (str or List[str], optional) β |
The prompt or prompts to guide what to not include in audio generation. If not defined, you need to |
pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1). num_waveforms_per_prompt (int, optional, defaults to 1) β |
The number of waveforms to generate per prompt. If num_waveforms_per_prompt > 1, the text encoding |
model is a joint text-audio model (ClapModel), and the tokenizer is a |
[~transformers.ClapProcessor], then automatic scoring will be performed between the generated outputs |
and the input text. This scoring ranks the generated waveforms based on their cosine similarity to text |
input in the joint text-audio embedding space. eta (float, optional, defaults to 0.0) β |
Corresponds to parameter eta (Ξ·) from the DDIM paper. Only applies |
to the DDIMScheduler, and is ignored in other schedulers. generator (torch.Generator or List[torch.Generator], optional) β |
A torch.Generator to make |
generation deterministic. latents (torch.FloatTensor, optional) β |
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image |
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 generator. prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not |
provided, text embeddings are generated from the prompt input argument. negative_prompt_embeds (torch.FloatTensor, optional) β |
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If |
not provided, negative_prompt_embeds are generated from the negative_prompt input argument. return_dict (bool, optional, defaults to True) β |
Whether or not to return a AudioPipelineOutput instead of a plain tuple. callback (Callable, optional) β |
A function that calls every callback_steps steps during inference. The function is called with the |
following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor). callback_steps (int, optional, defaults to 1) β |
The frequency at which the callback function is called. If not specified, the callback is called at |
every step. cross_attention_kwargs (dict, optional) β |
A kwargs dictionary that if specified is passed along to the AttentionProcessor as defined in |
self.processor. output_type (str, optional, defaults to "np") β |
The output format of the generated audio. Choose between "np" to return a NumPy np.ndarray or |
"pt" to return a PyTorch torch.Tensor object. Set to "latent" to return the latent diffusion |
model (LDM) output. Returns |
AudioPipelineOutput or tuple |
If return_dict is True, AudioPipelineOutput is returned, otherwise a tuple is |
returned where the first element is a list with the generated audio. |
The call function to the pipeline for generation. Examples: Copied >>> from diffusers import MusicLDMPipeline |
>>> import torch |
>>> import scipy |
>>> repo_id = "ucsd-reach/musicldm" |
>>> pipe = MusicLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float16) |
>>> pipe = pipe.to("cuda") |
>>> prompt = "Techno music with a strong, upbeat tempo and high melodic riffs" |
>>> audio = pipe(prompt, num_inference_steps=10, audio_length_in_s=5.0).audios[0] |
>>> # save the audio sample as a .wav file |
>>> scipy.io.wavfile.write("techno.wav", rate=16000, data=audio) disable_vae_slicing < source > ( ) Disable sliced VAE decoding. If enable_vae_slicing was previously enabled, this method will go back to |
computing decoding in one step. enable_model_cpu_offload < source > ( gpu_id = 0 ) 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. enable_vae_slicing < source > ( ) 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. |
Activation functions Customized activation functions for supporting various models in π€ Diffusers. GELU class diffusers.models.activations.GELU < source > ( dim_in: int dim_out: int approximate: str = 'none' bias: bool = True ) Parameters dim_in (int) β The number of channels in the input. dim_out (int) β Th... |
paper. |
Loading and Adding Custom Pipelines |
Diffusers allows you to conveniently load any custom pipeline from the Hugging Face Hub as well as any official community pipeline |
via the DiffusionPipeline class. |
Loading custom pipelines from the Hub |
Custom pipelines can be easily loaded from any model repository on the Hub that defines a diffusion pipeline in a pipeline.py file. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.