MCPcopy Index your code
hub / github.com/MoonInTheRiver/DiffSinger / validation_step

Method validation_step

usr/diffspeech_task.py:80–107  ·  view source on GitHub ↗
(self, sample, batch_idx)

Source from the content-addressed store, hash-verified

78 return losses, output
79
80 def validation_step(self, sample, batch_idx):
81 outputs = {}
82 txt_tokens = sample['txt_tokens'] # [B, T_t]
83
84 energy = sample['energy']
85 spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids')
86 mel2ph = sample['mel2ph']
87 f0 = sample['f0']
88 uv = sample['uv']
89
90 outputs['losses'] = {}
91
92 outputs['losses'], model_out = self.run_model(self.model, sample, return_output=True, infer=False)
93
94
95 outputs['total_loss'] = sum(outputs['losses'].values())
96 outputs['nsamples'] = sample['nsamples']
97 outputs = utils.tensors_to_scalars(outputs)
98 if batch_idx < hparams['num_valid_plots']:
99 # model_out = self.model(
100 # txt_tokens, spk_embed=spk_embed, mel2ph=None, f0=None, uv=None, energy=None, ref_mels=None, infer=True)
101 # self.plot_mel(batch_idx, model_out['mel_out'], model_out['fs2_mel'], name=f'diffspeech_vs_fs2_{batch_idx}')
102 model_out = self.model(
103 txt_tokens, spk_embed=spk_embed, mel2ph=mel2ph, f0=f0, uv=uv, energy=energy, ref_mels=None, infer=True)
104 gt_f0 = denorm_f0(sample['f0'], sample['uv'], hparams)
105 self.plot_wav(batch_idx, sample['mels'], model_out['mel_out'], is_mel=True, gt_f0=gt_f0, f0=model_out.get('f0_denorm'))
106 self.plot_mel(batch_idx, sample['mels'], model_out['mel_out'])
107 return outputs
108
109 ############
110 # validation plots

Callers

nothing calls this directly

Calls 4

run_modelMethod · 0.95
plot_wavMethod · 0.95
denorm_f0Function · 0.90
plot_melMethod · 0.80

Tested by

no test coverage detected