SAG-ViT / convert_safetensors_to_bin.py
shravvvv's picture
Added pytorch_model.bin
2f6eb09
raw
history blame contribute delete
400 Bytes
import torch
from safetensors.torch import load_file
from transformers import AutoConfig, AutoModel
# Path to your safetensors file
safetensors_path = "model.safetensors"
bin_path = "pytorch_model.bin"
# Load model weights from safetensors
state_dict = load_file(safetensors_path)
# Save as pytorch_model.bin
torch.save(state_dict, bin_path)
print(f"Converted {safetensors_path} to {bin_path}.")