Newbeeer / Poisson_flow

Code for NeurIPS 2022 Paper, "Poisson Flow Generative Models" (PFGM)
Apache License 2.0
846 stars 58 forks source link

UnboundLocalError: local variable 'eval_ds' referenced before assignment #5

Closed vagrant3427 closed 1 year ago

vagrant3427 commented 1 year ago

Hi, Yilun, I have another question. When I was sampling from bedroom_ddpmpp model, an error occurs

  File "/home/xjtu/code/Poisson_flow/main.py", line 60, in <module>
    app.run(main)
  File "/home/xjtu/anaconda3/envs/sde/lib/python3.9/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/xjtu/anaconda3/envs/sde/lib/python3.9/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/xjtu/code/Poisson_flow/main.py", line 54, in main
    run_lib.evaluate(FLAGS.config, FLAGS.workdir, FLAGS.eval_folder)
  File "/home/xjtu/code/Poisson_flow/run_lib.py", line 345, in evaluate
    eval_iter = iter(eval_ds)  # pytype: disable=wrong-arg-types
UnboundLocalError: local variable 'eval_ds' referenced before assignment

I found that the reason is in #LINE 124 in the datasets.py, as the following:

dataset_builder = tfds.builder(f'lsun/{config.data.category}', data_dir='/scratch/ylxu/tensorflow_datasets')

So I wonder why is the config of 'LSUN' dataset different from CIFAR10 or CELEBA. (i.e. there is a data_dir which I could not find)

Newbeeer commented 1 year ago

Hi,

For Q1: Did you include --config.eval.save_images flag in your comment? If so, the dataset wouldn't be loaded.

For Q2: Thanks for pointing out the issue. I've removed it in the repo. The argument data_dir is the path to store the data. Previously I used the path on my server. Please specify the path on your server, or by default it will be saved to TFDS_DATA_DIR.

Yilun

vagrant3427 commented 1 year ago

Yes, I include --config.eval.save_images flag.

python3 main.py --config ./configs/poisson/bedroom_ddpmpp.py --mode eval --workdir poisson/bedroom_ddpmpp --config.eval.enable_sampling --config.eval.save_images --config.eval.batch_size 100

The error is still as following:

Traceback (most recent call last):
  File "/home/xjtu/code/Poisson_flow/main.py", line 60, in <module>
    app.run(main)
  File "/home/xjtu/anaconda3/envs/sde/lib/python3.9/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/xjtu/anaconda3/envs/sde/lib/python3.9/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/xjtu/code/Poisson_flow/main.py", line 54, in main
    run_lib.evaluate(FLAGS.config, FLAGS.workdir, FLAGS.eval_folder)
  File "/home/xjtu/code/Poisson_flow/run_lib.py", line 345, in evaluate
    eval_iter = iter(eval_ds)  # pytype: disable=wrong-arg-types
UnboundLocalError: local variable 'eval_ds' referenced before assignment
Newbeeer commented 1 year ago

Hi,

It seems that you enable config.eval.enable_loss in the config file. In this case, please either disable config.eval.enable_loss, or remove the --config.eval.save_images flag.

vagrant3427 commented 1 year ago

I used your original config file first. As you said, I disable config.eval.enable_loss and it goes right. Thank u again!

Newbeeer commented 1 year ago

Sounds good! Thanks for pointing it out. I also set the default config.eval.enable_loss to False in current repo.