EADST

Merge Safetensors to Bin File

Merge Safetensors to Bin File

from safetensors.torch import load_file
import torch
import os

safetensors_dir = "./your_model_folder_path/"

# get the number of safetensors
number = 0
for root, _, files in os.walk(safetensors_dir):
    for file in files:
        if "-of-" in file:
            number = file.split("-of-")[-1].strip(".safetensors")
            break

# merge safetensors to bin
model_data = {}
for i in range(1, int(number)+1):
    file_path = os.path.join(safetensors_dir, f"model-0000{i}-of-{number}.safetensors")
    data = load_file(file_path)
    model_data.update(data)

# save bin
torch.save(model_data, "./your_model_folder_path/pytorch_model.bin") 
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Sklearn Baidu Mixtral Bert Animate PIP CTC Plotly 论文 Random 域名 OpenCV NLTK SAM LeetCode 继承 LaTeX Bipartite 阿里云 报税 RGB Clash TSV Streamlit JSON Miniforge 多进程 搞笑 版权 Nginx CEIR NameSilo uwsgi llama.cpp Ubuntu SQL API 论文速读 关于博主 Gemma Windows FP16 音频 Quantize transformers DeepSeek Search Bin tar mmap GoogLeNet Domain HaggingFace Python 图形思考法 DeepStream 强化学习 飞书 Data C++ 净利润 Website Hilton InvalidArgumentError Qwen2 Disk Qwen Bitcoin PyTorch Review BF16 LLM Template Card Knowledge OCR Magnet 云服务器 Tracking Video 顶会 ONNX Michelin Password Vmess Cloudreve v2ray 证件照 Qwen2.5 Docker Attention CLAP Safetensors Diagram scipy MD5 PDF Heatmap git-lfs ChatGPT Linux Anaconda QWEN Translation TensorFlow Dataset Zip Augmentation icon Excel VGG-16 tqdm WebCrawler 公式 Jupyter NLP Math OpenAI Google Ptyhon 多线程 Claude Permission Freesound GGML XML Color GPTQ BTC Rebuttal GPT4 Logo VSCode Plate 腾讯云 YOLO UI git Use Pytorch Pillow FastAPI FP32 LoRA Tensor GIT Markdown FlashAttention SQLite RAR FP64 IndexTTS2 Shortcut 递归学习法 Crawler AI SVR torchinfo FP8 签证 Web TTS Paddle Pickle hf TensorRT Transformers Quantization 图标 Image2Text diffusers HuggingFace logger uWSGI Agent Llama Tiktoken Pandas WAN VPN Statistics CSV Input Vim Hotel ResNet-50 CAM Conda LLAMA Jetson XGBoost PyCharm Git UNIX Django v0.dev printf CUDA EXCEL Firewall Land Proxy 第一性原理 Hungarian News Base64 SPIE Paper Interview ModelScope Github Datetime Breakpoint Numpy 财报 PDB CC COCO Distillation BeautifulSoup CV Algorithm Food 算法题
站点统计

本站现有博文327篇,共被浏览833614

本站已经建立2538天!

热门文章
文章归档
回到顶部