import safetensors | |
from safetensors.torch import save_file | |
tensors = dict() | |
with safetensors.safe_open("./model.safetensors", framework="pt") as f: | |
for key in f.keys(): | |
tensors[key] = f.get_tensor(key) | |
save_file(tensors, "./model.safetensors", metadata={'format': 'pt'}) | |