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

本站现有博文322篇,共被浏览789114

本站已经建立2484天!

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