yang-song / score_sde_pytorch

PyTorch implementation for Score-Based Generative Modeling through Stochastic Differential Equations (ICLR 2021, Oral)
https://arxiv.org/abs/2011.13456
Apache License 2.0
1.58k stars 295 forks source link

Error when running DDPM with celeb_a dataset. #25

Open marianaw opened 1 year ago

marianaw commented 1 year ago

Dear authors, I'm struggling to run the DDPM model on CELEBA dataset. Tensorflow, tensorflow_dataset and pytorch versions:

>>> tf.__version__
'2.9.1'
>>> tfds.__version__
'4.6.0'
>>> torch.__version__
'1.11.0+cu102'

This is my celeba.py config file:

# coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Lint as: python3
"""Config file for reproducing the results of DDPM on bedrooms."""

from configs.default_lsun_configs import get_default_configs

def get_config():
  config = get_default_configs()

  # training
  training = config.training
  training.sde = 'vpsde'
  training.continuous = False
  training.reduce_mean = True

  # sampling
  sampling = config.sampling
  sampling.method = 'pc'
  sampling.predictor = 'ancestral_sampling'
  sampling.corrector = 'none'

  # data
  data = config.data
  data.dataset = 'CELEBA'
  data.centered = True
  # data.tfrecords_path = '/atlas/u/yangsong/celeba_hq/-r10.tfrecords'
  data.image_size = 64
  data.batch_size = 64

  # model
  model = config.model
  model.name = 'ddpm'
  model.scale_by_sigma = False
  model.num_scales = 1000
  model.ema_rate = 0.9999
  model.normalization = 'GroupNorm'
  model.nonlinearity = 'swish'
  model.nf = 128
  model.ch_mult = (1, 2, 2, 2)
  model.num_res_blocks = 2
  model.attn_resolutions = (16,)
  model.resamp_with_conv = True
  model.conditional = True

  # optim
  optim = config.optim
  optim.lr = 2e-5

  return config

The error message is:

TypeError: in user code:                                                                                                                                                     

    File "/home/mvargasvieyra/others_code/score_sde_pytorch/datasets.py", line 169, in preprocess_fn  *                                                                      
        img = resize_op(d['image'])                                                                                                                                          
    File "/home/mvargasvieyra/others_code/score_sde_pytorch/datasets.py", line 121, in resize_op  *                                                                          
        img = resize_small(img, config.data.image_size)                                                                                                                      
    File "/home/mvargasvieyra/others_code/score_sde_pytorch/datasets.py", line 60, in resize_small  *                                                                        
        h = tf.round(h * ratio, tf.int32)                                                                                                                                    
    File "/usr/lib/python3.9/contextlib.py", line 117, in __enter__                                                                                                          
        return next(self.gen)                                                                                                                                                

    TypeError: expected string or bytes-like object    

By inspecting the dataset with ipdb I verified the ds object is not empty. Any hints would be greatly appreciated. Thanks!