arcadiaaaaa
Add files using upload-large-folder tool
24303c9 verified
Raw History Blame Contribute Delete
1.32 kB
import torch
from audio_diffusion_pytorch import DiffusionModel, UNetV0, VDiffusion, VSampler
from module.models_s1 import DiT
latent_dim = 4
cond_channels = 192
net =DiT(latent_dim, cond_channels)
model = DiffusionModel(
net=net, # The model type used for diffusion (U-Net V0 in this case)
in_channels=2, # U-Net: number of input/output (audio) channels
channels=[8, 32], # U-Net: channels at each layer
factors=[1, 4,], # U-Net: downsampling and upsampling factors at each layer
items=[1, 2], # U-Net: number of repeating items at each layer
attentions=[0, 0, ], # U-Net: attention enabled/disabled at each layer
attention_heads=8, # U-Net: number of attention heads per attention item
attention_features=64, # U-Net: number of attention features per attention item
diffusion_t=VDiffusion, # The diffusion method used
sampler_t=VSampler, # The diffusion sampler used
)
print('n params:', sum(p.numel() for p in model.parameters())/1e6, 'M')
audio = torch.randn(2, 4, 111)
cond = torch.randn(2, 192, 111)
loss = model(audio, cond=cond)
loss.backward()
print(loss)
# # Turn noise into new audio sample with diffusion
noise = torch.randn(2, 4, 111)
sample = model.sample(noise, num_steps=10,cond=cond, show_progress=True) # Suggested num_steps 10-100
print(sample.shape)