import os def get_pth_file(dir_path): file_list = [] for root, dirs, files in os.walk(dir_path): for file in files: if file.endswith("pth"): file_list.append(os.path.join(root, file)) return file_list file_list = get_pth_file("./") epoch = max([epochs.split("/")[-1].split("_")[0] for epochs in file_list]) pth_path = f"{epoch}_epochs.pth" config_json = "config.json"