Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

about SGRAN test mode #2

Open
dgerin opened this issue Feb 19, 2020 · 1 comment
Open

about SGRAN test mode #2

dgerin opened this issue Feb 19, 2020 · 1 comment

Comments

@dgerin
Copy link

dgerin commented Feb 19, 2020

Hello twhui,

I would like to perform a test phase on the SGRAN.
I downloaded the SGRAN pretrained model at your link : https://drive.google.com/file/d/1vAtPLGbdyt--SZQxUl0YKPRQgu6-kR6v/view, and set il all up on my local env.
While reading the README, i was sure that the bench support testing for SGRAN
but when I inspect the sources, my understanding is that "test mode" is only available
for SRResNet.

In model.py below, It is clear that sr_gan is only loaded for "training mode" , isn't it :

def create_model(opt): 
    if opt.model == 'sr_resnet': 
        from .sr_resnet_model import SRResNetModel 
        model = SRResNetModel() 
    elif opt.model == 'sr_resnet_test': 
        from .sr_resnet_test_model import SRResNetTestModel 
        model = SRResNetTestModel() 
 
    elif opt.model == 'sr_gan': 
        from .sr_gan_model import SRGANModel 
        model = SRGANModel() 
 
    else: 
        raise NotImplementedError('Model [%s] not recognized.' % opt.model) 
    model.initialize(opt) 
    print('Model [%s] is created.' % model.name()) 
    return model 

In addition, when I execute the cmd below, I got a crash that tells me again that test mode is not supported got SRGAN :

CUDA_VISIBLE_DEVICES=0 python ./test.py --option ./options/test/SRGAN_x4.json

Traceback (most recent call last):
  File "./test.py", line 45, in <module>
    model = create_model(opt)
  File "/home/dgerin/SRGAN-PyTorch/models/models.py", line 17, in create_model
    model.initialize(opt)
  File "/home/dgerin/SRGAN-PyTorch/models/sr_gan_model.py", line 20, in initialize
    assert opt.is_train

Could you give more information about that ?

Thanks,
Dimitri

@dgerin
Copy link
Author

dgerin commented Feb 20, 2020

Hello,
Please, I now a bit more advanced in my understanding of the flow.
In fact, I previously just misunderstood that for SRGAN, the D net is only used for training.
It appears clearly, when reading the code and option file that for the SRGAN,
we have the D net and the G net, but for the G net, we (sould) use the SRResnet G net.

When we zoom into sr_gan_model.py, and in networks.py :

# Always define netG                                                                                                     
self.netG = networks.define_G(opt) # Should use model "sr_resnet"       
# Pick the corresponding model for Generator and initialize it.
def define_G(opt):
    gpu_ids = opt.gpu_ids
    opt = opt.network
    which_model = opt.which_model_G

    if which_model == 'sr_resnet':
        netG = G.SRResNetGenerator(input_ngc=opt.input_ngc, output_ngc=opt.output_ngc, ngf=opt.ngf, ngb=opt.ngb, norm_type=opt.norm_type)
    elif which_model == 'sr_gan':
        netG = G.SRGANGenerator(input_ngc=opt.input_ngc, output_ngc=opt.output_ngc, ngf=opt.ngf, ngb=opt.ngb, norm_type=opt.norm_type)

    else:
        raise NotImplementedError('Generator model [%s] is not recognized' % which_model)

    netG = nn.DataParallel(netG, device_ids=gpu_ids)
    return netG

, this is confusing, because G.SRGANGenerator is not implement in the G module
import models.modules.generator as G

What I'm finally trying to clarify is if there are differences (in topology, tensor shapes, kernel sizes, etc..) between G.SRResNetGenerator and
the not implemented G.SRGANGenerator ?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant