我有一个 pytorch
.ckpt
文件,我需要将其转换为 .bin
文件。
我尝试在 Python 3.10.11 中执行该代码:
import torch
# Load the checkpoint file
checkpoint = torch.load("checkpoint.ckpt")
# Extract the model parameters
params = checkpoint["model_state_dict"]
# Save the parameters to a .bin file
torch.save(params, "model.bin")
我得到了这个错误:
File "D:\Model\trial_ckpt converter.py", line 4, in <module>
checkpoint = torch.load("checkpoint.ckpt")
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serialization.py", line 797, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\serialization.py", line 283, in __init__
super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
有人知道这方面的解决方案吗?