Code Monkey home page Code Monkey logo

Comments (4)

yulunzhang avatar yulunzhang commented on July 28, 2024

You can remove the upscale module in the model, which enable the input and output to have same size.

RCAN can be used for image inpainting, but you have to investigate more details by yourself.

from rcan.

ioncaciula avatar ioncaciula commented on July 28, 2024

Thanks for the support. I am not the familiarized with the Pytorch framework. Can you post here the changes in codes for RCAN_testing and RCAN_training which enable the same size for the input and output image?

  1. The second problem it is about a possible bug in your code.
    The Y component is obtained with rgb2ycbcr function. The transform is most used in the video domain.
    The problem with rgb2ycbcr is the range of Y values: [16,235].

From Wikipedia page: https://en.wikipedia.org/wiki/YCbCr:

"JFIF usage of JPEG supports Y′CbCr where Y′, CB and CR have the full 8-bit range of [0...255].[4] Below are the conversion equations expressed to six decimal digits of precision. (For ideal equations, see ITU-T T.871.[5]) Note that for the following formulae, the range of each input (R,G,B) is also the full 8-bit range of [0...255]."

I recommend this formula for JFIF for Y component: 0.299R+0.587G+0.114*B.

What do you think?

Best regards,
Ion

from rcan.

yulunzhang avatar yulunzhang commented on July 28, 2024

Hi,
1.To enable same sizes between input and output, just remove the line ‘common.Upsampler()’ in model/rcan.py/modules_tail

2.Thanks for pointing out this issue. Here, rgb2ycbcr() is only used for PSNR calculation, which is a little different from that in Matlab. But we don’t care too much about the transformation from rgb to ycbcr. The PSNR values in the training process is a rough indicator about the network ability. The rgb2ycbcr() would not affect the network performance. Anyway, you can modify this function, if you want.

from rcan.

ioncaciula avatar ioncaciula commented on July 28, 2024

Hi,

Thanks for support. I commented the line in both sub-folders of RCAN: train and test.
define tail module
modules_tail = [
#common.Upsampler(conv, scale, n_feats, act=False),
conv(n_feats, args.n_colors, kernel_size)]

But when I run the line (with your model/RCAN_BIX2.pt ):
/usr/bin/python3.6 main.py --data_test MyImage --scale 2 --model RCAN --n_resgroups 10 --n_resblocks 20 --n_feats 64 --pre_train ../model/RCAN_BIX2.pt --test_only --save_results --chop --save 'RCAN' --testpath ../LR/LRBI --testset Kodak

I obtain:

Traceback (most recent call last):
File "main.py", line 18, in
while not t.terminate():
File "/home/ionut/RCAN-master/RCAN_TestCode/code/trainer.py", line 139, in terminate
self.test()
File "/home/ionut/RCAN-master/RCAN_TestCode/code/trainer.py", line 96, in test
sr = self.model(lr, idx_scale)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/ionut/RCAN-master/RCAN_TestCode/code/model/init.py", line 52, in forward
return self.forward_chop(x)
File "/home/ionut/RCAN-master/RCAN_TestCode/code/model/init.py", line 145, in forward_chop
= sr_list[0][:, :, 0:h_half, 0:w_half]
RuntimeError: The expanded size of the tensor (768) must match the existing size (394) at non-singleton dimension 3
kodim01

The Kodak input image has the same size has output image because it is custom scaled.
What changes are necessary to remove the error?
PS. I attached one custom scaled Kodak image which I used for testing.

Best regards,
Ion

from rcan.

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.