sjtuplayer / anomalydiffusion

[AAAI 2024] AnomalyDiffusion: Few-Shot Anomaly Image Generation with Diffusion Model
MIT License
138 stars 19 forks source link

您好,想问一个代码问题 #4

Closed agreasjh closed 1 day ago

agreasjh commented 6 months ago

运行下面代码后 set CUDA_VISIBLE_DEVICES=0 python main.py --spatial_encoder_embedding --data_enhance --base configs/latent-diffusion/txt2img-1p4B-finetune-encoder+embedding.yaml -t --actual_resume models/ldm/text2img-large/model.ckpt -n test --gpus 0, --init_word anomaly --mvtec_path=/mvtec_anomaly_detection/tile

出现错误: (Anomalydiffusion) E:\Pycharm\Project\anomalydiffusion-master>python main.py --spatial_encoder_embedding --data_enhance --base configs/latent-diffusion/txt2img-1p4B-finetune-encoder+embedding.yaml -t --actual_resume models/ldm/text2img-large/model.ckpt -n test --gpus 0, --init_word anomaly --mvtec_path=/mvtec_anomaly_detection/tile Global seed set to 23 Running on GPUs 0, Loading model from models/ldm/text2img-large/model.ckpt LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 872.30 M params. making attention of type 'vanilla' with 512 in_channels Working with z of shape (1, 4, 32, 32) = 4096 dimensions. making attention of type 'vanilla' with 512 in_channels Traceback (most recent call last): File "main.py", line 645, in model = load_model_from_config(config, opt.actual_resume) File "main.py", line 30, in load_model_from_config model = instantiate_from_config(config.model) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\util.py", line 85, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict()), kwargs) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\models\diffusion\ddpm.py", line 477, in init self.instantiate_cond_stage(cond_stage_config) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\models\diffusion\ddpm.py", line 573, in instantiate_cond_stage model = instantiate_from_config(config) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\util.py", line 85, in instantiate_from_config return get_obj_from_str(config["target"])(config.get("params", dict()), kwargs) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\modules\encoders\modules.py", line 108, in init self.tknz_fn = BERTTokenizer(vq_interface=False, max_length=max_seq_len) File "E:\Pycharm\Project\anomalydiffusion-master\ldm\modules\encoders\modules.py", line 79, in init self.tokenizer = BertTokenizerFast.from_pretrained("bert-base-uncased") File "D:\Anaconda3\envs\Anomalydiffusion\lib\site-packages\transformers\tokenization_utils_base.py", line 1676, in from_pretrained resolved_config_file = get_file_from_repo( File "D:\Anaconda3\envs\Anomalydiffusion\lib\site-packages\transformers\utils\hub.py", line 678, in get_file_from_repo resolved_file = cached_path( File "D:\Anaconda3\envs\Anomalydiffusion\lib\site-packages\transformers\utils\hub.py", line 282, in cached_path output_path = get_from_cache( File "D:\Anaconda3\envs\Anomalydiffusion\lib\site-packages\transformers\utils\hub.py", line 545, in get_from_cache raise ValueError( ValueError: Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 888, in if trainer.global_rank == 0: NameError: name 'trainer' is not defined

这应该如何解决?

sjtuplayer commented 6 months ago

It seems to be the problem that you cannot connect to huggingface. You can change your network or download the code and model from huggingface.

agreasjh commented 6 months ago

Thanks,What files need to be download from huggingface and put in which folder?There is no mention of instruction in the README file.

---原始邮件--- 发件人: @.> 发送时间: 2024年2月15日(周四) 下午4:11 收件人: @.>; 抄送: @.**@.>; 主题: Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4)

It seems to be the problem that you cannot connect to huggingface. You can change your network or download the code and model from huggingface.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

sjtuplayer commented 6 months ago

According to the error log, the problem comes from 'BertTokenizerFast.from_pretrained("bert-base-uncased")'. You can search this bert model in hugging face and download it.

agreasjh commented 6 months ago

After downloading, should it be placed directly in the 'model' folder under the root directory?

--------------原始邮件-------------- 发件人:"sjtuplayer @.>; 发送时间:2024年2月15日(星期四) 下午4:22 收件人:"sjtuplayer/anomalydiffusion" @.>; 抄送:"蒋昊 @.>;"Author @.>; 主题:Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4)

According to the error log, the problem comes from 'BertTokenizerFast.from_pretrained("bert-base-uncased")'. You can search this bert model in hugging face and download it.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

zhtstar commented 6 months ago

你好,请问你的这个问题解决了吗?我碰到了和你一样的问题,我尝试更改了huggingface的镜像,虽然可以在终端直接用wget下载huggingface上的模型,bert-base-uncased这个模型我已经下载到了本地,但是在运行代码时还是会报错。

After downloading, should it be placed directly in the 'model' folder under the root directory? --------------原始邮件-------------- 发件人:"sjtuplayer @.>; 发送时间:2024年2月15日(星期四) 下午4:22 收件人:"sjtuplayer/anomalydiffusion" @.>; 抄送:"蒋昊 @.>;"Author @.>; 主题:Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4) ----------------------------------- According to the error log, the problem comes from 'BertTokenizerFast.from_pretrained("bert-base-uncased")'. You can search this bert model in hugging face and download it. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

sjtuplayer commented 6 months ago

你好,请问你的这个问题解决了吗?我碰到了和你一样的问题,我尝试更改了huggingface的镜像,虽然可以在终端直接用wget下载huggingface上的模型,bert-base-uncased这个模型我已经下载到了本地,但是在运行代码时还是会报错。

After downloading, should it be placed directly in the 'model' folder under the root directory? --------------原始邮件-------------- 发件人:"sjtuplayer @.**>; 发送时间:2024年2月15日(星期四) 下午4:22 收件人:"sjtuplayer/anomalydiffusion" @.**>; 抄送:"蒋昊 @.**>;"Author @.**>; 主题:Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4) ----------------------------------- According to the error log, the problem comes from 'BertTokenizerFast.frompretrained("bert-base-uncased")'. You can search this bert model in hugging face and download it. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @_.***>

After downloading ‘’bert-base-uncased‘’, you can change Line 79 of ldm/modules/encoders/modules.py to the path of your downloaded ‘’bert-base-uncased‘’.

zhtstar commented 6 months ago

thanks

---原始邮件--- 发件人: @.> 发送时间: 2024年2月28日(周三) 上午10:19 收件人: @.>; 抄送: @.**@.>; 主题: Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4)

你好,请问你的这个问题解决了吗?我碰到了和你一样的问题,我尝试更改了huggingface的镜像,虽然可以在终端直接用wget下载huggingface上的模型,bert-base-uncased这个模型我已经下载到了本地,但是在运行代码时还是会报错。

After downloading, should it be placed directly in the 'model' folder under the root directory? … --------------原始邮件-------------- 发件人:"sjtuplayer @.>; 发送时间:2024年2月15日(星期四) 下午4:22 收件人:"sjtuplayer/anomalydiffusion" @**.>; 抄送:"蒋昊 @.**>;"Author @._>; 主题:Re: [sjtuplayer/anomalydiffusion] 您好,想问一个代码问题 (Issue #4) ----------------------------------- According to the error log, the problem comes from 'BertTokenizerFast.frompretrained("bert-base-uncased")'. You can search this bert model in hugging face and download it. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @_.>

After downloading ‘’bert-base-uncased‘’, you can change Line 79 of ldm/modules/encoders/modules.py to the path of your downloaded ‘’bert-base-uncased‘’.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

122y0nx commented 5 days ago

您好我想问一下您的这个代码复现成功了吗,我一直在处理bug,很长时间还是做不出来,您成功了的话方便帮助我一下吗