simontomaskarlsson / GAN-MRI

Code repository for Frontiers article 'Generative Adversarial Networks for Image-to-Image Translation on Multi-Contrast MR Images - A Comparison of CycleGAN and UNIT'
GNU General Public License v3.0
227 stars 77 forks source link

Error when checking input: expected input_5 to have 4 dimensions, but got array with shape (1, 256, 170, 1, 3) #4

Closed nvnvashisth closed 5 years ago

nvnvashisth commented 5 years ago

What could be possible solution here?

--- Caching data --- Data has been loaded Traceback (most recent call last): File "CycleGAN.py", line 935, in GAN = CycleGAN() File "CycleGAN.py", line 246, in init self.train(epochs=self.epochs, batch_size=self.batch_size, save_interval=self.save_interval) File "CycleGAN.py", line 606, in train run_training_iteration(loop_index, epoch_iterations) File "CycleGAN.py", line 400, in run_training_iteration synthetic_images_B = self.G_A2B.predict(real_imagesA) File "/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1149, in predict x, , _ = self._standardize_user_data(x) File "/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 751, in _standardize_user_data exception_prefix='input') File "/anaconda3/lib/python3.6/site-packages/keras/engine/training_utils.py", line 128, in standardize_input_data 'with shape ' + str(data_shape)) ValueError: Error when checking input: expected input_5 to have 4 dimensions, but got array with shape (1, 256, 170, 1, 3)

simontomaskarlsson commented 5 years ago

Hi @nvnvashisth, I am not sure but the problem might be due to the image size. Which image size are you using and have you set the corresponding values in the contructor on row 32? def __init__(self, lr_D=2e-4, lr_G=2e-4, image_shape=(height, width, nr-of-channels)

nvnvashisth commented 5 years ago

Hi, there was some preprocessing issue, but it worked later. Thanks for your contribution 👍