jerryli27 / TwinGAN

Twin-GAN -- Unpaired Cross-Domain Image Translation with Weight-Sharing GANs
Apache License 2.0
719 stars 99 forks source link

Placeholder issue #12

Closed bakirillov closed 6 years ago

bakirillov commented 6 years ago

When I run as follows: python inference/image_translation_infer.py --model_path="\~/Documents/weights/256" --image_hw=256 --input_tensor_name="sources_ph" --output_tensor_name="custom_generated_t_style_source:0" input_image_path="\~/Documents/art/photo.jpg" --output_image_path="\~/Documents/art/" --num_output=1 I get that error: Traceback (most recent call last): File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call return fn(*args) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1263, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype uint8 and shape [?,?,?] [[Node: Placeholder = Placeholder[dtype=DT_UINT8, shape=[?,?,?], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] [[Node: custom_generated_t_style_source/_2051 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1565_custom_generated_t_style_source", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "inference/image_translation_infer.py", line 128, in tf.app.run() File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "inference/image_translation_infer.py", line 109, in main outputs, image_paths = inferer.infer(FLAGS.input_image_path, return_image_paths=True, num_output=FLAGS.num_output) File "inference/image_translation_infer.py", line 91, in infer output = self.sess.run(self.output, feed_dict=feed_dict) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 877, in run run_metadata_ptr) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1100, in _run feed_dict_tensor, options, run_metadata) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1272, in _do_run run_metadata) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1291, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype uint8 and shape [?,?,?] [[Node: Placeholder = Placeholder[dtype=DT_UINT8, shape=[?,?,?], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] [[Node: custom_generated_t_style_source/_2051 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1565_custom_generated_t_style_source", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Caused by op 'Placeholder', defined at: File "inference/image_translation_infer.py", line 128, in tf.app.run() File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "inference/image_translation_infer.py", line 103, in main inferer = ImageInferer() File "inference/image_translation_infer.py", line 55, in init self.images_placeholder = tf.placeholder(dtype=tf.uint8, shape=[None, None, None]) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1735, in placeholder return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 4925, in placeholder "Placeholder", dtype=dtype, shape=shape, name=name) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func return func(*args, **kwargs) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op op_def=op_def) File "/home/bakirillov/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1717, in init self._traceback = tf_stack.extract_stack()

InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder' with dtype uint8 and shape [?,?,?] [[Node: Placeholder = Placeholder[dtype=DT_UINT8, shape=[?,?,?], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] [[Node: custom_generated_t_style_source/_2051 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_1565_custom_generated_t_style_source", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]] I checked and in inference/image_translation_infer.py everything looks correct. What am I doing wrong? Python 3.6.4. Anaconda, tensorflow 1.10, keras 2.2.2

jerryli27 commented 6 years ago

Sorry for the late reply. You seem to be missing a -- for the input_image_path flag. (Happens to me all the time)

Please try

python inference/image_translation_infer.py --model_path="~/Documents/weights/256" --image_hw=256 --input_tensor_name="sources_ph" --output_tensor_name="custom_generated_t_style_source:0" --input_image_path="~/Documents/art/photo.jpg" --output_image_path="~/Documents/art/" --num_output=1

Thanks!

bakirillov commented 6 years ago

Thank you very much! Now it works!