Skip to content

jwzxgy2007/stylegan2_tf2pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StyleGAN2_tf2pytorch

Convert checkpoint from offical tensorflow StyleGAN2 to pytorch StyleGAN2

Requirements

  • Python 3.6

  • Pytorch >= 1.4.0.

  • Tensorflow-gpu==1.14.0 (Offical StyleGAN2 recommended)

  • CUDA 10.0 needed to compile some ops from dnnlib

Usage

python tf2pytorch.py --tf_cp *tensorflow checkpoint path* 
                     --output_path *output pytorch checkpoint path*

You can download pytorch checkpoint from google drive provided by editGAN and tensorflow checkpoint (stylegan2-car-config-f.pkl) from google drive provided by StyleGAN2, and compare the weight diff (should be zero) between official tensorflow checkpoint and pytorch checkpoint.

python tf2pytorch.py --compare true

To load the converted checkpoint, you can

import pickle
with open(*checkpoint path*, 'rb') as f
    checkpoint_data = pickle.load(f)
net.load_state_dict(checkpoint_data, strict=False)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published