WindVChen / DiffAttack

An unrestricted attack based on diffusion models that can achieve both good transferability and imperceptibility.
Apache License 2.0
115 stars 9 forks source link

huggingface download error #5

Open junyizeng opened 1 year ago

junyizeng commented 1 year ago

Thank you very much for your open source, I have encountered the following problem with the pre-trained diffusion model from huggingface.

Traceback (most recent call last): File "/root/code/DiffAttack-main/main.py", line 107, in ldm_stable = StableDiffusionPipeline.from_pretrained(pretrained_diffusion_path).to('cuda:0') File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 884, in from_pretrained cached_folder = cls.download( File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/diffusers/pipelines/pipeline_utils.py", line 1208, in download config_file = hf_hub_download( File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 120, in _inner_fn return fn(*args, **kwargs) File "/root/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1259, in hf_hub_download raise LocalEntryNotFoundError( huggingface_hub.utils._errors.LocalEntryNotFoundError: Connection error, and we cannot find the requested files in the disk cache. Please try again or make sure your Internet connection is on.

WindVChen commented 1 year ago

Hi @junyizeng ,

It seems that there is a problem with the Internet connection. Maybe you can check some possible solutions here.

junyizeng commented 1 year ago

Thank you very much for your quick reply. Due to the limitation of the device, I am renting the online calculator platform (AutoDL) to run the code, but the file downloaded by stable_diffusion is too large and the system disk is easily filled up, which affects the normal operation of the code. Can I download the files needed to load stable_diffuion in advance and import the model from local? Since this is my first time to use huggingface, could you please provide a tutorial if possible?

WindVChen commented 1 year ago

Since I'm unfamiliar with AutoDL platform, I'm unsure whether the way I run it with local files will bring some inspiration.

You can first download the files by directly running the following codes on the local machine:

from diffusers import StableDiffusionPipeline
ldm_stable = StableDiffusionPipeline.from_pretrained(“stabilityai/stable-diffusion-2-base”)

Then, you can find these files in the local path (take Win10 as an example): C:\Users\$YourName$\.cache\huggingface\diffusers\models--stabilityai--stable-diffusion-2-base\snapshots\$A Long Serial Number$.

After that, you can directly load the local files without again downloading from the Internet:

from diffusers import StableDiffusionPipeline
ldm_stable = StableDiffusionPipeline.from_pretrained("C:\Users\$YourName$\.cache\huggingface\diffusers\models--stabilityai--stable-diffusion-2-base\snapshots\$A Long Serial Number$")
junyizeng commented 1 year ago

Thank you very much, the method you gave is effective!

yuuma002 commented 11 months ago

Hi. Thanks for open-sourcing the code of your wonderful work. I met the same error and I cannot fix the error by https://github.com/huggingface/transformers/issues/10067. Could you provide the detailed fixing method of the issue @WindVChen?

Hi @junyizeng ,

It seems that there is a problem with the Internet connection. Maybe you can check some possible solutions here.

WindVChen commented 11 months ago

Hi @yuuma002 ,

Thanks for your attention. If still fail to download the weight automatically, maybe you can try to download it manually. Try to download all the files here (no need to download 512-base-ema.ckpt and 512-base-ema.safetensors) and save them into a directory (let us name it as A), then you can try to load the weight by:

from diffusers import StableDiffusionPipeline
ldm_stable = StableDiffusionPipeline.from_pretrained(A)

Hope this can help.