forked from mrq/DL-Art-School
some random crap
This commit is contained in:
parent
6655f7845a
commit
47662b9ec5
|
@ -378,7 +378,6 @@ class ResBlock(nn.Module):
|
||||||
dropout,
|
dropout,
|
||||||
out_channels=None,
|
out_channels=None,
|
||||||
use_conv=False,
|
use_conv=False,
|
||||||
use_scale_shift_norm=False,
|
|
||||||
dims=2,
|
dims=2,
|
||||||
up=False,
|
up=False,
|
||||||
down=False,
|
down=False,
|
||||||
|
@ -389,7 +388,6 @@ class ResBlock(nn.Module):
|
||||||
self.dropout = dropout
|
self.dropout = dropout
|
||||||
self.out_channels = out_channels or channels
|
self.out_channels = out_channels or channels
|
||||||
self.use_conv = use_conv
|
self.use_conv = use_conv
|
||||||
self.use_scale_shift_norm = use_scale_shift_norm
|
|
||||||
padding = 1 if kernel_size == 3 else 2
|
padding = 1 if kernel_size == 3 else 2
|
||||||
|
|
||||||
self.in_layers = nn.Sequential(
|
self.in_layers = nn.Sequential(
|
||||||
|
@ -427,7 +425,7 @@ class ResBlock(nn.Module):
|
||||||
else:
|
else:
|
||||||
self.skip_connection = conv_nd(dims, channels, self.out_channels, 1)
|
self.skip_connection = conv_nd(dims, channels, self.out_channels, 1)
|
||||||
|
|
||||||
def forward(self, x, emb):
|
def forward(self, x):
|
||||||
"""
|
"""
|
||||||
Apply the block to a Tensor, conditioned on a timestep embedding.
|
Apply the block to a Tensor, conditioned on a timestep embedding.
|
||||||
|
|
||||||
|
@ -435,7 +433,7 @@ class ResBlock(nn.Module):
|
||||||
:return: an [N x C x ...] Tensor of outputs.
|
:return: an [N x C x ...] Tensor of outputs.
|
||||||
"""
|
"""
|
||||||
return checkpoint(
|
return checkpoint(
|
||||||
self._forward, x, emb
|
self._forward, x
|
||||||
)
|
)
|
||||||
|
|
||||||
def _forward(self, x):
|
def _forward(self, x):
|
||||||
|
|
|
@ -327,7 +327,7 @@ class Trainer:
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-opt', type=str, help='Path to option YAML file.', default='../options/train_tortoise_random_latent_gen_diffuser.yml')
|
parser.add_argument('-opt', type=str, help='Path to option YAML file.', default='../experiments/train_mel_upsampler.yml')
|
||||||
parser.add_argument('--launcher', choices=['none', 'pytorch'], default='none', help='job launcher')
|
parser.add_argument('--launcher', choices=['none', 'pytorch'], default='none', help='job launcher')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
opt = option.parse(args.opt, is_train=True)
|
opt = option.parse(args.opt, is_train=True)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from models.diffusion.gaussian_diffusion import get_named_beta_schedule
|
||||||
from models.diffusion.respace import space_timesteps, SpacedDiffusion
|
from models.diffusion.respace import space_timesteps, SpacedDiffusion
|
||||||
from scripts.audio.gen.speech_synthesis_utils import load_discrete_vocoder_diffuser, wav_to_mel, load_speech_dvae, \
|
from scripts.audio.gen.speech_synthesis_utils import load_discrete_vocoder_diffuser, wav_to_mel, load_speech_dvae, \
|
||||||
convert_mel_to_codes, load_univnet_vocoder, wav_to_univnet_mel
|
convert_mel_to_codes, load_univnet_vocoder, wav_to_univnet_mel
|
||||||
from trainer.injectors.audio_injectors import denormalize_tacotron_mel, TorchMelSpectrogramInjector
|
from trainer.injectors.audio_injectors import denormalize_tacotron_mel, TorchMelSpectrogramInjector, pixel_shuffle_1d
|
||||||
from utils.util import ceil_multiple, opt_get, load_model_from_config, pad_or_truncate
|
from utils.util import ceil_multiple, opt_get, load_model_from_config, pad_or_truncate
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,10 +64,11 @@ class MusicDiffusionFid(evaluator.Evaluator):
|
||||||
else:
|
else:
|
||||||
real_resampled = audio
|
real_resampled = audio
|
||||||
audio = audio.unsqueeze(0)
|
audio = audio.unsqueeze(0)
|
||||||
output_shape = audio.shape
|
output_shape = (1, 16, audio.shape[-1] // 16)
|
||||||
mel = self.spec_fn({'in': audio})['out']
|
mel = self.spec_fn({'in': audio})['out']
|
||||||
gen = self.diffuser.p_sample_loop(self.model, output_shape, noise=torch.zeros(*output_shape, device=audio.device),
|
gen = self.diffuser.p_sample_loop(self.model, output_shape, noise=torch.zeros(*output_shape, device=audio.device),
|
||||||
model_kwargs={'aligned_conditioning': mel})
|
model_kwargs={'aligned_conditioning': mel})
|
||||||
|
gen = pixel_shuffle_1d(gen, 16)
|
||||||
real_resampled = real_resampled + torch.FloatTensor(real_resampled.shape).uniform_(0.0, 1e-5).to(real_resampled.device)
|
real_resampled = real_resampled + torch.FloatTensor(real_resampled.shape).uniform_(0.0, 1e-5).to(real_resampled.device)
|
||||||
return gen, real_resampled, sample_rate
|
return gen, real_resampled, sample_rate
|
||||||
|
|
||||||
|
@ -149,8 +150,8 @@ class MusicDiffusionFid(evaluator.Evaluator):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
diffusion = load_model_from_config('X:\\dlas\\experiments\\train_music_waveform_gen3.yml', 'generator',
|
diffusion = load_model_from_config('X:\\dlas\\experiments\\train_music_waveform_gen3.yml', 'generator',
|
||||||
also_load_savepoint=False,
|
also_load_savepoint=False,
|
||||||
load_path='X:\\dlas\\experiments\\train_music_waveform_gen3_r0\\models\\15400_generator_ema.pth').cuda()
|
load_path='X:\\dlas\\experiments\\train_music_waveform_gen3_r1\\models\\10000_generator_ema.pth').cuda()
|
||||||
opt_eval = {'path': 'Y:\\split\\yt-music-eval', 'diffusion_steps': 100,
|
opt_eval = {'path': 'Y:\\split\\yt-music-eval', 'diffusion_steps': 50,
|
||||||
'conditioning_free': False, 'conditioning_free_k': 1,
|
'conditioning_free': False, 'conditioning_free_k': 1,
|
||||||
'diffusion_schedule': 'linear', 'diffusion_type': 'standard'}
|
'diffusion_schedule': 'linear', 'diffusion_type': 'standard'}
|
||||||
env = {'rank': 0, 'base_path': 'D:\\tmp\\test_eval_music', 'step': 1, 'device': 'cuda', 'opt': {}}
|
env = {'rank': 0, 'base_path': 'D:\\tmp\\test_eval_music', 'step': 1, 'device': 'cuda', 'opt': {}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user