【debug】安装diffusion的bug解决合集

环境问题

ImportError: cannot import name ‘CLIPImageProcessor’ from
‘transformers’ (D:\Python\lib\site-packages\transformers_init_.py)

https://github.com/huggingface/transformers/issues/23340

解决:查看更详细信息,安装环境

transformers-cli env

网络问题

1 连接切换回本地,下载

model_id = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

换成

model_id = "本地仓"
model_id = "D:\code\Github_code\Stable_diffusion\stable-diffusion-v1-5"

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, revision="fp16")
pipe = pipe.to(device)

2

You seem to have cloned a repository without having git-lfs installed

从别的电脑上复制过来,而不是从hugging face直接下载。需要使用

git lfs pull

大文件下载中断问题

仅克隆小文件,大文件用下载工具下载,然后软连接。

 GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/runwayml/stable-diffusion-v1-5

不要用https,选ssh。

git lfs install
GIT_LFS_SKIP_SMUDGE=1  git clone [email protected]:runwayml/stable-diffusion-v1-5

4

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
Loading pipeline components...:  29%|██████████████████████████████████▌                                                                                      | 2/7 [00:00<00:00, 12.42it/s]
Traceback (most recent call last):
  File "C:\conda\envs\ldm\lib\site-packages\diffusers\models\modeling_utils.py", line 108, in load_state_dict
    return safetensors.torch.load_file(checkpoint_file, device="cpu")
  File "C:\conda\envs\ldm\lib\site-packages\safetensors\torch.py", line 308, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "C:\conda\envs\ldm\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 1105, in from_pretrained
    loaded_sub_model = load_sub_model(
  File "C:\conda\envs\ldm\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 472, in load_sub_model
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "C:\conda\envs\ldm\lib\site-packages\diffusers\models\modeling_utils.py", line 641, in from_pretrained
    state_dict = load_state_dict(model_file, variant=variant)
  File "C:\conda\envs\ldm\lib\site-packages\diffusers\models\modeling_utils.py", line 113, in load_state_dict
    raise OSError(
OSError: You seem to have cloned a repository without having git-lfs installed. Please install git-lfs and run `git lfs install` followed by `git lfs pull` in the folder you cloned.

你可能感兴趣的:(bug)