Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
step_or_epoch bugfix
游雁d4f13c2e444f
diff --git a/funasr/train_utils/trainer.py b/funasr/train_utils/trainer.pyindex 5fe34b970..d0be9c807 100644--- a/funasr/train_utils/trainer.py+++ b/funasr/train_utils/trainer.py@@ -161,8 +161,8 @@ class Trainer:# self.step_or_epoch += 1state = {"epoch": epoch,- 'step': step,- 'total_step': self.batch_total,+ "step": step,+ "total_step": self.batch_total,"state_dict": model.state_dict(),"optimizer": optim.state_dict(),"scheduler": scheduler.state_dict(),@@ -171,7 +171,6 @@ class Trainer:"val_loss_step_or_epoch": self.val_loss_step_or_epoch,"best_step_or_epoch": self.best_step_or_epoch,"avg_keep_nbest_models_type": self.avg_keep_nbest_models_type,- "step": step,"step_in_epoch": step_in_epoch,"data_split_i": kwargs.get("data_split_i", 0),"data_split_num": kwargs.get("data_split_num", 1),@@ -194,9 +193,9 @@ class Trainer:ckpt_name = f"model.pt.ep{epoch}.{step}"filename = os.path.join(self.output_dir, ckpt_name)torch.save(state, filename)- logging.info(f'Checkpoint saved to {filename}')+ logging.info(f"Checkpoint saved to {filename}")- latest = Path(os.path.join(self.output_dir, f'model.pt'))+ latest = Path(os.path.join(self.output_dir, f"model.pt"))torch.save(state, latest)if self.best_step_or_epoch == "":@@ -333,7 +332,6 @@ class Trainer:if self.use_ddp or self.use_fsdp:dist.barrier()-def train_epoch(self,model=None,@@ -591,9 +589,9 @@ class Trainer:time4 = time.perf_counter()if torch.isfinite(loss):- self.val_loss_avg = (self.val_loss_avg * batch_idx + loss.detach().cpu().item()) / (- batch_idx + 1- )+ self.val_loss_avg = (+ self.val_loss_avg * batch_idx + loss.detach().cpu().item()+ ) / (batch_idx + 1)if "acc" in stats:self.val_acc_avg = (