File size: 285 Bytes
d487776
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
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'})