instantX-research / InstantID

InstantID: Zero-shot Identity-Preserving Generation in Seconds šŸ”„
https://instantid.github.io/
Apache License 2.0
11.17k stars 813 forks source link

We couldn't connect to 'https://huggingface.co' to load this model #127

Open luigiw opened 9 months ago

luigiw commented 9 months ago

Is this line correct? I got errors like below from that line of code.

# Path to InstantID models
face_adapter = f'./checkpoints/ip-adapter.bin'
controlnet_path = f'./checkpoints/ControlNetModel'

# Load pipeline
controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=dtype)

Traceback (most recent call last): File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/diffusers/configuration_utils.py", line 376, in load_config config_file = hf_hub_download( File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 110, in _inner_fn validate_repo_id(arg_value) File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 158, in validate_repo_id raise HFValidationError( huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': './checkpoints/ControlNetModel'. Use repo_type argument if needed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/hanchi/Code/InstantID/gradio_demo/app.py", line 50, in controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=dtype) File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(*args, *kwargs) File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/diffusers/models/modeling_utils.py", line 712, in from_pretrained config, unused_kwargs, commit_hash = cls.load_config( File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(args, **kwargs) File "/Users/hanchi/miniconda3/envs/instantid/lib/python3.10/site-packages/diffusers/configuration_utils.py", line 411, in load_config raise EnvironmentError( OSError: We couldn't connect to 'https://huggingface.co' to load this model, couldn't find it in the cached files and it looks like ./checkpoints/ControlNetModel is not the path to a directory containing a config.json file. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/diffusers/installation#offline-mode'.

haofanwang commented 9 months ago

If you cannot access to hf, you can download manually.

machineminded commented 9 months ago

This issue is because you are probably missing hf_hub_download per the readme.md. This is what I am using in Fooocus and it is downloading accordingly.

from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="InstantX/InstantID", filename="ControlNetModel/config.json", local_dir="InstantID/checkpoints")
hf_hub_download(repo_id="InstantX/InstantID", filename="ControlNetModel/diffusion_pytorch_model.safetensors", local_dir="InstantID/checkpoints")
hf_hub_download(repo_id="InstantX/InstantID", filename="ip-adapter.bin", local_dir="InstantID/checkpoints")