游雁
2024-01-13 bdfd27b9e96bd55c449953bb577e1d4deeaf11c9
funasr/train_utils/load_pretrained_model.py
@@ -105,6 +105,7 @@
    else:
        buffer = BytesIO(oss_bucket.get_object(path).read())
        src_state = torch.load(buffer, map_location=map_location)
    src_state = src_state["model"] if "model" in src_state else src_state
    if excludes is not None:
        for e in excludes.split(","):
            src_state = {k: v for k, v in src_state.items() if not k.startswith(e)}
@@ -120,6 +121,7 @@
    if ignore_init_mismatch:
        src_state = filter_state_dict(dst_state, src_state)
    # logging.info("Loaded src_state keys: {}".format(src_state.keys()))
    logging.debug("Loaded src_state keys: {}".format(src_state.keys()))
    logging.debug("Loaded dst_state keys: {}".format(dst_state.keys()))
    dst_state.update(src_state)
    obj.load_state_dict(dst_state)