isl-org/PhotorealismEnhancement

Sigmoid missing in hr_new?

KacperKazan opened this issue · 2 comments

Hello, I've noticed that when using the hr_new network the rec_fake (output of the generator) seems to have an unbounded value range. Compared to the loaded fake and real image which have pixels values bounded between [0, 1]

if generator_type == 'hr':
generator = nw.ResidualGenerator(nw.make_ienet(self.gen_cfg))
pass
elif generator_type == 'hr_new':
generator = PassthruGenerator(nw.make_ienet2(self.gen_cfg))
pass

The 'hr' option uses the ResidualGenerator which uses a sigmoid on the output to bound the output between [0, 1]

@torch.jit.script
def make_residual(img, x):
return torch.sigmoid(-torch.log(1 / img.clamp(min=0.001, max=0.999) - 1) + x)

However the PassthruGenerator which 'hr_new' uses doesn't have any sigmoid on the output.

Is this a bug? since it seems that the output image should be bounded [0,1] just as the real image is

Hello, I am facing a similar problem. The outputs of the generator are NaN sometimes because there is no bound. It would be great if you could share how to fix this. Thanks!

We removed the sigmoid in the updated version since it seemed not to be necessary with the setup we ran. If you're playing with different datasets or are facing issues with larger values, including the sigmoid is a good idea.