From cae52c52f3d322b39346e7b784b839ef995bffcb Mon Sep 17 00:00:00 2001
From: zhifu gao <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 04 三月 2024 18:43:26 +0800
Subject: [PATCH] Revert "Revert "Dev yf" (#1418)" (#1420)
---
funasr/train_utils/load_pretrained_model.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/funasr/train_utils/load_pretrained_model.py b/funasr/train_utils/load_pretrained_model.py
index 84c6320..0c46449 100644
--- a/funasr/train_utils/load_pretrained_model.py
+++ b/funasr/train_utils/load_pretrained_model.py
@@ -7,7 +7,7 @@
import torch
import torch.nn
import torch.optim
-
+import pdb
def filter_state_dict(
dst_state: Dict[str, Union[float, torch.Tensor]],
@@ -63,14 +63,15 @@
dst_state = obj.state_dict()
print(f"ckpt: {path}")
+
if oss_bucket is None:
src_state = torch.load(path, map_location=map_location)
else:
buffer = BytesIO(oss_bucket.get_object(path).read())
src_state = torch.load(buffer, map_location=map_location)
- if "state_dict" in src_state:
- src_state = src_state["state_dict"]
-
+
+ src_state = src_state["state_dict"] if "state_dict" in src_state else src_state
+ src_state = src_state["model_state_dict"] if "model_state_dict" in src_state else src_state
src_state = src_state["model"] if "model" in src_state else src_state
if isinstance(scope_map, str):
--
Gitblit v1.9.1