openai / improved-diffusion

Release for Improved Denoising Diffusion Probabilistic Models
MIT License
3.22k stars 485 forks source link

i meet a error when executing image_sample.py #109

Open xinrong6 opened 1 year ago

xinrong6 commented 1 year ago

python scripts/image_sample.py --model_path /hd8t/user_code/lxr/improved-diffusion/ckpt_save/ema_0.9999_025000.pt $DIFFUSION_FLAGS $MODEL_FLAGS

RuntimeError: Error(s) in loading state_dict for UNetModel: Missing key(s) in state_dict: "input_blocks.7.0.skip_connection.weight", "input_blocks.7.0.skip_connection.bias", "input_blocks.10.0.skip_connection.weight", "input_blocks.10.0.skip_connection.bias", "input_blocks.10.1.norm.weight", "input_blocks.10.1.norm.bias", "input_blocks.10.1.qkv.weight", "input_blocks.10.1.qkv.bias", "input_blocks.10.1.proj_out.weight", "input_blocks.10.1.proj_out.bias", "input_blocks.11.1.norm.weight", "input_blocks.11.1.norm.bias", "input_blocks.11.1.qkv.weight", "input_blocks.11.1.qkv.bias", "input_blocks.11.1.proj_out.weight", "input_blocks.11.1.proj_out.bias", "output_blocks.0.1.norm.weight", "output_blocks.0.1.norm.bias", "output_blocks.0.1.qkv.weight", "output_blocks.0.1.qkv.bias", "output_blocks.0.1.proj_out.weight", "output_blocks.0.1.proj_out.bias", "output_blocks.1.1.norm.weight", "output_blocks.1.1.norm.bias", "output_blocks.1.1.qkv.weight", "output_blocks.1.1.qkv.bias", "output_blocks.1.1.proj_out.weight", "output_blocks.1.1.proj_out.bias", "output_blocks.2.1.norm.weight", "output_blocks.2.1.norm.bias", "output_blocks.2.1.qkv.weight", "output_blocks.2.1.qkv.bias", "output_blocks.2.1.proj_out.weight", "output_blocks.2.1.proj_out.bias", "output_blocks.2.2.conv.weight", "output_blocks.2.2.conv.bias", "output_blocks.8.1.conv.weight", "output_blocks.8.1.conv.bias". ....... size mismatch for input_blocks.7.0.in_layers.2.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([384, 256, 3, 3]). size mismatch for input_blocks.7.0.in_layers.2.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([384]). size mismatch for input_blocks.7.0.emb_layers.1.weight: copying a param with shape torch.Size([512, 512]) from checkpoint, the shape in current model is torch.Size([768, 512]). size mismatch for input_blocks.7.0.emb_layers.1.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([768]). size mismatch for input_blocks.7.0.out_layers.0.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([384]).

1362303119 commented 1 year ago

@xinrong6 Hello, I also encountered this problem, can you solve it?

zhangxiaofei000 commented 1 year ago

Hi, I also encountered this problem, can you solve it?

gerard-sanroma commented 8 months ago

I am also facing the same issue. Has anybody figured out the solution? Thanks!

inferioronly commented 3 months ago

Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults().

Alexdbsdfs commented 3 months ago

Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults().

hello,What should be done specifically

Alexdbsdfs commented 3 months ago

@xinrong6 @zhangxiaofei000 @gerard-sanroma can you solve it?

inferioronly commented 3 months ago

Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults().

hello,What should be done specifically

Hello, it depends on your MODEL_FALGS and DIFFUSION_FLAGS during training. For example, if you are using 256x256 pictures during training, set the image_size in model_and_diffusion_defaults () to 256, and the others are the same.

Alexdbsdfs commented 3 months ago

Hello, can we add a contact information?  

db @.***

 

------------------ 原始邮件 ------------------ 发件人: "openai/improved-diffusion" @.>; 发送时间: 2024年7月16日(星期二) 下午3:01 @.>; @.**@.>; 主题: Re: [openai/improved-diffusion] i meet a error when executing image_sample.py (Issue #109)

Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults().

hello,What should be done specifically

Hello, it depends on your MODEL_FALGS and DIFFUSION_FLAGS during training. For example, if you are using 256x256 pictures during training, set the image_size in model_and_diffusion_defaults () to 256, and the others are the same.

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

Alexdbsdfs commented 3 months ago

this classifier:

!/bin/bash

设置模型、分类器和采样的标志

TRAIN_FLAGS="--iterations 10000 --anneal_lr True --batch_size 32 --lr 3e-4 --save_interval 1000 --weight_decay 0.05" CLASSIFIER_FLAGS="--image_size 64 --classifier_attention_resolutions 32,16,8 --classifier_depth 2 --classifier_width 128 --classifier_pool attention --classifier_resblock_updown True --classifier_use_scale_shift_norm True"

执行命令

mpiexec -n N python scripts/classifier_train.py --data_dir /home/cumt306/dingbo/DCNv4/data/train $TRAIN_FLAGS $CLASSIFIER_FLAGS

this diffusion: MODEL_FLAGS="--image_size 64 --num_channels 128 --num_res_blocks 3" DIFFUSION_FLAGS="--diffusion_steps 4000 --noise_schedule linear" TRAIN_FLAGS="--lr 1e-4 --batch_size 32"

python scripts/image_train.py --data_dir  /home/cumt306/dingbo/DCNv4/data/train $MODEL_FLAGS $DIFFUSION_FLAGS $TRAIN_FLAGS

this sampling: MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --image_size 64 --learn_sigma True --num_channels 128 --num_heads 4 --num_res_blocks 3 --resblock_updown True --use_fp16 True --use_scale_shift_norm True" CLASSIFIER_FLAGS="--image_size 64 --classifier_attention_resolutions 32,16,8 --classifier_depth 4 --classifier_width 128 --classifier_pool attention --classifier_resblock_updown True --classifier_use_scale_shift_norm True --classifier_scale 1.0 --classifier_use_fp16 True" SAMPLE_FLAGS="--batch_size 32 --num_samples 1000 --timestep_respacing ddim25 --use_ddim True" mpiexec -n N python scripts/classifier_sample.py \      --model_path /home/cumt306/dingbo/guided-diffusion-main/diffusion_model/openai-2024-07-16-11-34-50-811594/model001000.pt\     --classifier_path /home/cumt306/dingbo/guided-diffusion-main/classer_model/openai-2024-07-16-11-28-48-194253/model001000.pt\     $MODEL_FLAGS $CLASSIFIER_FLAGS $SAMPLE_FLAGS

when i run samping :    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for UNetModel:         size mismatch for out.2.weight: copying a param with shape torch.Size([3, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([6, 128, 3, 3]).         size mismatch for out.2.bias: copying a param with shape torch.Size([3]) from checkpoint, the shape in current model is torch.Size([6]).

db @.***

 

------------------ 原始邮件 ------------------ 发件人: "openai/improved-diffusion" @.>; 发送时间: 2024年7月16日(星期二) 下午3:01 @.>; @.**@.>; 主题: Re: [openai/improved-diffusion] i meet a error when executing image_sample.py (Issue #109)

Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults().

hello,What should be done specifically

Hello, it depends on your MODEL_FALGS and DIFFUSION_FLAGS during training. For example, if you are using 256x256 pictures during training, set the image_size in model_and_diffusion_defaults () to 256, and the others are the same.

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

inferioronly commented 3 months ago

Hello, can we add a contact information?   db @.   ------------------ 原始邮件 ------------------ 发件人: "openai/improved-diffusion" @.>; 发送时间: 2024年7月16日(星期二) 下午3:01 @.>; @*.**@*.>; 主题: Re: [openai/improved-diffusion] i meet a error when executing image_sample.py (Issue #109) Just modify the corresponding parameters in the script_util.py file model_and_diffusion_defaults(). hello,What should be done specifically Hello, it depends on your MODEL_FALGS and DIFFUSION_FLAGS during training. For example, if you are using 256x256 pictures during training, set the image_size in model_and_diffusion_defaults () to 256, and the others are the same. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>

I cant see your emal