kunheek / style-aware-discriminator

CVPR 2022 - Official PyTorch implementation of "A Style-Aware Discriminator for Controllable Image Translation"
https://arxiv.org/abs/2203.15375
MIT License
112 stars 8 forks source link

Aboutstop-gradient operation #2

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi, thank you for sharing your code. Can you please tell me how to stop the gradient when training the generator in your code? Looking forward to your reply, thanks!

kunheek commented 2 years ago

Hi. Thank you for your interest in our work!

I'm not sure if you are talking about the generator or style code. To implement the stop gradient described in paper, I used torch.no_grad() or tensor.detach() Here's the actual implementations:

If you are talking about freezing other networks during the generator update, I set requires_grad_(False). You can find it here.

I hope this helps you.

ghost commented 2 years ago

Got it. I'm talking about the style code. Thanks a lot!

ghost commented 2 years ago

Sorry to bother again. This model keeps the background of images very well, and I think this may be because the style codes are updated separately. If the style code is updated jointly, which code needs to be changed in addition to the three mentioned above?

kunheek commented 2 years ago

Actually, the style code cannot be trained jointly. It's technically possible, but it will generate unrealistic samples.

ghost commented 2 years ago

Got it. Thanks for your reply!