Closed Leon-Sander closed 2 years ago
I have not tested on CPU yet, sorry I have no idea
No problem, I found a workaround.
@tf.function(experimental_compile=True) needs to be added on top of the call function of the WaveLetPooling and WaveLetUnPooling in the ops.py file.
Hello,
when I am running the inference example without GPU enabled, I get the error displayed below. There are no problems when GPU is enabled. Do you have any idea why it is so?
InvalidArgumentError Traceback (most recent call last) /tmp/ipykernel_29724/90658942.py in
7 style = read_img(style, image_size, expand_dims=True)
8
----> 9 gen = model.transfer(content, style, 1.0)
10 #cv2.imwrite('test.png', gen[0][...,::-1])
11 display_outputs(content[0], style[0], gen[0])
~/code/test/photorealistic_style_transfer/model.py in transfer(self, content_img, style_img, alpha) 211 content_feat = WhiteningAndColoring(alpha)([content_feat, style_feat]) 212 # step 2. --> 213 content_feat = self.unpool_1([content_feat] + c_skips_3) 214 style_feat = self.unpool_1([style_feat] + s_skips_3) 215 content_feat = WhiteningAndColoring(alpha)([content_feat, style_feat])
~/code/environments/tf2/lib/python3.8/site-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs) 65 except Exception as e: # pylint: disable=broad-except 66 filtered_tb = _process_traceback_frames(e.traceback) ---> 67 raise e.with_traceback(filtered_tb) from None 68 finally: 69 del filtered_tb
~/code/test/photorealistic_style_transfer/ops.py in call(self, inputs) 78 out_shape = tf.shape(tensor_in) 79 return tf.concat([ ---> 80 _conv2d_transpose(LL_in, LL, output_shape=out_shape), 81 _conv2d_transpose(LH_in, LH, output_shape=out_shape), 82 _conv2d_transpose(HL_in, HL, output_shape=out_shape),
~/code/test/photorealistic_style_transfer/ops.py in _conv2d_transpose(x, kernel, output_shape) 171 172 def _conv2d_transpose(x, kernel, output_shape): --> 173 conv = tf.nn.conv2d_transpose( 174 x, kernel, 175 output_shape=output_shape,
InvalidArgumentError: Exception encountered when calling layer "wave_let_unpooling_2" (type WaveLetUnPooling).
Computed input depth 256 doesn't match filter input depth 1 [Op:Conv2DBackpropInput]
Call arguments received: • inputs=['tf.Tensor(shape=(1, 43, 64, 256), dtype=float32)', 'tf.Tensor(shape=(1, 43, 64, 256), dtype=float32)', 'tf.Tensor(shape=(1, 43, 64, 256), dtype=float32)', 'tf.Tensor(shape=(1, 43, 64, 256), dtype=float32)', 'tf.Tensor(shape=(1, 85, 128, 256), dtype=float32)']
Update: It seems to be a problem with grouped convolutions, which is not implemented yet on cpu by tensorflow. More information here