tg-bomze / Face-Depixelizer

Face Depixelizer based on "PULSE: Self-Supervised Photo Upsampling via Latent Space Exploration of Generative Models" repository.
2.01k stars 250 forks source link

RuntimeError when uploading image #3

Closed yopox closed 4 years ago

yopox commented 4 years ago

When I upload this image (32x32 .png) using english or russian colab, I get the following error:

mario.png(image/png) - 2858 bytes, last modified: n/a - 100% done

Saving mario.png to mario.png
User uploaded file "mario.png" with length 2858 bytes

---------------------------------------------------------------------------

RuntimeError                              Traceback (most recent call last)
<ipython-input-1-50b27c8aa454> in <module>()
     64   imagesHR = []
     65   imagesHR.append(face)
---> 66   face = toPIL(D(toTensor(face).unsqueeze(0).cuda()).cpu().detach().clamp(0,1)[0])
     67   images.append(face)
     68 

1 frames

/content/pulse/bicubic.py in forward(self, x, nhwc, clip_round, byte_output)
     59         # downscaling performed by 1-d convolution
     60         x = F.pad(x, (0, 0, pad_top, pad_bottom), self.padding)
---> 61         x = F.conv2d(input=x, weight=filters1, stride=(stride, 1), groups=3)
     62         if clip_round:
     63             x = torch.clamp(torch.round(x), 0.0, 255.)

RuntimeError: Given groups=3, weight of size [3, 1, 4, 1], expected input[1, 4, 1027, 1024] to have 3 channels, but got 4 channels instead
Acurisu commented 4 years ago

If I'm not mistaken, does it expect three channels (RGB) while your PNG contains an additional (probably alpha) channel thus leading to four channels (RGBA) which it cannot handle.

Convert your image to jpg or remove the additional channel from your png for it to work.

tg-bomze commented 4 years ago

Fixed it)

Here's what was missing: face = face.convert('RGB')