autonomousvision / stylegan-xl

[SIGGRAPH'22] StyleGAN-XL: Scaling StyleGAN to Large Diverse Datasets
MIT License
964 stars 113 forks source link

How can I change the output of the network? #47

Closed Booooooooooo closed 2 years ago

Booooooooooo commented 2 years ago

Thank you for your excellent work. I am trying to get my hands on StyleganXL and I am trying to get the intermediate features of the pretrained StyleganXL. However, I am a little confused about the loading procedure and the @persistence decorator.

As I understand, the source code saved in pickle will be used when loading a persistence class. I can refer to the following code to get the pretrained intermediate feature. I should first load the pretrained StyleganXL. Then define a new network which modified the source code and outputs features.

       with open('old_pickle.pkl', 'rb') as f:
            old_net = pickle.load(f)
        new_net = MyNetwork(*old_obj.init_args, **old_obj.init_kwargs)
        misc.copy_params_and_buffers(old_net, new_net, require_all=True)

However, I noticed in networks_stylegan3.py, initializing the Generator relys on in_embeddings/tf_efficientnet_lite0.pkl. What does this pkl do? And how can I implement the above function?

xl-sr commented 2 years ago

Yes, the procedure you propose should work. The pkl you are referring to are the pretrained class embeddings by an Efficientnet.