yuval-alaluf / stylegan3-editing

Official Implementation of "Third Time's the Charm? Image and Video Editing with StyleGAN3" (AIM ECCVW 2022) https://arxiv.org/abs/2201.13433
https://yuval-alaluf.github.io/stylegan3-editing/
MIT License
660 stars 72 forks source link

Runing sg3-editing in a Low Memory GPU set (12gb) #15

Closed hqnicolas closed 2 years ago

hqnicolas commented 2 years ago

Based on issue #14 Yuval-Alaluf Restyle Resized to 256x256 Args. Latent 512 I can already guarantee based on the styleGAN2 files that it is not possible to use 8gb GPUs with stylegan3 To help spread this knowledge, I think we could create a Base-Files project with decreased use of vram (12gb). let's start from the ground up with files trained with 256x256 images with args.latent = 512

yuval-alaluf commented 2 years ago

There is no need to change the networks_stylegan3.py file since this is the official code from NVIDIA. If you want to load a 256x256 generator, try the following:

checkpoint_path = "/path/to/your/sg3.pt"
decoder = Generator(
                z_dim=512,
                c_dim=0,
                w_dim=512,
                img_resolution=res,
                img_channels=3,
                channel_base=32768,
                channel_max=512,
                magnitude_ema_beta=0.9988915792636801,
                mapping_kwargs={'num_layers': 2}.cuda()
decoder.load_state_dict(torch.load(checkpoint_path), strict=True)

You may have noticed that this is how we load the landscapes generator which is of resolution 256x256

yuval-alaluf commented 2 years ago

I am not going to make a fork for this because the current code already supports loading generators of various resolutions.