bnsreenu / python_for_microscopists

https://www.youtube.com/channel/UC34rW-HtPJulxr5wp2Xa04w?sub_confirmation=1
MIT License
3.78k stars 2.35k forks source link

Noise2Void shape broadcast error during prediction #83

Open astronerdF opened 4 months ago

astronerdF commented 4 months ago

I have followed the 293_denoising_RGB_images_using_deep_learning.ipynb and everything seemed fine except while trying to predict.

This is the error that I get: `pred = model.predict(img, axes='YXC')


ValueError Traceback (most recent call last) Cell In[26], line 5 1 # Here we denoise the image (predict) 2 # The parameter 'n_tiles' can be used if images are to big for the GPU memory. 3 # If we do not provide the n_tiles' parameter the system will automatically try to find an appropriate tiling. 4 # This can take longer. ----> 5 pred = model.predict(img, axes='YXC')

File ~/Desktop/N2VTensorFlow/n2vTF/lib/python3.8/site-packages/n2v/models/n2v_standard.py:382, in N2V.predict(self, img, axes, resizer, n_tiles, tta) 380 if n_tiles: 381 new_n_tiles = tuple([n_tiles[axes.index(c)] for c in axes if c != 'C']) + (n_tiles[axes.index('C')],) --> 382 normalized = self.normalize(np.moveaxis(img, axes.index('C'), -1), means, stds) 383 else: 384 normalized = self.normalize(img[..., np.newaxis], means, stds)

File ~/Desktop/N2VTensorFlow/n2vTF/lib/python3.8/site-packages/n2v/models/n2v_standard.py:341, in N2V.normalize(self, data, means, stds) 340 def normalize(self, data, means, stds): --> 341 return (data - means) / stds

ValueError: operands could not be broadcast together with shapes (359,497,4) (1,1,3)`