0
$\begingroup$

I'm building a CNN decoder, which mirrors (in reverse) the VGG network structure from Conv-4-1 layer.

The net seems to be working fine, however, the output looks broken. Please note that the colour distortion is fine, it's the the [255/0 RGB pixels] e.g. green that I'm worrying about.

I tried to overfit a single image, but even then I get these hot pixels. Does anyone know why they appear?

enter image description here

My net:

    activation = 'elu'

    input_ = Input((None, None, 512))
    x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', bias_initializer='zeros', activation=activation)(input_)

    x = UpSampling2D()(x)
    for _ in range(3):
        x = Conv2D(filters=256, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
    x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)

    x = UpSampling2D()(x)
    x = Conv2D(filters=128, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
    x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)

    x = UpSampling2D()(x)
    x = Conv2D(filters=64, kernel_size=self.kernel_size, padding='same', activation=activation)(x)
    x = Conv2D(filters=3, kernel_size=self.kernel_size, padding='same')(x)

    model = Model(inputs=input_, outputs=x)
$\endgroup$
3
$\begingroup$

I've seen this too many times - it's not a problem with your network, it's a problem with matplotlib and how it displays the image. You are probably trying to display a float with range $<0, 255>$. When matplotlib sees float type as input, it assumes a range of $<0, 1>$, and thresholds everything outside of that range, and the results you can see.

$\endgroup$
  • $\begingroup$ Before printing, I do y = np.clip(y, 0, 255) and assert y.dtype == np.uint8, 'Must be uint8', so these pixels correspond to [0, 0, 0] to [255, 255, 255] where 0/255 are sometimes interchanged to produce yellow/cian etc. $\endgroup$ – GRS Jun 6 at 13:37
  • $\begingroup$ Mind sharing the full code? $\endgroup$ – Lugi Jun 6 at 14:15
  • $\begingroup$ Unfortunately I can't as it would turn into a debugging exercise. I thought it's a common problem that has a known reason for happening. I guess the issue is somewhere in the code. I'm partially afraid that I'm stuck in local minima, but I doubt it. $\endgroup$ – GRS Jun 6 at 15:46
  • $\begingroup$ Trust me, I'll spot your mistake in under 60 second. There's no way a network-related issue results in something like this. It's something with how you process the data. $\endgroup$ – Lugi Jun 6 at 23:14
  • $\begingroup$ Here is the network -> github.com/skiler07/mst-tf/blob/master/trainer/MST.py I am implementing a paper. The preprocessing is quite complex. If you wish to reproduce, you can clone master and try running locally. $\endgroup$ – GRS Jun 6 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.