分类: AGI
Stable Diffusion使用新模型时报错'openai/clip-vit-large-patch14' is the correct path to a directory containing

在虚拟机上第一次运行Stable Diffusion时报错如下:

Loading weights [cc6cb27103] from /data/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt
Creating model from config: /data/stable-diffusion-webui/configs/v1-inference.yaml
creating model quickly: OSError
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 995, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/home/ice/.local/share/virtualenvs/stable-diffusion-webui-bRNo03KA/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "/home/ice/.local/share/virtualenvs/stable-diffusion-webui-bRNo03KA/lib/python3.11/site-packages/gradio/utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "/data/stable-diffusion-webui/modules/ui_settings.py", line 316, in <lambda>
    fn=lambda value, k=k: self.run_settings_single(value, key=k),
  File "/data/stable-diffusion-webui/modules/ui_settings.py", line 95, in run_settings_single
    if value is None or not opts.set(key, value):
  File "/data/stable-diffusion-webui/modules/options.py", line 165, in set
    option.onchange()
  File "/data/stable-diffusion-webui/modules/call_queue.py", line 14, in f
    res = func(*args, **kwargs)
  File "/data/stable-diffusion-webui/modules/initialize_util.py", line 181, in <lambda>
    shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: sd_models.reload_model_weights()), call=False)
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 977, in reload_model_weights
    load_model(checkpoint_info, already_loaded_state_dict=state_dict)
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 820, in load_model
    sd_model = instantiate_from_config(sd_config.model, state_dict)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 775, in instantiate_from_config
    return constructor(**params)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 563, in __init__
    self.instantiate_cond_stage(cond_stage_config)
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 630, in instantiate_cond_stage
    model = instantiate_from_config(config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/encoders/modules.py", line 103, in __init__
    self.tokenizer = CLIPTokenizer.from_pretrained(version)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ice/.local/share/virtualenvs/stable-diffusion-webui-bRNo03KA/lib/python3.11/site-packages/transformers/tokenization_utils_base.py", line 1809, in from_pretrained
    raise EnvironmentError(
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

Failed to create model quickly; will retry using slow method.
changing setting sd_model_checkpoint to dreamshaper_331BakedVae.safetensors: OSError
Traceback (most recent call last):
  File "/data/stable-diffusion-webui/modules/options.py", line 165, in set
    option.onchange()
  File "/data/stable-diffusion-webui/modules/call_queue.py", line 14, in f
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/modules/initialize_util.py", line 181, in <lambda>
    shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: sd_models.reload_model_weights()), call=False)
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 977, in reload_model_weights
    load_model(checkpoint_info, already_loaded_state_dict=state_dict)
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 829, in load_model
    sd_model = instantiate_from_config(sd_config.model, state_dict)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/modules/sd_models.py", line 775, in instantiate_from_config
    return constructor(**params)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 563, in __init__
    self.instantiate_cond_stage(cond_stage_config)
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 630, in instantiate_cond_stage
    model = instantiate_from_config(config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py", line 89, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/encoders/modules.py", line 103, in __init__
    self.tokenizer = CLIPTokenizer.from_pretrained(version)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ice/.local/share/virtualenvs/stable-diffusion-webui-bRNo03KA/lib/python3.11/site-packages/transformers/tokenization_utils_base.py", line 1809, in from_pretrained
    raise EnvironmentError(
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

Loading weights [fc2511737a] from /data/stable-diffusion-webui/models/Stable-diffusion/chilloutmix_NiPrunedFp32Fix.safetensors

分析:
根据报错内容判断是stable-diffusion-webui/openai/clip-vit-large-patch14文件夹下缺少clip-vit-large-patch14
解决:

cd /data/stable-diffusion-webui
mkdir openai
cd openai
git clone https://huggingface.co/openai/clip-vit-large-patch14.git

然后重新启动服务即可正常,贴一张生成的沙漠仙人掌的图片:
00000-3259983318.png

发表新评论