Stable Diffusion web UI 运行报错 Error while deserializing header: MetadataIncompleteBuffer

在尝试从HuggingFace仓库下载并加载Stable-diffusion-v1-5模型的safetensors文件时,遇到了一个SafetensorError。问题似乎是文件的元数据在反序列化过程中不完整。解决方案包括手动删除并重新下载模型文件到指定目录,并确保文件路径正确无误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Use --skip-version-check commandline argument to disable this check.
==============================================================================
Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to D:\code\ai\sd.webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors

  2%|█▌                                                                          | 86.5M/3.97G [01:44<1:20:22, 866kB/s]
Calculating sha256 for D:\code\ai\sd.webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors: preload_extensions_git_metadata for 7 extensions took 0.00s
9351bb829b90c2645b2c0f0860aea4b319b69c59544a4bf5120965c33034940c
Loading weights [9351bb829b] from D:\code\ai\sd.webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
loading stable diffusion model: SafetensorError
Traceback (most recent call last):
  File "threading.py", line 973, in _bootstrap
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "D:\code\ai\sd.webui\webui\webui.py", line 306, in load_model
    shared.sd_model  # noqa: B018
  File "D:\code\ai\sd.webui\webui\modules\shared.py", line 726, in sd_model
    return modules.sd_models.model_data.get_sd_model()
  File "D:\code\ai\sd.webui\webui\modules\sd_models.py", line 422, in get_sd_model
    load_model()
  File "D:\code\ai\sd.webui\webui\modules\sd_models.py", line 455, in load_model
    state_dict = get_checkpoint_state_dict(checkpoint_info, timer)
  File "D:\code\ai\sd.webui\webui\modules\sd_models.py", line 271, in get_checkpoint_state_dict
    res = read_state_dict(checkpoint_info.filename)
  File "D:\code\ai\sd.webui\webui\modules\sd_models.py", line 250, in read_state_dict
    pl_sd = safetensors.torch.load_file(checkpoint_file, device=device)
  File "D:\code\ai\sd.webui\system\python\lib\site-packages\safetensors\torch.py", line 259, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
safetensors_rust.SafetensorError: Error while deserializing header: MetadataIncompleteBuffer


Stable diffusion model failed to load
Applying attention optimization: Doggettx... done.
Traceback (most recent call last):
  File "D:\code\ai\sd.webui\webui\launch.py", line 38, in <module>
    main()
  File "D:\code\ai\sd.webui\webui\launch.py", line 34, in main
    start()
  File "D:\code\ai\sd.webui\webui\modules\launch_utils.py", line 344, in start
    webui.webui()
  File "D:\code\ai\sd.webui\webui\webui.py", line 390, in webui
    app, local_url, share_url = shared.demo.launch(
  File "D:\code\ai\sd.webui\system\python\lib\site-packages\gradio\blocks.py", line 1806, in launch
    raise ValueError(
ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.

1、改成手动下载文件,注意要想删除D:\code\ai\sd.webui\webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors文件,每个人路径不一样,看上面的错误日志是上面地址。

2、删除后手动下载,并移动到D:\code\ai\sd.webui\webui\models\Stable-diffusion\路径下,同样要根据日志改成你的地址。

3、从这个地址下载文件,https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors,注意后续的地址可能不一样,具体地址看报错里面的。

image.png
### 可能的报错原因分析 Stable Diffusion WebUI 是一个功能强大的工具,但在启动过程中可能会遇到各种错误。以下是可能导致问题的一些常见因素: 1. **模型文件缺失或损坏** 如果 `codeformer-v0.1.0.pth` 文件未正确放置在指定目录下 (`stable-diffusion-webui\models\Codeformer`) 或者该文件已损坏,则可能引发加载失败的问题[^1]。 2. **依赖库版本不匹配** Stable Diffusion WebUI 的正常运行需要特定版本的 Python 和其他依赖项。如果这些依赖项未正确安装或者存在冲突,也可能导致程序无法启动[^2]。 3. **代码路径问题** 若某些模块(如 `modules.py`)被修改或删除,这会直接影响到整个项目的初始化过程[^3]。 4. **硬件兼容性不足** 部分高级特性可能需要较强的 GPU 支持。如果没有满足最低硬件要求,WebUI 将难以正常工作[^4]。 --- ### 解决方案 #### 方法一:验证并修复模型文件 确认 `codeformer-v0.1.0.pth` 是否存在于相应位置,并检查其完整性。可以通过重新下载官方发布的预训练权重来替换现有文件: ```bash wget https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer-v0.1.0.pth -P stable-diffusion-webui/models/Codeformer/ ``` #### 方法二:更新环境配置 确保所有必要的软件包都按照教程中的指导完成安装。对于 Windows 用户来说,推荐遵循 GitHub 上提供的自动安装指南: ```bash git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git cd stable-diffusion-webui pip install -r requirements.txt ``` #### 方法三:排查编码异常 仔细审查 `modules.py` 中是否存在语法错误或其他逻辑缺陷。必要时可对比原始仓库里的标准版本进行修正。 #### 方法四:优化系统资源分配 考虑到高性能计算的需求,建议关闭不必要的后台进程以释放更多内存给 WebUI 使用;同时调整显卡驱动至最新稳定版以便获得更好的性能表现. --- ### 注意事项 以上措施需逐一尝试直至找到根本原因所在。另外,在操作之前最好备份好当前设置以免造成数据丢失风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值