MCPcopy Create free account
hub / github.com/ace-step/ACE-Step / predict_step

Method predict_step

trainer.py:715–767  ·  view source on GitHub ↗
(self, batch)

Source from the content-addressed store, hash-verified

713 return target_latents
714
715 def predict_step(self, batch):
716 (
717 keys,
718 target_latents,
719 attention_mask,
720 encoder_text_hidden_states,
721 text_attention_mask,
722 speaker_embds,
723 lyric_token_ids,
724 lyric_mask,
725 mert_ssl_hidden_states,
726 mhubert_ssl_hidden_states,
727 ) = self.preprocess(batch, train=False)
728
729 infer_steps = 60
730 guidance_scale = 15.0
731 omega_scale = 10.0
732 seed_num = 1234
733 random.seed(seed_num)
734 bsz = target_latents.shape[0]
735 random_generators = [torch.Generator(device=self.device) for _ in range(bsz)]
736 seeds = []
737 for i in range(bsz):
738 seed = random.randint(0, 2**32 - 1)
739 random_generators[i].manual_seed(seed)
740 seeds.append(seed)
741 duration = 240 # Fixed duration (24 * 10)
742 pred_latents = self.diffusion_process(
743 duration=duration,
744 encoder_text_hidden_states=encoder_text_hidden_states,
745 text_attention_mask=text_attention_mask,
746 speaker_embds=speaker_embds,
747 lyric_token_ids=lyric_token_ids,
748 lyric_mask=lyric_mask,
749 random_generators=random_generators,
750 infer_steps=infer_steps,
751 guidance_scale=guidance_scale,
752 omega_scale=omega_scale,
753 )
754
755 audio_lengths = batch["wav_lengths"]
756 sr, pred_wavs = self.dcae.decode(
757 pred_latents, audio_lengths=audio_lengths, sr=48000
758 )
759 return {
760 "target_wavs": batch["target_wavs"],
761 "pred_wavs": pred_wavs,
762 "keys": keys,
763 "prompts": batch["prompts"],
764 "candidate_lyric_chunks": batch["candidate_lyric_chunks"],
765 "sr": sr,
766 "seeds": seeds,
767 }
768
769 def construct_lyrics(self, candidate_lyric_chunk):
770 lyrics = []

Callers 1

plot_stepMethod · 0.95

Calls 3

preprocessMethod · 0.95
diffusion_processMethod · 0.95
decodeMethod · 0.45

Tested by

no test coverage detected