yenchenlin / pix2pix-tensorflow

TensorFlow implementation of "Image-to-Image Translation Using Conditional Adversarial Networks".
MIT License
939 stars 300 forks source link

Error running code with my own dataset of grayscale images #35

Open marialarsson opened 6 years ago

marialarsson commented 6 years ago

Hi,

I am trying to run this code on my own dataset of greyscale images (sample attached). I replaced the images in facade/train and set input_c_dim=1, output_c_dim=1

But I get the following error message below. I suspect it has something to do with the greyscale because at the bottom of the error message it says "Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [3]"

Any ideas?

It works when I run it on the original dataset by the way (with input_c_dim=3, output_c_dim=3)

Thanks, Maria

1

~/git/pix2pix-tensorflow$ python main.py --phase train [*] Reading checkpoint... Traceback (most recent call last): File "main.py", line 58, in tf.app.run() File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "main.py", line 53, in main model.train(args) File "/home/hiro/git/pix2pix-tensorflow/model.py", line 150, in train if self.load(self.checkpoint_dir): File "/home/hiro/git/pix2pix-tensorflow/model.py", line 388, in load self.saver.restore(self.sess, os.path.join(checkpoint_dir, ckpt_name)) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1802, in restore {self.saver_def.filename_tensor_name: save_path}) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 900, in run run_metadata_ptr) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1135, in _run feed_dict_tensor, options, run_metadata) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1316, in _do_run run_metadata) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1335, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [3] [[Node: save/Assign_92 = Assign[T=DT_FLOAT, _class=["loc:@generator/g_d8/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](generator/g_d8/biases, save/RestoreV2:92)]]

Caused by op u'save/Assign_92', defined at: File "main.py", line 58, in tf.app.run() File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "main.py", line 50, in main checkpoint_dir=args.checkpoint_dir, sample_dir=args.sample_dir) File "/home/hiro/git/pix2pix-tensorflow/model.py", line 67, in init self.build_model() File "/home/hiro/git/pix2pix-tensorflow/model.py", line 109, in build_model self.saver = tf.train.Saver() File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1338, in init self.build() File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1347, in build self._build(self._filename, build_save=True, build_restore=True) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1384, in _build build_save=build_save, build_restore=build_restore) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 835, in _build_internal restore_sequentially, reshape) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 494, in _AddRestoreOps assign_ops.append(saveable.restore(saveable_tensors, shapes)) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 185, in restore self.op.get_shape().is_fully_defined()) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/state_ops.py", line 283, in assign validate_shape=validate_shape) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign use_locking=use_locking, name=name) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 3392, in create_op op_def=op_def) File "/home/hiro/git/pix2pix-tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1718, in init self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [3] [[Node: save/Assign_92 = Assign[T=DT_FLOAT, _class=["loc:@generator/g_d8/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](generator/g_d8/biases, save/RestoreV2:92)]]