Comments (3)
Yes this is possible, you can provide a custom embedding by simply setting the embedding_features
dimension in the constructor and choose where you want to have cross attention blocks (like with text-cond):
from audio_diffusion_pytorch import DiffusionModel, UNetV0, VDiffusion, VSampler
model = DiffusionModel(
net_t=UNetV0, # The model type used for diffusion
in_channels=2, # U-Net: number of input/output (audio) channels
channels=[8, 32, 64, 128, 256, 512, 512, 1024, 1024], # U-Net: channels at each layer
factors=[1, 4, 4, 4, 2, 2, 2, 2, 2], # U-Net: downsampling and upsampling factors at each layer
items=[1, 2, 2, 2, 2, 2, 2, 4, 4], # U-Net: number of repeating items at each layer
attentions=[0, 0, 0, 0, 0, 1, 1, 1, 1], # U-Net: attention enabled/disabled at each layer
attention_heads=8, # U-Net: number of attention heads per attention block
attention_features=64, # U-Net: number of attention features per attention block,
diffusion_t=VDiffusion, # The diffusion method used
sampler_t=VSampler, # The diffusion sampler used
embedding_features=768, # U-Net: embedding features
cross_attentions=[0, 0, 0, 1, 1, 1, 1, 1, 1], # U-Net: cross-attention enabled/disabled at each layer
)
# Train model with audio
audio_wave = torch.randn(1, 2, 2**18) # [batch, in_channels, length]
embedding = torch.randn(1, 1, 768) # [batch, num_embeddings, embedding_features]
loss = model(audio_wave, embedding=embedding)
loss.backward()
noise = torch.randn(1, 2, 2**18)
sample = model.sample(noise, embedding=embedding, num_steps=2)
This example uses one embedding vector per batch, but you can use multiple
from audio-diffusion-pytorch.
Thank you very much for your answer !
I also want to ask how to realize the introduction of conditional information within the network ? Is it similar to latent diffusion ?
The second question is how to enhance the network 's ability to learn conditional information or generalization ability ? By increasing the number of cross-attention modules ?
Thank you very much!
from audio-diffusion-pytorch.
Yes, increasing the number of cross attention layers might help to to enhance the conditional information (note that I'd do this by increasing the number of items per layer, not the number of cross attentions per item). Also during inference you can increase the classifier free guidance scale.
from audio-diffusion-pytorch.
Related Issues (20)
- Add support to clip predicted samples to the desired range. HOT 2
- Alternative Noises: Offset, Pyramid, Pink HOT 2
- Spectrogram-based diffusion model HOT 2
- New Try
- Questions about conditional generation HOT 2
- Trained models
- Languages HOT 1
- Model architectures from the paper HOT 5
- Future Work - Models
- Can the repo be used to process MIDI data๏ผ
- AssertionError: ClassiferFreeGuidancePlugin requires embedding
- Class-conditional generation HOT 1
- I have a few questions about 1D-UNet HOT 4
- What is the structure of encoder in diffusionAE? HOT 1
- CUDA OF Memory for 80GB A100 : follow the mousai paper setting of text condition
- Unconditional model generates okay quality of fake human voice but failed on music. HOT 5
- RuntimeError: The size of tensor a (37) must match the size of tensor b (36) at non-singleton dimension 2 HOT 4
- Unconditional Generation generates noise
- RuntimeError: The size of tensor a (91) must match the size of tensor b (90) at non-singleton dimension 2
- Weird spikes in the loss
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audio-diffusion-pytorch.