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

本站现有博文333篇,共被浏览918613

本站已经建立2624天!

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