Git Product home page Git Product logo

Comments (6)

sefibk avatar sefibk commented on August 11, 2024

I don't understand why you think the code is wrong.
The downscaling is done identically to all 3 channels.
Anyway, you are welcome to test this and open a PR if performance is maintained on DIV2K-RK

from kernelgan.

HLzju avatar HLzju commented on August 11, 2024

I got a grayscale image(even though it has 3 channels) when I debug the ouput tensor of 'resize_tensor_w_kernel' in python file 'util.py', I've read the paper and I think it should be a colored image.

I tried to change the 'resize_tensor_w_kernel' as below:

def resize_tensor_w_kernel(im_t, k, sf=None):
"""Convolves a tensor with a given bicubic kernel according to scale factor"""
# Expand dimensions to fit convolution: [out_channels, 1, k_height, k_width]
k = k.expand(im_t.shape[1], 1, k.shape[0], k.shape[1])
# Calculate padding
padding = (k.shape[-1] - 1) // 2
return F.conv2d(im_t, k, stride=round(1 / sf), padding=padding,groups=im_t.shape[1])#

I got a colored image.

maybe, there's something I missed about the paper,I would appreciate it if you help me with my doubts.

from kernelgan.

sefibk avatar sefibk commented on August 11, 2024

You might be correct about the gray scale - AFAIK it is not supposed to be gray.
I will try to look at it but it won't be in the near future - I am very busy on other issues

from kernelgan.

fedral avatar fedral commented on August 11, 2024

I got a grayscale image(even though it has 3 channels) when I debug the ouput tensor of 'resize_tensor_w_kernel' in python file 'util.py', I've read the paper and I think it should be a colored image.

I tried to change the 'resize_tensor_w_kernel' as below:

def resize_tensor_w_kernel(im_t, k, sf=None):
"""Convolves a tensor with a given bicubic kernel according to scale factor"""

Expand dimensions to fit convolution: [out_channels, 1, k_height, k_width]

k = k.expand(im_t.shape[1], 1, k.shape[0], k.shape[1])

Calculate padding

padding = (k.shape[-1] - 1) // 2
return F.conv2d(im_t, k, stride=round(1 / sf), padding=padding,groups=im_t.shape[1])#

I got a colored image.

maybe, there's something I missed about the paper,I would appreciate it if you help me with my doubts.

I have came across the same bug here, and I solved it in the same way. This bug has already been pointed out in a closed iussue.
if groupwise convolution is not used, it will generate black image, normal blured image with "groupwise" parameter.

By the way, in recent CVPR 2020 super resolution competition, "Real-World Super-Resolution via Kernel Estimation and Noise Injection" used your work kernelGAN to gain the first place in real-world SR. This might be the reason why more and more people are checking and trying to reproduce your results of KernelGAN.

from kernelgan.

fedral avatar fedral commented on August 11, 2024

I got a grayscale image(even though it has 3 channels) when I debug the ouput tensor of 'resize_tensor_w_kernel' in python file 'util.py', I've read the paper and I think it should be a colored image.

I tried to change the 'resize_tensor_w_kernel' as below:

def resize_tensor_w_kernel(im_t, k, sf=None):
"""Convolves a tensor with a given bicubic kernel according to scale factor"""

Expand dimensions to fit convolution: [out_channels, 1, k_height, k_width]

k = k.expand(im_t.shape[1], 1, k.shape[0], k.shape[1])

Calculate padding

padding = (k.shape[-1] - 1) // 2
return F.conv2d(im_t, k, stride=round(1 / sf), padding=padding,groups=im_t.shape[1])#

I got a colored image.

maybe, there's something I missed about the paper,I would appreciate it if you help me with my doubts.

here is the link #28

from kernelgan.

sefibk avatar sefibk commented on August 11, 2024

Could you please open a PR and I will go over it?

from kernelgan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.