Stability-AI / generative-models

Generative Models by Stability AI
MIT License
23.17k stars 2.56k forks source link

SV3D_u:huggingface connect error #315

Closed litter-bird-big-dream closed 3 months ago

litter-bird-big-dream commented 3 months ago

environment: wsl,Ubuntu22.04 I just want to test sv3d I download model on ~/generative-models/checkpoints/ (.pt2) vampire@DESKTOP-LIKMKCG:~/generative-models$ ll checkpoints/ total 18294132 drwxr-xr-x 2 vampire vampire 4096 Mar 21 11:09 ./ drwxr-xr-x 14 vampire vampire 4096 Mar 21 11:37 ../ -rw-r--r-- 1 vampire vampire 9369205980 Mar 19 17:47 sv3d_p.safetensors -rw-r--r-- 1 vampire vampire 9363963100 Mar 19 17:53 sv3d_u.safetensors

when i run python scripts/sampling/simple_video_sample.py --input_path assets/86x1m2ne.png --version sv3d_u,error occur as: something like huggingface connect error,is there any model else needed in checkpoint that i should download befor?

`python scripts/sampling/simple_video_sample.py --input_path assets/86x1m2ne.png --version sv3d_u VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing Traceback (most recent call last): File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) OSError: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connectionpool.py", line 404, in _make_request self._validate_conn(conn) File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn conn.connect() File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connection.py", line 363, in connect self.sock = conn = self._new_conn() File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f5a603706d0>: Failed to establish a new connection: [Errno 101] Network is unreachable

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/vampire/.pt2/lib/python3.10/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/connectionpool.py", line 799, in urlopen retries = retries.increment( File "/home/vampire/.pt2/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /laion/CLIP-ViT-H-14-laion2B-s32B-b79K/resolve/main/open_clip_pytorch_model.bin (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5a603706d0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1261, in hf_hub_download metadata = get_hf_file_metadata( File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(args, kwargs) File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1667, in get_hf_file_metadata r = _request_wrapper( File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 385, in _request_wrapper response = _request_wrapper( File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 408, in _request_wrapper response = get_session().request(method=method, url=url, params) File "/home/vampire/.pt2/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "/home/vampire/.pt2/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, kwargs) File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/utils/_http.py", line 67, in send return super().send(request, args, **kwargs) File "/home/vampire/.pt2/lib/python3.10/site-packages/requests/adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /laion/CLIP-ViT-H-14-laion2B-s32B-b79K/resolve/main/open_clip_pytorch_model.bin (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f5a603706d0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))"), '(Request ID: d8a60008-c41b-42d3-8b92-adf4144b1452)')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/vampire/generative-models/scripts/sampling/simple_video_sample.py", line 349, in Fire(sample) File "/home/vampire/.pt2/lib/python3.10/site-packages/fire/core.py", line 143, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/vampire/.pt2/lib/python3.10/site-packages/fire/core.py", line 477, in _Fire component, remaining_args = _CallAndUpdateTrace( File "/home/vampire/.pt2/lib/python3.10/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace component = fn(*varargs, kwargs) File "/home/vampire/generative-models/scripts/sampling/simple_video_sample.py", line 98, in sample model, filter = load_model( File "/home/vampire/generative-models/scripts/sampling/simple_video_sample.py", line 340, in load_model model = instantiate_from_config(config.model).to(device).eval() File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/util.py", line 175, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict())) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/models/diffusion.py", line 59, in init self.conditioner = instantiate_from_config( File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/util.py", line 175, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict())) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/modules/encoders/modules.py", line 79, in init embedder = instantiate_from_config(embconfig) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/util.py", line 175, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict())) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/modules/encoders/modules.py", line 1039, in init self.open_clip = instantiate_from_config(open_clip_embedding_config) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/util.py", line 175, in instantiate_from_config return get_obj_fromstr(config["target"])(**config.get("params", dict())) File "/home/vampire/.pt2/lib/python3.10/site-packages/sgm/modules/encoders/modules.py", line 591, in init model, , _ = open_clip.create_model_and_transforms( File "/home/vampire/.pt2/lib/python3.10/site-packages/open_clip/factory.py", line 384, in create_model_and_transforms model = create_model( File "/home/vampire/.pt2/lib/python3.10/site-packages/open_clip/factory.py", line 283, in create_model checkpoint_path = download_pretrained(pretrained_cfg, cache_dir=cache_dir) File "/home/vampire/.pt2/lib/python3.10/site-packages/open_clip/pretrained.py", line 582, in download_pretrained target = download_pretrained_from_hf(model_id, cache_dir=cache_dir) File "/home/vampire/.pt2/lib/python3.10/site-packages/open_clip/pretrained.py", line 552, in download_pretrained_from_hf cached_file = hf_hub_download(model_id, filename, revision=revision, cache_dir=cache_dir) File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn return fn(*args, **kwargs) File "/home/vampire/.pt2/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1406, in hf_hub_download raise LocalEntryNotFoundError( huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.`

litter-bird-big-dream commented 3 months ago

I fixed it by modify the file: (.pt2) vampire@DESKTOP-LIKMKCG:~/.pt2/lib/python3.10/site-packages/huggingface_hub$ vim constants.py

change the ENDPOINT = os.getenv("HF_ENDPOINT") or ("https://hub-ci.huggingface.co" if _staging_mode else "https://huggingface.co") as

ENDPOINT = "https://hf-mirror.com"

python scripts/sampling/simple_video_sample.py --input_path assets/86x1m2ne.png --version sv3d_u VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing open_clip_pytorch_model.bin: 39%|███████████████████▏ | 1.54G/3.94G [04:16<06:36, 6.06MB/s]

Kizuna-AII commented 3 weeks ago

I fixed it by modify the file: (.pt2) vampire@DESKTOP-LIKMKCG:~/.pt2/lib/python3.10/site-packages/huggingface_hub$ vim constants.py

change the ENDPOINT = os.getenv("HF_ENDPOINT") or ("https://hub-ci.huggingface.co" if _staging_mode else "https://huggingface.co") as

ENDPOINT = "https://hf-mirror.com"

python scripts/sampling/simple_video_sample.py --input_path assets/86x1m2ne.png --version sv3d_u VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing VideoTransformerBlock is using checkpointing open_clip_pytorch_model.bin: 39%|███████████████████▏ | 1.54G/3.94G [04:16<06:36, 6.06MB/s]

It works! But editing the package file seems to be a bit invasive, and there is a more elegant way. Just change your environment variable HF_ENDPOINT to 'https://hf-mirror.com'. For example, you can just add this line to your `~/.bashrc':

export HF_ENDPOINT='https://hf-mirror.com'