win11配置Stable-diffusion-1.5

一、问题描述

最近因为项目需求,需要下载 Stable-diffusion-1.5,项目中给出的配置指令如下:

bash 复制代码
git lfs install
git clone https://huggingface.co/runwayml/stable-diffusion-v1-5
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/runwayml/stable-diffusion-v1-5

然而我在运行时无妨访问网站:

bash 复制代码
(python311) C:\Users\XXX>git lfs install
Git LFS initialized.

(python311) C:\Users\XXX>git clone https://huggingface.co/runwayml/stable-diffusion-v1-5
Cloning into 'stable-diffusion-v1-5'...
fatal: unable to access 'https://huggingface.co/runwayml/stable-diffusion-v1-5/': Failed to connect to huggingface.co port 443 after 21309 ms: Couldn't connect to server

这里先贴几个我觉得比较好的回答:

  1. 这可能是全网最好解决中国hugggingface.co无法访问问题(请看评论区)
  2. 国内访问HuggingFace镜像网站全攻略(2024最新)

二、解决方案

由于我是个小白,之前确实也没有搞过这些东西,所以上面的解决方案我还是看得一知半解,看完了还是不知道最后应该怎么弄。然后我问了下deep seek,这里我的解决方案如下:

  1. 首先第一个指令git lfs install是成功了的,直接来看第二个指令;
  2. git clone https://huggingface.co/runwayml/stable-diffusion-v1-5

法一(失败):使用hf-mirror.com 镜像站

将命令改为如下形式:

bash 复制代码
git clone https://hf-mirror.com/runwayml/stable-diffusion-v1-5

执行后需要登录一下:

这里输入 GitHub 用户名密码或者邮箱登录一下就好了。然后输出如下:

bash 复制代码
Cloning into 'stable-diffusion-v1-5'...
remote: Password authentication in git is no longer supported. You must use a user access token or an SSH key instead. See https://huggingface.co/blog/password-git-deprecation
fatal: Authentication failed for 'https://hf-mirror.com/runwayml/stable-diffusion-v1-5/'

hf-mirror.com 镜像站现在也要求身份验证了(返回 401 状态码),并且它遵循了 Hugging Face 的官方策略------不再支持密码认证,必须使用用户访问令牌(User Access Token)

如何获取token呢?还是需要登录 Hugging Face 获取。无解。

法二(失败):使用 ModelScope 镜像站(git下载)

在终端输入如下命令:

bash 复制代码
git clone https://www.modelscope.cn/runwayml/stable-diffusion-v1-5.git

输出如下:

bash 复制代码
Cloning into 'stable-diffusion-v1-5'...
remote: The project you were looking for could not be found or you don't have permission to view it.
fatal: repository 'https://www.modelscope.cn/runwayml/stable-diffusion-v1-5.git/' not found

没有这个地址。打开阿里达摩院官网,在搜索框中搜索stable-diffusion-v1-5,搜索结果如下:

可以看到正确的路径如图中所示。将命令改为:

bash 复制代码
git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-v1-5.git

接下来是漫长的等待下载过程...

然后出现如下错误:

bash 复制代码
(python311) C:\Users\XXX>git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-v1-5.git
Cloning into 'stable-diffusion-v1-5'...
remote: Enumerating objects: 94, done.
Receiving objects: 100% (94/94), 530.76 KiB | 3.40 MiB/s, done.
remote: Total 94 (delta 0), reused 0 (delta 0), pack-reused 94
Resolving deltas: 100% (28/28), done.
Downloading v1-5-pruned.ckpt (7.7 GB)5 GiB | 284.00 KiB/s
Error downloading object: v1-5-pruned.ckpt (e144158): Smudge error: Error downloading v1-5-pruned.ckpt (e1441589a6f3c5a53f5f54d0975a18a7feb7cdf0b0dee276dfc3331ae376a053): expected OID e1441589a6f3c5a53f5f54d0975a18a7feb7cdf0b0dee276dfc3331ae376a053, got 754f8f58b3887d9c555170089143ad1475a565defecaac1458cfc35bf965e1f3 after 514795922 bytes written

Errors logged to 'C:\Users\XXX\stable-diffusion-v1-5\.git\lfs\logs\20260324T225327.4163635.log'.
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: v1-5-pruned.ckpt: smudge filter lfs failed
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

好像是因为网络不稳定吧,文件又太大,反正折腾了两天以后还是下载失败了。

再回到阿里达摩院官网,我们直接点击模型下方的下载链接,可以看到官方给了我们几个下载命令,分别是命令行下载、SDK下载和git下载:

显然 git 下载命令和项目中给出的参考命令是一致的,也就是我们方法二中尝试的,但是最终失败了。

接下来我们试试使用命令行下载。

法三(成功):使用 ModelScope 镜像站(命令行下载)

在终端依次输入如下命令:

bash 复制代码
pip install modelscope

modelscope download --model AI-ModelScope/stable-diffusion-v1-5 --local_dir E:\XXX\stable-diffusion-v1-5

根据我所配置的项目需求,这里我将文件存放在项目的根目录下。

bash 复制代码
(python311) C:\Users\XXX>modelscope download --model AI-ModelScope/stable-diffusion-v1-5 --local_dir E:\project\Ph\DADO\Diffusion-Domain-Teacher-main\stable-diffusion-v1-5

 _   .-')                _ .-') _     ('-.             .-')                              _ (`-.    ('-.
( '.( OO )_             ( (  OO) )  _(  OO)           ( OO ).                           ( (OO  ) _(  OO)
 ,--.   ,--.).-'),-----. \     .'_ (,------.,--.     (_)---\_)   .-----.  .-'),-----.  _.`     \(,------.
 |   `.'   |( OO'  .-.  ',`'--..._) |  .---'|  |.-') /    _ |   '  .--./ ( OO'  .-.  '(__...--'' |  .---'
 |         |/   |  | |  ||  |  \  ' |  |    |  | OO )\  :` `.   |  |('-. /   |  | |  | |  /  | | |  |
 |  |'.'|  |\_) |  |\|  ||  |   ' |(|  '--. |  |`-' | '..`''.) /_) |OO  )\_) |  |\|  | |  |_.' |(|  '--.
 |  |   |  |  \ |  | |  ||  |   / : |  .--'(|  '---.'.-._)   \ ||  |`-'|   \ |  | |  | |  .___.' |  .--'
 |  |   |  |   `'  '-'  '|  '--'  / |  `---.|      | \       /(_'  '--'\    `'  '-'  ' |  |      |  `---.
 `--'   `--'     `-----' `-------'  `------'`------'  `-----'    `-----'      `-----'  `--'      `------'

Downloading Model from https://www.modelscope.cn to directory: E:\project\Ph\DADO\Diffusion-Domain-Teacher-main\stable-diffusion-v1-5
Downloading [safety_checker/config.json]: 100%|███████████████████████████████████| 4.61k/4.61k [00:00<00:00, 20.3kB/s]
Downloading [vae/config.json]: 100%|██████████████████████████████████████████████████| 547/547 [00:00<00:00, 2.19kB/s]
Downloading [configuration.json]: 100%|███████████████████████████████████████████| 1.65k/1.65k [00:00<00:00, 6.91kB/s]
Downloading [text_encoder/config.json]: 100%|█████████████████████████████████████████| 617/617 [00:00<00:00, 2.35kB/s]
Downloading [unet/config.json]: 100%|█████████████████████████████████████████████████| 743/743 [00:00<00:00, 2.10kB/s]
Downloading [model_index.json]: 100%|█████████████████████████████████████████████████| 543/543 [00:00<00:00, 2.18kB/s]
Downloading [tokenizer/merges.txt]: 100%|███████████████████████████████████████████| 512k/512k [00:00<00:00, 1.22MB/s]
Downloading [feature_extractor/preprocessor_config.json]: 100%|█████████████████████████| 342/342 [00:00<00:00, 615B/s]
Downloading [text_encoder/model.safetensors]: 100%|█████████████████████████████████| 469M/469M [04:41<00:00, 1.75MB/s]
Downloading [README.md]: 100%|████████████████████████████████████████████████████| 14.0k/14.0k [00:00<00:00, 32.0kB/s]
Downloading [scheduler/scheduler_config.json]: 100%|████████████████████████████████████| 308/308 [00:00<00:00, 839B/s]
Downloading [tokenizer/special_tokens_map.json]: 100%|████████████████████████████████| 472/472 [00:00<00:00, 1.25kB/s]
Downloading [tokenizer/tokenizer_config.json]: 100%|██████████████████████████████████| 806/806 [00:00<00:00, 1.79kB/s]
Downloading [vae/diffusion_pytorch_model.bin]: 100%|█████████████████████████████████| 319M/319M [10:49<00:00, 515kB/s]
Downloading [vae/diffusion_pytorch_model.safetensors]: 100%|█████████████████████████| 319M/319M [11:55<00:00, 468kB/s]
Downloading [safety_checker/pytorch_model.bin]: 100%|█████████████████████████████| 1.13G/1.13G [12:33<00:00, 1.61MB/s]
Downloading [text_encoder/pytorch_model.bin]: 100%|██████████████████████████████████| 469M/469M [37:00<00:00, 222kB/s]
Downloading [v1-inference.yaml]: 100%|████████████████████████████████████████████| 1.83k/1.83k [00:00<00:00, 5.69kB/s]
Downloading [tokenizer/vocab.json]: 100%|██████████████████████████████████████████| 1.01M/1.01M [00:01<00:00, 588kB/s]
Downloading [v1-5-pruned-emaonly.safetensors]: 100%|██████████████████████████████| 3.97G/3.97G [31:57<00:00, 2.22MB/s]
Downloading [unet/diffusion_pytorch_model.bin]: 100%|█████████████████████████████| 3.20G/3.20G [46:24<00:00, 1.23MB/s]
Downloading [safety_checker/model.safetensors]: 100%|██████████████████████████████| 1.13G/1.13G [47:41<00:00, 425kB/s]
Downloading [unet/diffusion_pytorch_model.safetensors]: 100%|█████████████████████| 3.20G/3.20G [56:58<00:00, 1.01MB/s]
Downloading [v1-5-pruned-emaonly.ckpt]: 100%|████████████████████████████████████| 3.97G/3.97G [1:11:32<00:00, 994kB/s]
Downloading [v1-5-pruned.ckpt]: 100%|███████████████████████████████████████████| 7.17G/7.17G [1:18:02<00:00, 1.65MB/s]
Downloading [v1-5-pruned.safetensors]: 100%|████████████████████████████████████| 7.17G/7.17G [1:23:40<00:00, 1.53MB/s]
Processing 26 items: 100%|█████████████████████████████████████████████████████████| 26.0/26.0 [1:36:14<00:00, 222s/it]
Downloading [v1-5-pruned.safetensors]: 100%|███████████████████████████████████▉| 7.17G/7.17G [1:23:40<00:00, 6.33MB/s]
Successfully Downloaded from model AI-ModelScope/stable-diffusion-v1-5.▉          | 1.67G/3.20G [46:23<25:42, 1.06MB/s]
Downloading [unet/diffusion_pytorch_model.safetensors]:  58%|████████████▏        | 1.86G/3.20G [47:40<08:33, 2.81MB/s]
Downloading [unet/diffusion_pytorch_model.safetensors]: 100%|█████████████████████| 3.20G/3.20G [56:58<00:00, 2.65MB/s]

虽然图中有一行文件显示只下载了58%,但这里应该是多文件并行下载时进度显示错位造成的。查看文件大小也没有问题。因此这就算是下载成功了。

相关推荐
李昊哲小课1 天前
Stable Diffusion 保姆级教程|HF 国内镜像配置 + 一键安装 + 本地模型加载 + 完整代码
stable diffusion·hugging face
yumgpkpm1 天前
Qwen3.6正式开源,华为昇腾910B实现高效适配
华为·ai作画·stable diffusion·开源·ai写作·llama·gpu算力
数智工坊3 天前
深度拆解AnomalyAny:异常检测新工作,利用Stable Diffusion生成真实多样异常样本!
人工智能·pytorch·python·stable diffusion
语戚7 天前
深度解析:Stable Diffusion 底层原理 + U-Net Denoise 去噪机制全拆解
人工智能·ai·stable diffusion·aigc·模型
平安的平安8 天前
用 Python 玩转 AI 绘图:Stable Diffusion 本地部署指南
人工智能·python·stable diffusion
语戚8 天前
Stable Diffusion 核心模块深度拆解:CLIP、U-Net 与 VAE 原理全解析
人工智能·ai·stable diffusion·aigc·模型
yumgpkpm10 天前
华为昇腾910B上用Kubernetes(K8s)部署LLM和用Docker部署LLM的区别
docker·chatgpt·容器·stable diffusion·kubernetes·llama·gpu算力
语戚10 天前
Stable Diffusion 入门:架构、空间与生成流程概览
人工智能·ai·stable diffusion·aigc·模型
yumgpkpm10 天前
华为昇腾910B上用Kubernetes(K8s)部署LLM(Qwen3-32B)的详细步骤,保姆级命令及方法、下载链接等
运维·服务器·华为·stable diffusion·aigc·copilot·llama
平安的平安10 天前
Python 实现 AI 图像生成:调用 Stable Diffusion API 完整教程
人工智能·python·stable diffusion