taki0112 / UGATIT

Official Tensorflow implementation of U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation (ICLR 2020)
MIT License
6.17k stars 1.04k forks source link

img_size is ignored when testing #20

Closed cpury closed 5 years ago

cpury commented 5 years ago

I wanted to train a test model via:

python main.py --dataset mydata --light=True --iteration=5000 --img_size=100 --save_freq=20

That seems to work fine. However, when running the test command, I get:

Traceback (most recent call last):
  File "main.py", line 106, in <module>
    main()
  File "main.py", line 102, in main
    gan.test()
  File "/content/UGATIT/UGATIT.py", line 640, in test
    fake_img = self.sess.run(self.test_fake_B, feed_dict = {self.test_domain_A : sample_image})
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 950, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1149, in _run
    str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 256, 256, 3) for Tensor 'test_domain_A:0', which has shape '(1, 100, 100, 3)'

Seems to me the model has the right size, but the loaded data in test mode defaults to 256?

sam598 commented 5 years ago

On lines 647 and 663 of UGATIT.py change: sample_image = np.asarray(load_test_data(sample_file)) to: sample_image = np.asarray(load_test_data(sample_file, size=self.img_size))

cpury commented 5 years ago

Awesome! If you're running this in the cloud and are too lazy to fork the project like me, this will fix it:

sed -i 's/load_test_data(sample_file)/load_test_data(sample_file, size=self.img_size)/g' UGATIT/UGATIT.py