sysu-imsl / EdgeGAN

Code for paper "SketchyCOCO: Image Generation from Freehand Scene Sketches" (CVPR 2020)
https://sysu-imsl.com/EdgeGAN/
45 stars 7 forks source link

Issue training with customized dataset #16

Closed WaichungLing closed 2 years ago

WaichungLing commented 2 years ago

Hi @Mukosame @liuq99 , Thanks for sharing the code and we find your project very interesting. We are trying to train the model with our own dataset. The dataset is in the same format as specified. It has five categories and each train/test image is 64*128*3. However, we got the following error message. Any idea on what leads to this? Thanks in advanced and looking forward to your reply.

tensorflow/core/common_runtime/executor.cc:641] Executor failed to create kernel. Invalid argument: Conv2DCustomBackpropInputOp only supports NHWC.
     [[{{node gradients_6/D2/mru_conv_unit_t_4_layer_0/Conv_2/Conv2D_grad/Conv2DBackpropInput}}]]
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/envs/EdgeGAN/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
    return fn(*args)
  File "/home/ubuntu/anaconda3/envs/EdgeGAN/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/home/ubuntu/anaconda3/envs/EdgeGAN/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Conv2DCustomBackpropInputOp only supports NHWC.
     [[{{node gradients_6/D2/mru_conv_unit_t_4_layer_0/Conv_2/Conv2D_grad/Conv2DBackpropInput}}]]
WaichungLing commented 2 years ago

For anyone facing the same issue: Try the following fix in conv.py:conv2d2

# NCHW -> NHWC
inputs = tf.transpose(inputs, [0, 2, 3, 1])

conv_out = tf.compat.v1.nn.conv2d(
    inputs, filters=weights, strides=stride, padding='SAME', data_format='NHWC')

# NHWC -> NCHW
 conv_out = tf.transpose(conv_out, [0, 3, 1, 2])