CycleGAN-tensorflow
CycleGAN-tensorflow copied to clipboard
How to train with parameter `--load_size=512 --fine_size=512` ?
When i try to run: CUDA_VISIBLE_DEVICES=0 python main.py --dataset_dir=my_dataset --load_size=512 --fine_size=512
, a error apear:
Traceback (most recent call last):
File "main.py", line 53, in <module>
tf.app.run()
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "main.py", line 49, in main
model.train(args) if args.phase == 'train' \
File "/home/vsocr/workplace/CycleGAN-tensorflow/model.py", line 158, in train
feed_dict={self.real_data: batch_images, self.lr: lr})
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1100, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 511, 511, 6) for Tensor 'real_A_and_B_images:0', which has shape '(?, 512, 512, 6)'
And run: CUDA_VISIBLE_DEVICES=0 python main.py --dataset_dir=2k_v1 --load_size=513 --fine_size=512
, error:
tf.app.run()
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "main.py", line 49, in main
model.train(args) if args.phase == 'train' \
File "/home/vsocr/workplace/CycleGAN-tensorflow/model.py", line 176, in train
self.sample_model(args.sample_dir, epoch, idx)
File "/home/vsocr/workplace/CycleGAN-tensorflow/model.py", line 218, in sample_model
feed_dict={self.real_data: sample_images}
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 895, in run
run_metadata_ptr)
File "/home/vsocr/py3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 1100, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 256, 256, 6) for Tensor 'real_A_and_B_images:0', which has shape '(?, 512, 512, 6)'
My images input shape: (512, 512, 3)
.
It seems to be a bug in code. Can you show me right way to put parameters?
as i understood it, a bug in the line https://github.com/xhujoy/CycleGAN-tensorflow/blob/master/model.py#L213 you need to pass the correct parameters into the function load_train_data
Hi @TechBK Have you find the way to train 512x512 images?
@TechBK @skalinin Hello, I am new to TensorFlow and machine learning.I have the same problem with you. How did you solve it?Is it related to my trainA trainB picture size? My A B size is different, the pixel is not 256 * 256.Here is my error:ValueError: Cannot feed value of shape (0,) for Tensor 'real_A_and_B_images:0', which has shape '(?, 256, 256, 6)'
I have solved this problem because the test must have photos
@TechBK Try setting your load_size to a higher resolution, since it is cropped later to the fine size.
e.g. load_size = 586
@Deeplearning20 I met the same problem with yours. Can you tell me how did you solve this problem?
@giaosam Please check if all trainA, trainB, testA, testB folders exist and not empty.
Even if I have images in trainA and trainB the error keeps appearing. Is there a certain amount of images that have to be present in the train folder?Thanks for your help.
@ennemoser Please note that there must be images in testA and testB.
Thank you very much for your quick response. I also have images in testA and test B. But the error keeps appearing. I define load size and fine size exactly like above. But do I have to change any other parameter/ argument?
@skalinin thank you . a bug in the line https://github.com/xhujoy/CycleGAN-tensorflow/blob/master/utils.py#L51: def load_train_data(image_path, load_size=286, fine_size=256, is_testing=False): @TechBK you may give there a same value as load_size and fine_size. for example:513 and 512
I think the bug is in the line https://github.com/xhujoy/CycleGAN-tensorflow/blob/master/model.py#L213: load_train_data(batch_file, is_testing=True) the load_train_data() will use default value which is :load_size=286, fine_size=256. you can change the function this way: load_train_data(batch_file, new_load_size, new_fine_size, is_testing=True)