openai / guided-diffusion

MIT License
6.06k stars 807 forks source link

Assertion Error of variable `betas` when using 256 x 256 model with classifier guidance #30

Closed jiahaolu97 closed 2 years ago

jiahaolu97 commented 2 years ago

When I use the recommended command

MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True" python classifier_sample.py $MODEL_FLAGS --classifier_scale 1.0 --classifier_path models/256x256_classifier.pt --model_path models/256x256_diffusion.pt $SAMPLE_FLAGS

There seems to be an assertion error

Logging to results/openai-2022-04-22-15-28-42-019927 creating model and diffusion... Traceback (most recent call last): File "scripts/classifier_sample.py", line 152, in main() File "scripts/classifier_sample.py", line 35, in main model, diffusion = create_model_and_diffusion( File "/home/lujiahao/research/guided-diffusion-main/guided_diffusion/script_util.py", line 117, in create_model_and_diffusion diffusion = create_gaussian_diffusion( File "/home/lujiahao/research/guided-diffusion-main/guided_diffusion/script_util.py", line 407, in create_gaussian_diffusion return SpacedDiffusion( File "/home/lujiahao/research/guided-diffusion-main/guided_diffusion/respace.py", line 77, in init base_diffusion = GaussianDiffusion(**kwargs) # pylint: disable=missing-kwoa File "/home/lujiahao/research/guided-diffusion-main/guided_diffusion/gaussian_diffusion.py", line 136, in init assert (betas > 0).all() and (betas <= 1).all() AssertionError

And I print the betas value :

[0.01 0.23111111 0.45222222 0.67333333 0.89444444 1.11555556 1.33666667 1.55777778 1.77888889 2. ]

How to solve this bug?

jiahaolu97 commented 2 years ago

Problem solved.

Using a too-small diffusion_steps will cause the error. When I set diffusion_steps=10 , the betas will not pass assertion.

Using a recommend diffusion_steps = 1000 will not cause the problem.

I'm closing this issue.

ONobody commented 1 year ago

@RoyLJH Hello, do you need to make any adjustments when using your own data set code part when training guided_classifier?