File size: 452 Bytes
c71cbeb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from safetensors.torch import save_file
import torch
# Load your PyTorch .bin file
# Replace 'path/to/your/pytorch_model.bin' with the actual path
state_dict = torch.load('pytorch_model.bin')
# Define the output path for the .safetensors file
# Replace 'path/to/your/model.safetensors' with your desired output path
output_path = 'model.safetensors'
# Save the state_dict in safetensors format
save_file(state_dict, output_path)
|