WindVChen / DiffAttack

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

run-time error #20

Open zhangfeng0617 opened 2 months ago

zhangfeng0617 commented 2 months ago

Hello, may I ask if I have downloaded the pre-training model you sent to the local, changed the path in the code, or this problem, may I ask what is going on? thank you image image

WindVChen commented 2 months ago

Hi @zhangfeng0617 ,

I didn't encounter such an issue before, but maybe you can have a look at this issue https://github.com/huggingface/transformers/issues/17611 which is quite similar.

Besides, there could also sometimes be internet problem. You can also have a try to add this script at the start of the code (refer to https://github.com/CompVis/stable-diffusion/issues/302#issuecomment-2042642642):

import os
os.environ['HF_ENDPOINT']='https://hf-mirror.com'

If you want to load the pre-trained model from the local machine, you may need to ensure downloading the correct type of files. Below is the needed file list of Stable Diffusion: image

zhangfeng0617 commented 2 months ago

Thanks for your reply, can you give me a link to the pre-training model of this project? Maybe my pre-training model is not in the right file. thank you

WindVChen commented 2 months ago

Hi, you can find these files here.

zhangfeng0617 commented 2 months ago

thank you! thank you!

zhangfeng0617 commented 1 month ago

I downloaded the pre-training model to the local, there is this problem, hope you can help to answer it, thank you image **Attack based on Diffusion***** Traceback (most recent call last): File "main.py", line 114, in ldm_stable = StableDiffusionPipeline.from_pretrained(pretrained_diffusion_path).to('cuda:0') File "F:\Anaconda2023\anaconda3\envs\diffattack\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 1037, in from_pretrained loaded_sub_model = load_sub_model( File "F:\Anaconda2023\anaconda3\envs\diffattack\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 450, in load_sub_model loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs) File "F:\Anaconda2023\anaconda3\envs\diffattack\lib\site-packages\transformers\tokenization_utils_base.py", line 2094, in from_pretrained raise EnvironmentError( OSError: Can't load tokenizer for 'stabilityai/stable-diffusion-2-base\tokenizer'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'stabilityai/stable-diffusion-2-base\tokenizer' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

Process finished with exit code 1 image

thanks!

WindVChen commented 1 month ago

Hi,

Could you please let me know the level of file path you passed into the code?

For example, here's my local save path:

image

And it should work when setting the --pretrained_diffusion_path="C:\Users\PC\.cache\huggingface\diffusers\models--stabilityai--stable-diffusion-2-base\snapshots\455a0f46082..." in the main.py.

zhangfeng0617 commented 1 month ago

This is the previous version you published, but it does not affect. I put the pre-trained model downloaded from the link you sent above into the project, and I also loaded it directly in the code. As shown in the figure. I see you put it under the C drive path, is that the reason? In addition, the pre-trained model I downloaded does not have huggingface\diffusers\ in front, is this affecting the operation? thank you image image

WindVChen commented 1 month ago

Ah, I think I understand the issue now.

I apologize for the confusion regarding the path specified in the code: --pretrained_diffusion_path="stabilityai/stable-diffusion-2-base". The value stabilityai/stable-diffusion-2-base does not refer to a local path. Instead, it points to the Hugging Face repository stabilityai/stable-diffusion-2-base from which the necessary weights will be downloaded automatically.

The error message you encountered previously might be due to a name collision if you have a local directory with the same name as the Hugging Face repository. To resolve this, please try using an absolute path for the --pretrained_diffusion_path parameter. If that doesn't work, consider renaming your local folder to something else.

zhangfeng0617 commented 1 month ago

It's okay. I'm the one who's learning and asking questions. I changed the local absolute path and changed the name of the pre-trained model, but it still didn't work. May I ask is there any other way? If I don't download the pre-trained model locally, I'll have a network problem like the one shown here. I really don't know what to do (crying and laughing), looking forward to your help, thank you. image

WindVChen commented 1 month ago

Emm, that's a bit weird.

Typically, setting --pretrained_diffusion_path="stabilityai/stable-diffusion-2-base" should automatically download the weights. The error message shown in the screenshot still seems to be related to a network connection issue. Have you tried the potential solutions mentioned here?

zhangfeng0617 commented 1 month ago

I tried the method but it didn't work. I will download your project again and try it. Thank you very much for your trouble.

WindVChen commented 1 month ago

Sorry it didn't work out :( Please keep me informed if you manage to identify the issue.

zhangfeng0617 commented 3 weeks ago

Hello, because I am busy with other things at this time, so I have delayed this. I re-downloaded your project and tried to replace the versions of the request and urllib3 libraries, but I still had this connection problem. Also, I downloaded stable-diffusion-2-base locally, but I didn't use it. I just downloaded the project, and then hooked up the vpn to run it directly, but the following problems kept appearing. Is there a problem with the process of my running the project? Could you help me, please? Thank you. It's so much trouble. If possible, it would be best to add your contact information, so that I can consult you more easily, because I do encounter this problem is rather difficult. It's perfectly normal for you to say no. Thank you again.

The following is the error message:

File "F:\Anaconda2023\anaconda3\envs\diffattack\lib\site-packages\requests\adapters.py", line 517, in send raise SSLError(e, request=request) requests.exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/stabilityai/stable-diffusion-2-base (Caused by SSLError(SSLZeroReturnError(6, 'TLS/SSL connection has been closed (EOF) (_ssl.c:1135)')))"), '(Request ID: 38dcc369-6bd4-4e11-988c-2d545872bbb3)')

WindVChen commented 2 weeks ago

Hi @zhangfeng0617 ,

Apologies for the delayed response—things have been quite busy on my end as well.

Please feel free to send an email to windvchen@gmail.com, and I'll share my personal contact details there.

zhangfeng0617 commented 2 weeks ago

Ok, thank you, now I am busy with some other things, I will contact you when the school starts, thank you very much