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

本站现有博文309篇,共被浏览735854

本站已经建立2373天!

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