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

Method run_model

usr/diffsinger_task.py:123–153  ·  view source on GitHub ↗
(self, model, sample, return_output=False, infer=False)

Source from the content-addressed store, hash-verified

121 # self.model.fs2.decoder = None
122
123 def run_model(self, model, sample, return_output=False, infer=False):
124 txt_tokens = sample['txt_tokens'] # [B, T_t]
125 target = sample['mels'] # [B, T_s, 80]
126 mel2ph = sample['mel2ph'] # [B, T_s]
127 f0 = sample['f0']
128 uv = sample['uv']
129 energy = sample['energy']
130 fs2_mel = None #sample['fs2_mels']
131 spk_embed = sample.get('spk_embed') if not hparams['use_spk_id'] else sample.get('spk_ids')
132 if hparams['pitch_type'] == 'cwt':
133 cwt_spec = sample[f'cwt_spec']
134 f0_mean = sample['f0_mean']
135 f0_std = sample['f0_std']
136 sample['f0_cwt'] = f0 = model.cwt2f0_norm(cwt_spec, f0_mean, f0_std, mel2ph)
137
138 output = model(txt_tokens, mel2ph=mel2ph, spk_embed=spk_embed,
139 ref_mels=[target, fs2_mel], f0=f0, uv=uv, energy=energy, infer=infer)
140
141 losses = {}
142 if 'diff_loss' in output:
143 losses['mel'] = output['diff_loss']
144 # self.add_dur_loss(output['dur'], mel2ph, txt_tokens, losses=losses)
145 # if hparams['use_pitch_embed']:
146 # self.add_pitch_loss(output, sample, losses)
147 if hparams['use_energy_embed']:
148 self.add_energy_loss(output['energy_pred'], energy, losses)
149
150 if not return_output:
151 return losses
152 else:
153 return losses, output
154
155 def validation_step(self, sample, batch_idx):
156 outputs = {}

Callers 2

validation_stepMethod · 0.95
validation_stepMethod · 0.45

Calls 2

add_energy_lossMethod · 0.80
cwt2f0_normMethod · 0.45

Tested by

no test coverage detected