JiahuiYu / generative_inpainting

DeepFill v1/v2 with Contextual Attention and Gated Convolution, CVPR 2018, and ICCV 2019 Oral
http://jiahuiyu.com/deepfill/
Other
3.27k stars 787 forks source link

RuntimeError: tf.placeholder() is not compatible with eager execution. #494

Closed kangjh0226 closed 3 years ago

kangjh0226 commented 3 years ago

Hi there, I'm using tensorflow 2.4.1 to try to run this code. and I met a problem on file inpaint_ops.py from neuralgym library.

image

This is part of initializing class DataFromFNames(Dataset):

Changing tf.placeholder to tf.compat.v1.placeholder is not enough. Here is terminal result:

2021-03-19 15:04:52.047612: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll ---------------------------------- APP CONFIG ---------------------------------- num_gpus_per_job: 1 num_cpus_per_job: 4 num_hosts_per_job: 1 memory_per_job: 32 gpu_type: nvidia-tesla-p100 name: places2_gated_conv_v100 model_restore: dataset: celebahq random_crop: False val: False log_dir: logs/full_model_celeba_hq_256 gan: sngan gan_loss_alpha: 1 gan_with_mask: True discounted_mask: True random_seed: False padding: SAME train_spe: 4000 max_iters: 100000000 viz_max_out: 10 val_psteps: 2000 data_flist: celebahq: ['data/celeba_hq/train_shuffled.flist.txt', 'data/celeba_hq/validation_static_view.flist.txt'] celeba: ['data/celeba/train_shuffled.flist', 'data/celeba/validation_static_view.flist'] places2: ['data/places2/train_shuffled.flist', 'data/places2/validation_static_view.flist'] imagenet: ['data/imagenet/train_shuffled.flist', 'data/imagenet/validation_static_view.flist'] static_view_size: 30 img_shapes: [178, 218, 3] height: 128 width: 128 max_delta_height: 32 max_delta_width: 32 batch_size: 4 vertical_margin: 0 horizontal_margin: 0 ae_loss: True l1_loss: True l1_loss_alpha: 1.0 guided: False edge_threshold: 0.6

Traceback (most recent call last): File "train.py", line 38, in nthreads=FLAGS.num_cpus_per_job) File "F:\GGH\code\run\venv\lib\site-packages\neuralgym\data\data_from_fnames.py", line 85, in init for dtype, shape in zip(self.dtypes, self.shapes)] File "F:\GGH\code\run\venv\lib\site-packages\neuralgym\data\data_from_fnames.py", line 85, in for dtype, shape in zip(self.dtypes, self.shapes)] File "F:\GGH\code\run\venv\lib\site-packages\tensorflow\python\ops\array_ops.py", line 3176, in placeholder raise RuntimeError("tf.placeholder() is not compatible with " RuntimeError: tf.placeholder() is not compatible with eager execution.

If you know anything about upper problem, please give me advice, sincerely.

kangjh0226 commented 3 years ago

I add tf.compat.v1.disable_eager_execution() just after import tensorflow