titu1994 / Image-Super-Resolution

Implementation of Super Resolution CNN in Keras.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: could not broadcast input array from shape (3,32,32) into shape (3,64,64)

shreyaspalve opened this issue · comments

C:\Users\Shreyas\Image-Super-Resolution\Image-Super-Resolution>python tests.py
Using TensorFlow backend.
2018-04-10 12:19:18.301435: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Training model : ImageSuperResolutionModel
Epoch 1/250
Found 364 images.
Traceback (most recent call last):
File "tests.py", line 48, in
sr.fit(nb_epochs=250)
File "C:\Users\Shreyas\Image-Super-Resolution\Image-Super-Resolution\models.py", line 516, in fit
return super(ImageSuperResolutionModel, self).fit(batch_size, nb_epochs, save_history, history_fn)
File "C:\Users\Shreyas\Image-Super-Resolution\Image-Super-Resolution\models.py", line 122, in fit
validation_steps=val_count // batch_size + 1)
File "C:\Users\Shreyas\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Users\Shreyas\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\engine\training.py", line 2192, in fit_generator
generator_output = next(output_generator)
File "C:\Users\Shreyas\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\data_utils.py", line 793, in get
six.reraise(value.class, value, value.traceback)
File "C:\Users\Shreyas\AppData\Local\Programs\Python\Python36\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\Users\Shreyas\AppData\Local\Programs\Python\Python36\lib\site-packages\keras\utils\data_utils.py", line 658, in _data_generator_task
generator_output = next(self._generator)
File "C:\Users\Shreyas\Image-Super-Resolution\Image-Super-Resolution\img_utils.py", line 300, in image_generator
batch_x[i] = img.transpose((2, 0, 1))
ValueError: could not broadcast input array from shape (3,32,32) into shape (3,64,64)
@titu1994 can you please help for solving this issue?

It seems that I have solved this problem. I change the parameters of "def create_model(self, height=32, width=32, channels=3, load_weights=False, batch_size=128) " into "def create_model(self, height=64, width=64, channels=3, load_weights=False, batch_size=128)". @shreyaspalve

l meet this problem.maybe this is about the type of input images,l use img = cv2.resize(img, (64,64,3)) like this. but actually no help. can you give me some help

@hj950815 I am sorry. I haven't reviewed this project for almost 4 months, and I almost forget everything. Just try exactly what I said in the comment, and see whether it will work. I use the images provided in this repository, and everything goes well.

@hj950815:
The fix suggested by @Combo819 worked for me.
(But instead of changing the default parameters I changed my create_model call to pass width=64 and height=64.)

@Combo819 in what line? in what file? no lucky. i have the same error. no lucky yet

@hj950815:
The fix suggested by @Combo819 worked for me.
(But instead of changing the default parameters I changed my create_model call to pass width=64 and height=64.)

Neither of the suggestions worked for me. Did anyone find another solution?

I found the solution. Probably a dumb mistake. I hadn't set true_upscaling as False.