Vishal2188 / TherISuRNet---A-Computationally-Efficient-Thermal-Image-Super-Resolution-Network

Tensorflow implementation of our Paper published in PBVS Workshop 2020 in Conjunction with CVPR 2020.
MIT License
20 stars 5 forks source link

Size incompatibility #1

Closed Moaazallaham closed 3 years ago

Moaazallaham commented 3 years ago

Thank you so much for sharing

I am trying to retrain your network on the PBVS dataset, and I tried running your code without any modification, but I get this error:

Traceback (most recent call last): File "main.py", line 185, in main() File "main.py", line 96, in main L1_loss = tf.compat.v1.losses.absolute_difference(y, t) File "C:\Users\moaaz\anaconda3\envs\TherISuRNet\lib\site-packages\tensorflow_core\python\ops\losses\losses_impl.py", line 253, in absolute_difference predictions.get_shape().assert_is_compatible_with(labels.get_shape()) File "C:\Users\moaaz\anaconda3\envs\TherISuRNet\lib\site-packages\tensorflow_core\python\framework\tensor_shape.py", line 1115, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (4, 192, 192, 3) and (4, 256, 256, 3) are incompatible

Trying to find what is the cause of the problem, I found that y and t in main.py Line#92 are of different sizes. Digging further into it, I found that in model.py Line#75, you use the _img_size3, img_size3_ , where in model.py Line#95 you use size=[h 4, w 4] , and that is why y and t are resulting in different sizes. Is that how it is supposed to be?

I wonder if you can help me with it.

Vishal2188 commented 3 years ago

Thanks for your query.

Actually, one correction is there. I have corrected it. In the main path, I have upscale the feature maps with pixel shuffle operation using factor 2 (i.e., line number 81 from model.py file) while in the global residual learning path (i.e., line number 95 from model.py file), I have upscale the feature maps with factor 4.

So in order to solve this, two options are there. 1) You just change the upscale factor value from 2 to 4 (i.e., at line number 81 from model.py) as x = tf.depth_to_space(x, 4)

or

2) Just use that command two time as listed below (line number 114 -115 from updated model.py file):

xUP = self.Upsample2xBlock(x4, kernel_size=3, filters=64, strides = 1) xUP = self.Upsample2xBlock(xUP, kernel_size=3, filters=64, strides = 1)

so that the feature maps from the main path are upscaled with factor 4.

Another correction is from main.py file. It was created for upscale factor 3. So I have changed few sentences as listed below: 1) line number 75, t = tf.placeholder(tf.float32, [bs, img_size 4, img_size 4, 3]) 2) line number 149, X = cv2.resize(X,(img_size 2 4, img_size 2 4),interpolation = cv2.INTER_CUBIC) (earlier the img_size was multipled with 3)