awentzonline / image-analogies

Generate image analogies using neural matching and blending.
MIT License
3.52k stars 283 forks source link

Mismatch of Images #27

Open rlkelly opened 8 years ago

rlkelly commented 8 years ago

I get this error when I run the app with images I insert, I check with numpy/cv2 and they have the same shape, so I was wondering where this error is coming from?

Using Theano backend. /usr/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module. "downsample module has been moved to the theano.tensor.signal.pool module.") Theano CPU mode detected. Forcing a-scale-mode to "match" Using PatchMatch model Scale factor 0.25 "A" shape (1, 4, 132, 186) "B" shape (1, 3, 132, 186) Building loss... Precomputing static features... Traceback (most recent call last): File "/usr/local/bin/make_image_analogy.py", line 27, in image_analogy.main.main(args, model_class) File "/usr/local/lib/python2.7/site-packages/image_analogy/main.py", line 69, in main model.build(a_image, ap_image, b_image, (1, img_num_channels, img_height, img_width)) File "/usr/local/lib/python2.7/site-packages/image_analogy/models/nnf.py", line 17, in build loss = self.build_loss(a_image, ap_image, b_image) File "/usr/local/lib/python2.7/site-packages/image_analogy/models/nnf.py", line 55, in build_loss all_a_features, all_ap_image_features, all_b_features = self.precompute_static_features(a_image, ap_image, b_image) File "/usr/local/lib/python2.7/site-packages/image_analogy/models/base.py", line 53, in precompute_static_features all_a_features = self.get_features(a_image, a_layers) File "/usr/local/lib/python2.7/site-packages/image_analogy/models/base.py", line 62, in get_features feature_outputs = f([x]) File "/usr/local/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 384, in call return self.function(inputs) File "/usr/local/lib/python2.7/site-packages/theano/compile/function_module.py", line 871, in call storage_map=getattr(self.fn, 'storage_map', None)) File "/usr/local/lib/python2.7/site-packages/theano/gof/link.py", line 314, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/usr/local/lib/python2.7/site-packages/theano/compile/function_module.py", line 859, in call outputs = self.fn() ValueError: The hardcoded shape for the image stack size (3) isn't the run time shape (4). Apply node that caused the error: ConvOp{('imshp', (3, 134, 188)),('kshp', (3, 3)),('nkern', 64),('bsize', None),('dx', 1),('dy', 1),('out_mode', 'valid'),('unroll_batch', None),('unroll_kern', None),('unroll_patch', True),('imshp_logical', (3, 134, 188)),('kshp_logical', (3, 3)),('kshp_logical_top_aligned', True)}(IncSubtensor{InplaceSet;::, ::, int64:int64:, int64:int64:}.0, <TensorType(float32, 4D)>) Toposort index: 26 Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)] Inputs shapes: [(1, 4, 134, 188), (64, 3, 3, 3)] Inputs strides: [(403072, 100768, 752, 4), (108, 36, 12, 4)] Inputs values: ['not shown', 'not shown'] Outputs clients: [[Elemwise{Composite{(i0 \ (Abs((i1 + i2)) + i1 + i2))}}[(0, 1)](TensorConstant{%281, 1, 1, 1%29 of 0.5}, ConvOp{%28'imshp', %283, 134, 188%29%29,%28'kshp', %283, 3%29%29,%28'nkern', 64%29,%28'bsize', None%29,%28'dx', 1%29,%28'dy', 1%29,%28'out_mode',),('unroll_batch', None),('unroll_kern', None),('unroll_patch', True),('imshp_logical', (3, 134, 188)),('kshp_logical', (3, 3)),('kshp_logical_top_aligned', True)}.0, Reshape{4}.0)]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer): File "/usr/local/lib/python2.7/site-packages/keras/layers/convolutional.py", line 496, in get_output X = self.get_input(train) File "/usr/local/lib/python2.7/site-packages/keras/layers/core.py", line 175, in get_input previous_output = self.previous.get_output(train=train) File "/usr/local/lib/python2.7/site-packages/keras/layers/convolutional.py", line 312, in get_output X = self.get_input(train) File "/usr/local/lib/python2.7/site-packages/keras/layers/core.py", line 175, in get_input previous_output = self.previous.get_output(train=train) File "/usr/local/lib/python2.7/site-packages/keras/layers/convolutional.py", line 763, in get_output X = self.get_input(train) File "/usr/local/lib/python2.7/site-packages/keras/layers/core.py", line 175, in get_input previous_output = self.previous.get_output(train=train) File "/usr/local/lib/python2.7/site-packages/keras/layers/convolutional.py", line 317, in get_output filter_shape=self.W_shape) File "/usr/local/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 624, in conv2d filter_shape=filter_shape)

HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

rlkelly commented 8 years ago

Input and Output images must both be 2-dimensional, 3-dimensional, etc.

If you go into image-analogies/main.py you'll see on line 65 the method for getting dimensions from from image_analogy import img_utils, vgg16 and this will help to troubleshoot the problem.

6o6o commented 8 years ago

Make sure your images do not contain an alpha channel. You can check with identify -verbose your_image.png To switch it off convert -alpha off your_image.png new_image.png