Skip to content

Error loading locally safetensors files #10863

Closed
@elismasilva

Description

@elismasilva

Describe the bug

Some models are getting error on load safetensors directly from .safetensors file.

Reproduction

StableDiffusionXLControlTilingPipeline.from_single_file("F:\\models\\Stable-diffusion\\RealVisXL v5.0 Lightning.safetensors",...)

@SunMarc - > metadata is returning {} len = 0 and this condition is not in this check:
Image

Logs

Traceback (most recent call last):
  File "C:\Users\pelol\.pyenv\pyenv-win\versions\3.10.11\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\pelol\.pyenv\pyenv-win\versions\3.10.11\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy\__main__.py", line 71, in <module>
    cli.main()
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 501, in main
    run()
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy/..\debugpy\server\cli.py", line 351, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "c:\Users\pelol\.vscode\extensions\ms-python.debugpy-2025.1.2025021701-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "F:\Projetos\DiffusersWebUI\src\test_mx_tile_diffusers.py", line 133, in <module>
    pipe = StableDiffusionXLControlTilingPipeline.from_single_file("F:\\models\\Stable-diffusion\\RealVisXL v5.0 Lightning.safetensors",
  File "f:\Projetos\DiffusersWebUI\venv\lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "F:\Projetos\DiffusersWebUI\venv\src\diffusers\src\diffusers\loaders\single_file.py", line 385, in from_single_file
    checkpoint = load_single_file_checkpoint(
  File "F:\Projetos\DiffusersWebUI\venv\src\diffusers\src\diffusers\loaders\single_file_utils.py", line 411, in load_single_file_checkpoint
    checkpoint = load_state_dict(pretrained_model_link_or_path, disable_mmap=disable_mmap)
  File "F:\Projetos\DiffusersWebUI\venv\src\diffusers\src\diffusers\models\model_loading_utils.py", line 221, in load_state_dict
    raise OSError(
OSError: Unable to load weights from checkpoint file for 'F:\models\Stable-diffusion\RealVisXL v5.0 Lightning.safetensors' at 'F:\models\Stable-diffusion\RealVisXL v5.0 Lightning.safetensors'.
PS F:\Projetos\DiffusersWebUI>

System Info

  • 🤗 Diffusers version: 0.33.0.dev0
  • Platform: Windows-10-10.0.19045-SP0
  • Running on Google Colab?: No
  • Python version: 3.10.11
  • PyTorch version (GPU?): 2.5.1+cu124 (True)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Huggingface_hub version: 0.28.1
  • Transformers version: 4.47.1
  • Accelerate version: 1.2.1
  • PEFT version: 0.12.0
  • Bitsandbytes version: 0.45.0
  • Safetensors version: 0.4.4
  • xFormers version: 0.0.28.post3
  • Accelerator: NVIDIA GeForce RTX 3060 Ti, 8192 MiB
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@SunMarc

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions