liugz18
2024-07-18 d80ac2fd2df4e7fb8a28acfa512bb11472b5cc99
funasr/train_utils/load_pretrained_model.py
@@ -52,14 +52,19 @@
    if excludes is not None:
        if isinstance(excludes, str):
            excludes = excludes.split(",")
    logging.info(f"excludes: {excludes}")
    for k in dst_state.keys():
        for k_ex in excludes:
            if k.startswith(k_ex):
                logging.info(f"key: {{k}} matching: {k_ex}, excluded")
                continue
        excludes_flag = False
        if excludes is not None:
            for k_ex in excludes:
                if k.startswith(k_ex):
                    logging.info(f"key: {k} matching: {k_ex}, excluded")
                    excludes_flag = True
                    break
        if excludes_flag:
            continue
        k_src = k
@@ -91,7 +96,7 @@
                dst_state[k] = src_state[k_src]
        else:
            logging.info(f"Warning, miss key in ckpt: {k}, mapped: {k_src}")
            print(f"Warning, miss key in ckpt: {k}, {path}")
    flag = obj.load_state_dict(dst_state, strict=True)
    logging.info(f"Loading ckpt: {path}, status: {flag}")