LS4GAN / uvcgan2

UVCGAN v2: An Improved Cycle-Consistent GAN for Unpaired Image-to-Image Translation
https://arxiv.org/abs/2303.16280
Other
116 stars 18 forks source link

Ratio between fake and reconstructed #32

Open PoRuSung opened 1 month ago

PoRuSung commented 1 month ago

Hi, thanks for the great work ! I want to ask about if I want to change the ratio of fake and reconstructed images while training what should I do? Can you help me with that? (previously I've used your code to train a model and got low reconstruct loss but the fake loss is not as low as reconstruct loss)

usert5432 commented 1 month ago

Hi @PoRuSung,

Thank you for your interest in our work!

I want to ask about if I want to changing the ratio of fake and reconstructed images while training what should I do? Can you help me with that? (previously I've used your code to train a model and got low reconstruct loss but the fake loss is not as low as reconstruct loss)

If you simply want to change the ratio (importance) of reconstruction and translation losses, then you can adjust lambda-cycle argument of the corresponding scripts. Increasing lambda-cycle parameter will increase the importance of the reconstruction images.

However, I am not sure if that answers your question. In particular, if you are referring to a runtime ratio of fake and reco losses, or some other ratio, then a different procedure may be needed. If it is the case, could you please elaborate on the problem you encounter, and we will try to diagnose it.

PoRuSung commented 1 month ago

@usert5432 Hi, thanks for your reply! Currently my purpose is to change the ratio of reconstruction and translation losses and I've set lambda-cycle to 0.0 and start training.

if you are referring to a runtime ratio of fake and reco losses, or some other ratio, then a different procedure may be needed.

But I wonder the difference between the message you mentioned above and the reconstruction and translation losses, currently my understanding isn't sufficient to distinguish these two, would you kindly explain a little bit for me? Thank you very much.

usert5432 commented 1 month ago

Hi @PoRuSung,

Thank you for the elaboration.

Currently my purpose is to change the ratio of reconstruction and translation losses and I've set lambda-cycle to 0.0 and start training.

Unfortunately, setting lambda-cycle to 0 will likely break the training. You need to use some non-zero values.

But I wonder the difference between the message you mentioned above and the reconstruction and translation losses, currently my understanding isn't sufficient to distinguish these two, would you kindly explain a little bit for me? Thank you very much.

lambda-cycle controls the "importance" of reconstruction loss relative to the fake loss. When I say "importance", I mean it in the abstract sense. So, the higher lambda-cycle is -- the more attention CycleGAN will pay to the reconstruction loss relative to the fake loss.

However, this abstract "importance" does not directly translate to the actual numerical values of the losses. For example, if one trains CycleGAN with lambda-cycle = 1 one can observe the following losses: gen_ab = 0.26, reco_a = 0.2. At the same time, increasing lambda-cycle to 10 will make the reconstruction loss more "important", but one may still observe the same numerical values, e.g. gen_ab = 0.26, reco_a = 0.2.

Now, if you care about "importance" of fake and reco losses, then lambda-cycle is a parameter to adjust. If you care about their numerical values, then I do not not have any good suggestions on how to adjust their numerical ratio.

PoRuSung commented 1 month ago

Hi @usert5432 ,

Thank you for your detail explanation, I'll try using lambda-cycle =1.0 , thanks again!

PoRuSung commented 1 month ago

Hi @usert5432 ,

I would like to ask another question about training image size, I set the training image size to 960*592 (which is dividable by 16) image image

but encountered error msg like image could you please help me figure this out? Thank you!

usert5432 commented 1 month ago

Hi @PoRuSung,

could you please help me figure this out? Thank you!

Sure, I suspect this issue may be happening because you perform a parameter transfer from a model that was pre-trained on images of size (256, 256)?

Could you please double check that and/or share transfer configuration?

PoRuSung commented 1 month ago

d2b_lambda_cyc_zero_translation.zip

Hi @usert5432 , Thank you for your reply, the attachment is my translation python file, the transfer configuration is using the afhq/pretrain image

usert5432 commented 1 month ago

Hi @PoRuSung,

Thank you for sharing the config file! Indeed, it looks like the training attempts to use pre-trained encoders. However, "afhq/pretrain" was pretrained on images of size (256, 256) and thus cannot be simply transferred to images of size (592, 960).

I think, this error can be fixed by disabling the pre-training (e.g. passing --no-pretrain option to the training script)

PoRuSung commented 1 month ago

Hi @usert5432 ,

Thanks for your reply! I'm just wondering training without using pre-trained model would affect the training performance.

usert5432 commented 4 weeks ago

Thanks for your reply! I'm just wondering training without using pre-trained model would affect the training performance.

Yes, unfortunately, removing the pre-training will likely worsen the performance. You may want to run a custom pre-training on large images.