NVlabs / consistory

Other
270 stars 21 forks source link

No file named diffusion_pytorch_model.bin for SDXL 1.0 #5

Open katarzynasornat opened 1 week ago

katarzynasornat commented 1 week ago

Hi all,

first of all thanks for your amazing work. I tried to run it but got the following error:

OSError: stabilityai/stable-diffusion-xl-base-1.0 does not appear to have a file named diffusion_pytorch_model.bin.

full trace below:

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:261, in hf_raise_for_status(response, endpoint_name)
    260 try:
--> 261     response.raise_for_status()
    262 except HTTPError as e:

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/requests/models.py:1021, in Response.raise_for_status(self)
   1020 if http_error_msg:
-> 1021     raise HTTPError(http_error_msg, response=self)

HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/462165984030d82259a11f4367a4eed129e94a7b/unet/diffusion_pytorch_model.bin

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

EntryNotFoundError                        Traceback (most recent call last)
File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/utils/hub_utils.py:320, in _get_model_file(pretrained_model_name_or_path, weights_name, subfolder, cache_dir, force_download, proxies, resume_download, local_files_only, use_auth_token, user_agent, revision, commit_hash)
    318 try:
    319     # 2. Load model file as usual
--> 320     model_file = hf_hub_download(
    321         pretrained_model_name_or_path,
    322         filename=weights_name,
    323         cache_dir=cache_dir,
    324         force_download=force_download,
    325         proxies=proxies,
    326         resume_download=resume_download,
    327         local_files_only=local_files_only,
    328         use_auth_token=use_auth_token,
    329         user_agent=user_agent,
    330         subfolder=subfolder,
    331         revision=revision or commit_hash,
    332     )
    333     return model_file

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:118, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    116     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 118 return fn(*args, **kwargs)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/file_download.py:1232, in hf_hub_download(repo_id, filename, subfolder, repo_type, revision, endpoint, library_name, library_version, cache_dir, local_dir, local_dir_use_symlinks, user_agent, force_download, force_filename, proxies, etag_timeout, resume_download, token, local_files_only, legacy_cache_layout)
   1231 try:
-> 1232     metadata = get_hf_file_metadata(
   1233         url=url,
   1234         token=token,
   1235         proxies=proxies,
   1236         timeout=etag_timeout,
   1237     )
   1238 except EntryNotFoundError as http_error:
   1239     # Cache the non-existence of the file and raise

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:118, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    116     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 118 return fn(*args, **kwargs)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/file_download.py:1608, in get_hf_file_metadata(url, token, proxies, timeout)
   1599 r = _request_wrapper(
   1600     method="HEAD",
   1601     url=url,
   (...)
   1606     timeout=timeout,
   1607 )
-> 1608 hf_raise_for_status(r)
   1610 # Return

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:271, in hf_raise_for_status(response, endpoint_name)
    270     message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
--> 271     raise EntryNotFoundError(message, response) from e
    273 elif error_code == "GatedRepo":

EntryNotFoundError: 404 Client Error. (Request ID: Root=1-67379ae1-72bf3ba37246ab241de15f08;c2476b9b-f6a4-4349-882e-26b8bd195fde)

Entry Not Found for url: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/462165984030d82259a11f4367a4eed129e94a7b/unet/diffusion_pytorch_model.bin.

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
Cell In[1], line 11
      8 from consistory_run import load_pipeline, run_batch_generation
     10 gpu = 0
---> 11 story_pipeline = load_pipeline(gpu)
     13 style = "A photo of "
     14 subject = "a cute dog"

File /consistory/consistory_run.py:23, in load_pipeline(gpu_id)
     20 sd_id = "stabilityai/stable-diffusion-xl-base-1.0"
     22 device = torch.device(f'cuda:{gpu_id}') if torch.cuda.is_available() else torch.device('cpu')
---> 23 unet = ConsistorySDXLUNet2DConditionModel.from_pretrained(sd_id, subfolder="unet", torch_dtype=float_type)
     24 scheduler = DDIMScheduler.from_pretrained(sd_id, subfolder="scheduler")
     26 story_pipeline = ConsistoryExtendAttnSDXLPipeline.from_pretrained(
     27     sd_id, unet=unet, torch_dtype=float_type, variant="fp16", use_safetensors=True, scheduler=scheduler
     28 ).to(device)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/models/modeling_utils.py:769, in ModelMixin.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    767         pass
    768 if model_file is None:
--> 769     model_file = _get_model_file(
    770         pretrained_model_name_or_path,
    771         weights_name=_add_variant(WEIGHTS_NAME, variant),
    772         cache_dir=cache_dir,
    773         force_download=force_download,
    774         resume_download=resume_download,
    775         proxies=proxies,
    776         local_files_only=local_files_only,
    777         use_auth_token=use_auth_token,
    778         revision=revision,
    779         subfolder=subfolder,
    780         user_agent=user_agent,
    781         commit_hash=commit_hash,
    782     )
    784 if low_cpu_mem_usage:
    785     # Instantiate model with empty weights
    786     with accelerate.init_empty_weights():

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/utils/hub_utils.py:349, in _get_model_file(pretrained_model_name_or_path, weights_name, subfolder, cache_dir, force_download, proxies, resume_download, local_files_only, use_auth_token, user_agent, revision, commit_hash)
    343     raise EnvironmentError(
    344         f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for "
    345         "this model name. Check the model page at "
    346         f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions."
    347     )
    348 except EntryNotFoundError:
--> 349     raise EnvironmentError(
    350         f"{pretrained_model_name_or_path} does not appear to have a file named {weights_name}."
    351     )
    352 except HTTPError as err:
    353     raise EnvironmentError(
    354         f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{err}"
    355     )

Is it some error on my side, perhaps conda env not properly set up or was there some change thatdiffusion_pytorch_model.bin is not present anymore?

I checked under UNet for SDXL stability.ai repo and also cannot fins any .bin file:

image

Any help appreciated!

p.s. is there any way to run it with Google Colab and bypass conda?

Thank you

xcltql666 commented 15 hours ago

The same question.

xcltql666 commented 12 hours ago

Hi all,

first of all thanks for your amazing work. I tried to run it but got the following error:

OSError: stabilityai/stable-diffusion-xl-base-1.0 does not appear to have a file named diffusion_pytorch_model.bin.

full trace below:

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:261, in hf_raise_for_status(response, endpoint_name)
    260 try:
--> 261     response.raise_for_status()
    262 except HTTPError as e:

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/requests/models.py:1021, in Response.raise_for_status(self)
   1020 if http_error_msg:
-> 1021     raise HTTPError(http_error_msg, response=self)

HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/462165984030d82259a11f4367a4eed129e94a7b/unet/diffusion_pytorch_model.bin

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

EntryNotFoundError                        Traceback (most recent call last)
File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/utils/hub_utils.py:320, in _get_model_file(pretrained_model_name_or_path, weights_name, subfolder, cache_dir, force_download, proxies, resume_download, local_files_only, use_auth_token, user_agent, revision, commit_hash)
    318 try:
    319     # 2. Load model file as usual
--> 320     model_file = hf_hub_download(
    321         pretrained_model_name_or_path,
    322         filename=weights_name,
    323         cache_dir=cache_dir,
    324         force_download=force_download,
    325         proxies=proxies,
    326         resume_download=resume_download,
    327         local_files_only=local_files_only,
    328         use_auth_token=use_auth_token,
    329         user_agent=user_agent,
    330         subfolder=subfolder,
    331         revision=revision or commit_hash,
    332     )
    333     return model_file

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:118, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    116     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 118 return fn(*args, **kwargs)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/file_download.py:1232, in hf_hub_download(repo_id, filename, subfolder, repo_type, revision, endpoint, library_name, library_version, cache_dir, local_dir, local_dir_use_symlinks, user_agent, force_download, force_filename, proxies, etag_timeout, resume_download, token, local_files_only, legacy_cache_layout)
   1231 try:
-> 1232     metadata = get_hf_file_metadata(
   1233         url=url,
   1234         token=token,
   1235         proxies=proxies,
   1236         timeout=etag_timeout,
   1237     )
   1238 except EntryNotFoundError as http_error:
   1239     # Cache the non-existence of the file and raise

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py:118, in validate_hf_hub_args.<locals>._inner_fn(*args, **kwargs)
    116     kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
--> 118 return fn(*args, **kwargs)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/file_download.py:1608, in get_hf_file_metadata(url, token, proxies, timeout)
   1599 r = _request_wrapper(
   1600     method="HEAD",
   1601     url=url,
   (...)
   1606     timeout=timeout,
   1607 )
-> 1608 hf_raise_for_status(r)
   1610 # Return

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:271, in hf_raise_for_status(response, endpoint_name)
    270     message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
--> 271     raise EntryNotFoundError(message, response) from e
    273 elif error_code == "GatedRepo":

EntryNotFoundError: 404 Client Error. (Request ID: Root=1-67379ae1-72bf3ba37246ab241de15f08;c2476b9b-f6a4-4349-882e-26b8bd195fde)

Entry Not Found for url: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/462165984030d82259a11f4367a4eed129e94a7b/unet/diffusion_pytorch_model.bin.

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
Cell In[1], line 11
      8 from consistory_run import load_pipeline, run_batch_generation
     10 gpu = 0
---> 11 story_pipeline = load_pipeline(gpu)
     13 style = "A photo of "
     14 subject = "a cute dog"

File /consistory/consistory_run.py:23, in load_pipeline(gpu_id)
     20 sd_id = "stabilityai/stable-diffusion-xl-base-1.0"
     22 device = torch.device(f'cuda:{gpu_id}') if torch.cuda.is_available() else torch.device('cpu')
---> 23 unet = ConsistorySDXLUNet2DConditionModel.from_pretrained(sd_id, subfolder="unet", torch_dtype=float_type)
     24 scheduler = DDIMScheduler.from_pretrained(sd_id, subfolder="scheduler")
     26 story_pipeline = ConsistoryExtendAttnSDXLPipeline.from_pretrained(
     27     sd_id, unet=unet, torch_dtype=float_type, variant="fp16", use_safetensors=True, scheduler=scheduler
     28 ).to(device)

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/models/modeling_utils.py:769, in ModelMixin.from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    767         pass
    768 if model_file is None:
--> 769     model_file = _get_model_file(
    770         pretrained_model_name_or_path,
    771         weights_name=_add_variant(WEIGHTS_NAME, variant),
    772         cache_dir=cache_dir,
    773         force_download=force_download,
    774         resume_download=resume_download,
    775         proxies=proxies,
    776         local_files_only=local_files_only,
    777         use_auth_token=use_auth_token,
    778         revision=revision,
    779         subfolder=subfolder,
    780         user_agent=user_agent,
    781         commit_hash=commit_hash,
    782     )
    784 if low_cpu_mem_usage:
    785     # Instantiate model with empty weights
    786     with accelerate.init_empty_weights():

File ~/anaconda3/envs/consistory/lib/python3.10/site-packages/diffusers/utils/hub_utils.py:349, in _get_model_file(pretrained_model_name_or_path, weights_name, subfolder, cache_dir, force_download, proxies, resume_download, local_files_only, use_auth_token, user_agent, revision, commit_hash)
    343     raise EnvironmentError(
    344         f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for "
    345         "this model name. Check the model page at "
    346         f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions."
    347     )
    348 except EntryNotFoundError:
--> 349     raise EnvironmentError(
    350         f"{pretrained_model_name_or_path} does not appear to have a file named {weights_name}."
    351     )
    352 except HTTPError as err:
    353     raise EnvironmentError(
    354         f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n{err}"
    355     )

Is it some error on my side, perhaps conda env not properly set up or was there some change thatdiffusion_pytorch_model.bin is not present anymore?

I checked under UNet for SDXL stability.ai repo and also cannot fins any .bin file:

image

Any help appreciated!

p.s. is there any way to run it with Google Colab and bypass conda?

Thank you

Hi, I have also encountered the same problem and it has been resolved. After practice, I found that this was due to network issues which caused the model to only download a portion. Then when the code loads this incomplete model, there will be a problem where some files do not exist. Please ensure that your network is unobstructed and all download tasks have been completed successfully.