openai / guided-diffusion

MIT License
5.9k stars 782 forks source link

Issue about loading cifar-10 data : How to train the diffusion model on cifar-10? #131

Open youyuanyi opened 8 months ago

youyuanyi commented 8 months ago

How to train the diffusion model on cifar-10? The load_data() function in image_datasets.py can not load cifar-10 datasets directly

My train.sh is following:

MODEL_FLAGS="--image_size 32 --num_channels 128 --num_res_blocks 3 --learn_sigma True --dropout 0.3"
DIFFUSION_FLAGS="--diffusion_steps 4000 --noise_schedule cosine"
TRAIN_FLAGS="--lr 1e-4 --batch_size 128"

# Train
python scripts/image_train.py --data_dir ../data/cifar-10-batches-py $MODEL_FLAGS $DIFFUSION_FLAGS $TRAIN_FLAGS

in ../data/cifar-10-batches-py, there are data like this : batches.meta data_batch_1 data_batch_2 data_batch_3 data_batch_4 data_batch_5 readme.html test_batch

sibasmarak commented 8 months ago

Hi, please try to follow the steps outlined here in the README script of the parent repository for cifar10.

youyuanyi commented 8 months ago

Thanks for the tip! Thank you very much!

youyuanyi commented 8 months ago

Hi, please try to follow the steps outlined here in the README script of the parent repository for cifar10.

Thanks again for your kind help! I want to train a guided diffusion on cifar-10 dataset. It seems I need to both train a diffusion model and a 32x32 classifier on cifar-10. So I have the following two issues:

  1. Is the model trained in the "improved diffusion" repository can be directly used in guided diffusion?
  2. Can a 32x32 classifier be trained on the cifar-10 data set in 'guided difffusion'? It seems like the code only support 64x64,128x128,256x256,512x512 input size
sibasmarak commented 8 months ago
  1. If the image sizes match (which is not the case for CIFAR), then you can directly use from improved diffusion repository.
  2. Yes, guided diffusion has no support for 32 image sizes (although, I suppose you can copy and re-use the code blocks for 32 image size from improved diffusion)
youyuanyi commented 8 months ago
  1. If the image sizes match (which is not the case for CIFAR), then you can directly use from improved diffusion repository.
  2. Yes, guided diffusion has no support for 32 image sizes (although, I suppose you can copy and re-use the code blocks for 32 image size from improved diffusion)

Thank you! I think i got what you mean. I suppose I can adapt the input and output layer of the classifier model and fine-tune it on cifar-10.

Tongmengjun commented 4 months ago

How to evluate fid on cifar10? I can't find cifar10's ref batch.