Commit 57e0e891 authored by limm's avatar limm
Browse files

add part mmgeneration code

parent 04e07f48
_base_ = [
'../_base_/models/stylegan/styleganv1_base.py',
'../_base_/datasets/grow_scale_imgs_ffhq_styleganv1.py',
'../_base_/default_runtime.py',
]
model = dict(generator=dict(out_size=1024), discriminator=dict(in_size=1024))
train_cfg = dict(
nkimgs_per_scale={
'8': 1200,
'16': 1200,
'32': 1200,
'64': 1200,
'128': 1200,
'256': 1200,
'512': 1200,
'1024': 166000
})
checkpoint_config = dict(interval=5000, by_epoch=False, max_keep_ckpts=20)
lr_config = None
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(type='PGGANFetchDataHook', interval=1),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
total_iters = 670000
metrics = dict(
fid50k=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-1024-50k-rgb.pkl',
bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
_base_ = [
'../_base_/models/stylegan/styleganv1_base.py',
'../_base_/datasets/grow_scale_imgs_ffhq_styleganv1.py',
'../_base_/default_runtime.py',
]
model = dict(generator=dict(out_size=256), discriminator=dict(in_size=256))
train_cfg = dict(nkimgs_per_scale={
'8': 1200,
'16': 1200,
'32': 1200,
'64': 1200,
'128': 1200,
'256': 190000
})
checkpoint_config = dict(interval=5000, by_epoch=False, max_keep_ckpts=20)
lr_config = None
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(type='PGGANFetchDataHook', interval=1),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
total_iters = 670000
metrics = dict(
fid50k=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-256-50k-rgb.pkl',
bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
# StyleGANv2
> [Analyzing and Improving the Image Quality of Stylegan](https://openaccess.thecvf.com/content_CVPR_2020/html/Karras_Analyzing_and_Improving_the_Image_Quality_of_StyleGAN_CVPR_2020_paper.html)
<!-- [ALGORITHM] -->
## Abstract
<!-- [ABSTRACT] -->
The style-based GAN architecture (StyleGAN) yields state-of-the-art results in data-driven unconditional generative image modeling. We expose and analyze several of its characteristic artifacts, and propose changes in both model architecture and training methods to address them. In particular, we redesign the generator normalization, revisit progressive growing, and regularize the generator to encourage good conditioning in the mapping from latent codes to images. In addition to improving image quality, this path length regularizer yields the additional benefit that the generator becomes significantly easier to invert. This makes it possible to reliably attribute a generated image to a particular network. We furthermore visualize how well the generator utilizes its output resolution, and identify a capacity problem, motivating us to train larger models for additional quality improvements. Overall, our improved model redefines the state of the art in unconditional image modeling, both in terms of existing distribution quality metrics as well as perceived image quality.
<!-- [IMAGE] -->
<div align=center>
<img src="https://user-images.githubusercontent.com/28132635/143055738-58b15493-ab87-436d-94fd-c4c19e4a0225.JPG"/>
</div>
## Results and Models
<div align="center">
<b> Results (compressed) from StyleGAN2 config-f trained by MMGeneration</b>
<br/>
<img src="https://user-images.githubusercontent.com/12726765/113825919-25433100-97b4-11eb-84f7-5c66b3cfbc68.png" width="800"/>
</div>
| Model | Comment | FID50k | P&R50k | Config | Download |
| :---------------------------------: | :-------------: | :----: | :-----------: | :--------------------------------------------------------------: | :-----------------------------------------------------------------: |
| stylegan2_config-f_ffhq_1024 | official weight | 2.8134 | 62.856/49.400 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth) |
| stylegan2_config-f_lsun-car_384x512 | official weight | 5.4316 | 65.986/48.190 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-car_384x512_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-car-config-f-official_20210327_172340-8cfe053c.pth) |
| stylegan2_config-f_horse_256 | official weight | - | - | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-horse_256_b4x8_800k.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-horse-config-f-official_20210327_173203-ef3e69ca.pth) |
| stylegan2_config-f_church_256 | official weight | - | - | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-church_256_b4x8_800k.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-church-config-f-official_20210327_172657-1d42b7d1.pth) |
| stylegan2_config-f_cat_256 | official weight | - | - | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-cat_256_b4x8_800k.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-cat-config-f-official_20210327_172444-15bc485b.pth) |
| stylegan2_config-f_ffhq_256 | our training | 3.992 | 69.012/40.417 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_256_b4x8_800k.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_256_b4x8_20210407_160709-7890ae1f.pth) |
| stylegan2_config-f_ffhq_1024 | our training | 2.8185 | 68.236/49.583 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth) |
| stylegan2_config-f_lsun-car_384x512 | our training | 2.4116 | 66.760/50.576 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-car_384x512_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_lsun-car_384x512_b4x8_1800k_20210424_160929-fc9072ca.pth) |
## FP16 Support and Experiments
Currently, we have supported FP16 training for StyleGAN2, and here are the results for the mixed-precision training. (Experiments for FFHQ1024 will come soon.)
<div align="center">
<b> Evaluation FID for FP32 and FP16 training </b>
<br/>
<img src="https://user-images.githubusercontent.com/12726765/117523645-18e90880-afec-11eb-9327-da14362b8bfd.png" width="600"/>
</div>
As shown in the figure, we provide **3** ways to do mixed-precision training for `StyleGAN2`:
- [stylegan2_c2_fp16_PL-no-scaler](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k.py): In this setting, we try our best to follow the official FP16 implementation in [StyleGAN2-ADA](https://github.com/NVlabs/stylegan2-ada). Similar to the official version, we only adopt FP16 training for the higher-resolution feature maps (the last 4 stages in G and the first 4 stages). Note that we do not adopt the `clamp` way to avoid gradient overflow used in the official implementation. We use the `autocast` function from `torch.cuda.amp` package.
- [stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k.py): In this config, we try to adopt mixed-precision training for the whole generator, but in partial discriminator (the first 4 higher-resolution stages). Note that we do not apply the loss scaler in the path length loss and gradient penalty loss. Because we always meet divergence after adopting the loss scaler to scale the gradient in these two losses.
- [stylegan2_c2_apex_fp16_PL-R1-no-scaler](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k.py): In this setting, we adopt the [APEX](https://github.com/NVIDIA/apex) toolkit to implement mixed-precision training with multiple loss/gradient scalers. In APEX, you can assign different loss scalers for the generator and the discriminator respectively. Note that we still ignore the gradient scaler in the path length loss and gradient penalty loss.
| Model | Comment | Dataset | FID50k | Config | Download |
| :----------------------------------------------: | :-------------------------------------: | :-----: | :----: | :-----------------------------------------------: | :-------------------------------------------------: |
| stylegan2_config-f_ffhq_256 | baseline | FFHQ256 | 3.992 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_256_b4x8_800k.py) | [ckpt](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_256_b4x8_20210407_160709-7890ae1f.pth) |
| stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k | partial layers in fp16 | FFHQ256 | 4.331 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k.py) | [ckpt](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k_20210508_114854-dacbe4c9.pth) |
| stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k | the whole G in fp16 | FFHQ256 | 4.362 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k.py) | [ckpt](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k_20210508_114930-ef8270d4.pth) |
| stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k | the whole G&D in fp16 + two loss scaler | FFHQ256 | 4.614 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k.py) | [ckpt](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k_20210508_114701-c2bb8afd.pth) |
In addition, we also provide `QuickTestImageDataset` to users for quickly checking whether the code can be run correctly. It's more important for FP16 experiments, because some cuda operations may no support mixed precision training. Esepcially for `APEX`, you can use [this config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_apex_fp16_quicktest_ffhq_256_b4x8_800k.py) in your local machine by running:
```bash
bash tools/dist_train.sh \
configs/styleganv2/stylegan2_c2_apex_fp16_quicktest_ffhq_256_b4x8_800k.py 1 \
--work-dir ./work_dirs/quick-test
```
With a similar way, users can switch to [config for partial-GD](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16_quicktest_ffhq_256_b4x8_800k.py) and [config for globalG-partialD](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k.py) to test the other two mixed precision training configuration.
*Note that to use the [APEX](https://github.com/NVIDIA/apex) toolkit, you have to installed it following the official guidance. (APEX is not included in our requirements.) If you are using GPUs without tensor core, you would better to switch to the newer PyTorch version (>= 1.7,0). Otherwise, the APEX installation or running may meet several bugs.*
## About Different Implementations of FID Metric
| Model | Comment | FID50k | FID Version | Config | Download |
| :--------------------------: | :-------------: | :----: | :-------------: | :-----------------------------------------------------------------: | :-------------------------------------------------------------------: |
| stylegan2_config-f_ffhq_1024 | official weight | 2.8732 | Tero's StyleGAN | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth) \| [FID-Reals](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/ffhq-1024-50k-stylegan.pkl) |
| stylegan2_config-f_ffhq_1024 | our training | 2.9413 | Tero's StyleGAN | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth) \| [FID-Reals](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/ffhq-1024-50k-stylegan.pkl) |
| stylegan2_config-f_ffhq_1024 | official weight | 2.8134 | Our PyTorch | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth) \| [FID-Reals](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/ffhq-1024-50k-rgb.pkl) |
| stylegan2_config-f_ffhq_1024 | our training | 2.8185 | Our PyTorch | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py) | [model](https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth) \| [FID-Reals](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/ffhq-1024-50k-rgb.pkl) |
In this table, we observe that the FID with Tero's inception network is similar to that with PyTorch Inception (in MMGeneration). Thus, we use the FID with PyTorch's Inception net (but the weight is not the official model zoo) by default. Because it can be run on different PyTorch versions. If you use [Tero's Inception net](https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/metrics/inception-2015-12-05.pt), your PyTorch must meet `>=1.6.0`.
More precalculated inception pickle files are listed here:
- FFHQ 256x256 real inceptions, PyTorch InceptionV3. [download](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/ffhq-256-50k-rgb.pkl)
- LSUN-Car 384x512 real inceptions, PyTorch InceptionV3. [download](https://download.openmmlab.com/mmgen/evaluation/fid_inception_pkl/lsun-car-512_50k_rgb.pkl)
## About Different Implementation and Setting of PR Metric
| Model | P&R Details | Precision | Recall |
| :--------------------------------------------: | :------------------------------: | :-------: | :----: |
| stylegan2_config-f_ffhq_1024 (official weight) | use Tero's VGG16, P&R50k_full | 67.876 | 49.299 |
| stylegan2_config-f_ffhq_1024 (official weight) | use Tero's VGG16, P&R50k | 62.856 | 49.400 |
| stylegan2_config-f_ffhq_1024 (official weight) | use PyTorch's VGG16, P&R50k_full | 67.662 | 55.460 |
As shown in this table, `P&R50k_full` is the metric used in StyleGANv1 and StyleGANv2. `full` indicates that we use the whole dataset for extracting the real distribution, e.g., 70000 images in FFHQ dataset. However, adopting the VGG16 provided from [Tero](https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/metrics/vgg16.pt) requires that your PyTorch version must fulfill `>=1.6.0`. Be careful about using the PyTorch's VGG16 to extract features, which will cause higher precision and recall.
## Citation
```latex
@inproceedings{karras2020analyzing,
title={Analyzing and improving the image quality of stylegan},
author={Karras, Tero and Laine, Samuli and Aittala, Miika and Hellsten, Janne and Lehtinen, Jaakko and Aila, Timo},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={8110--8119},
year={2020},
url={https://openaccess.thecvf.com/content_CVPR_2020/html/Karras_Analyzing_and_Improving_the_Image_Quality_of_StyleGAN_CVPR_2020_paper.html},
}
```
Collections:
- Metadata:
Architecture:
- StyleGANv2
Name: StyleGANv2
Paper:
- https://openaccess.thecvf.com/content_CVPR_2020/html/Karras_Analyzing_and_Improving_the_Image_Quality_of_StyleGAN_CVPR_2020_paper.html
README: configs/styleganv2/README.md
Models:
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
FID50k: 2.8134
P&R50k: 62.856/49.400
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-car_384x512_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: LSUN
Name: stylegan2_c2_lsun-car_384x512_b4x8
Results:
- Dataset: LSUN
Metrics:
Comment: official weight
FID50k: 5.4316
P&R50k: 65.986/48.190
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-car-config-f-official_20210327_172340-8cfe053c.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-horse_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: LSUN
Name: stylegan2_c2_lsun-horse_256_b4x8_800k
Results:
- Dataset: LSUN
Metrics:
Comment: official weight
FID50k: '-'
P&R50k: '-'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-horse-config-f-official_20210327_173203-ef3e69ca.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-church_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: LSUN
Name: stylegan2_c2_lsun-church_256_b4x8_800k
Results:
- Dataset: LSUN
Metrics:
Comment: official weight
FID50k: '-'
P&R50k: '-'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-church-config-f-official_20210327_172657-1d42b7d1.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-cat_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: LSUN
Name: stylegan2_c2_lsun-cat_256_b4x8_800k
Results:
- Dataset: LSUN
Metrics:
Comment: official weight
FID50k: '-'
P&R50k: '-'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-cat-config-f-official_20210327_172444-15bc485b.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_256_b4x8_800k
Results:
- Dataset: FFHQ
Metrics:
Comment: our training
FID50k: 3.992
P&R50k: 69.012/40.417
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_256_b4x8_20210407_160709-7890ae1f.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: our training
FID50k: 2.8185
P&R50k: 68.236/49.583
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_lsun-car_384x512_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: LSUN
Name: stylegan2_c2_lsun-car_384x512_b4x8
Results:
- Dataset: LSUN
Metrics:
Comment: our training
FID50k: 2.4116
P&R50k: 66.760/50.576
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_lsun-car_384x512_b4x8_1800k_20210424_160929-fc9072ca.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_256_b4x8_800k
Results:
- Dataset: FFHQ
Metrics:
Comment: baseline
FID50k: 3.992
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_256_b4x8_20210407_160709-7890ae1f.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k
Results:
- Dataset: FFHQ
Metrics:
Comment: partial layers in fp16
FID50k: 4.331
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_fp16_partial-GD_PL-no-scaler_ffhq_256_b4x8_800k_20210508_114854-dacbe4c9.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k
Results:
- Dataset: FFHQ
Metrics:
Comment: the whole G in fp16
FID50k: 4.362
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_fp16-globalG-partialD_PL-R1-no-scaler_ffhq_256_b4x8_800k_20210508_114930-ef8270d4.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k
Results:
- Dataset: FFHQ
Metrics:
Comment: the whole G&D in fp16 + two loss scaler
FID50k: 4.614
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_apex_fp16_PL-R1-no-scaler_ffhq_256_b4x8_800k_20210508_114701-c2bb8afd.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
FID Version: Tero's StyleGAN
FID50k: 2.8732
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: our training
FID Version: Tero's StyleGAN
FID50k: 2.9413
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
FID Version: Our PyTorch
FID50k: 2.8134
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv2/stylegan2_c2_ffhq_1024_b4x8.py
In Collection: StyleGANv2
Metadata:
Training Data: FFHQ
Name: stylegan2_c2_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
Comment: our training
FID Version: Our PyTorch
FID50k: 2.8185
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan2/stylegan2_c2_ffhq_1024_b4x8_20210407_150045-618c9024.pth
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
disc_auxiliary_loss=dict(use_apex_amp=False),
gen_auxiliary_loss=dict(use_apex_amp=False),
)
total_iters = 800002
apex_amp = dict(mode='gan', init_args=dict(opt_level='O1', num_losses=2))
resume_from = None
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
generator=dict(out_size=256),
discriminator=dict(in_size=256, convert_input_fp32=False),
# disc_auxiliary_loss=dict(use_apex_amp=True),
# gen_auxiliary_loss=dict(use_apex_amp=True),
)
dataset_type = 'QuickTestImageDataset'
data = dict(
samples_per_gpu=2,
train=dict(type=dataset_type, size=(256, 256)),
val=dict(type=dataset_type, size=(256, 256)))
log_config = dict(interval=1)
total_iters = 800002
apex_amp = dict(
mode='gan', init_args=dict(opt_level='O1', num_losses=2, loss_scale=512.))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = [
'../_base_/datasets/ffhq_flip.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
ema_half_life = 10. # G_smoothing_kimg
model = dict(generator=dict(out_size=1024), discriminator=dict(in_size=1024))
data = dict(
samples_per_gpu=4,
train=dict(dataset=dict(imgs_root='./data/ffhq/images')),
val=dict(imgs_root='./data/ffhq/images'))
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
metrics = dict(
fid50k=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-1024-50k-rgb.pkl',
bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-1024-50k-rgb.pkl',
bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=30)
lr_config = None
total_iters = 800002
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = [
'../_base_/datasets/ffhq_flip.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
model = dict(generator=dict(out_size=256), discriminator=dict(in_size=256))
data = dict(
samples_per_gpu=4,
train=dict(dataset=dict(imgs_root='./data/ffhq/ffhq_imgs/ffhq_256')),
val=dict(imgs_root='./data/ffhq/ffhq_imgs/ffhq_256'))
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=30)
lr_config = None
log_config = dict(
interval=100,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook'),
])
total_iters = 800002
metrics = dict(
fid50k=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-256-50k-rgb.pkl',
bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/ffhq-256-50k-rgb.pkl',
bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
generator=dict(out_size=256, fp16_enabled=True),
discriminator=dict(in_size=256, fp16_enabled=False, num_fp16_scales=4),
)
total_iters = 800000
# use ddp wrapper for faster training
use_ddp_wrapper = True
find_unused_parameters = False
runner = dict(
fp16_loss_scaler=dict(init_scale=512),
is_dynamic_ddp= # noqa
False, # Note that this flag should be False to use DDP wrapper.
)
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
generator=dict(out_size=256, fp16_enabled=True),
discriminator=dict(in_size=256, fp16_enabled=True),
disc_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
# gen_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
)
dataset_type = 'QuickTestImageDataset'
data = dict(
samples_per_gpu=2,
train=dict(type=dataset_type, size=(256, 256)),
val=dict(type=dataset_type, size=(256, 256)))
log_config = dict(interval=1)
total_iters = 800002
runner = dict(fp16_loss_scaler=dict(init_scale=512))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
generator=dict(out_size=256, num_fp16_scales=4),
discriminator=dict(in_size=256, num_fp16_scales=4),
disc_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
# gen_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
)
total_iters = 800002
# use ddp wrapper for faster training
use_ddp_wrapper = True
find_unused_parameters = False
runner = dict(
fp16_loss_scaler=dict(init_scale=512),
is_dynamic_ddp= # noqa
False, # Note that this flag should be False to use DDP wrapper.
)
"""Config for the `config-f` setting in StyleGAN2."""
_base_ = ['./stylegan2_c2_ffhq_256_b4x8_800k.py']
model = dict(
generator=dict(out_size=256, num_fp16_scales=4),
discriminator=dict(in_size=256, num_fp16_scales=4),
disc_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
# gen_auxiliary_loss=dict(data_info=dict(loss_scaler='loss_scaler')),
)
dataset_type = 'QuickTestImageDataset'
data = dict(
samples_per_gpu=2,
train=dict(type=dataset_type, size=(256, 256)),
val=dict(type=dataset_type, size=(256, 256)))
log_config = dict(interval=1)
total_iters = 800002
runner = dict(fp16_loss_scaler=dict(init_scale=512))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
_base_ = [
'../_base_/datasets/lsun-car_pad_512.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
model = dict(generator=dict(out_size=512), discriminator=dict(in_size=512))
data = dict(
samples_per_gpu=4,
train=dict(dataset=dict(imgs_root='./data/lsun/images/car')),
val=dict(imgs_root='./data/lsun/images/car'))
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=40)
lr_config = None
total_iters = 1800002
metrics = dict(
fid50k=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
evaluation = dict(
type='GenerativeEvalHook',
interval=10000,
metrics=dict(
type='FID',
num_images=50000,
inception_pkl='work_dirs/inception_pkl/lsun-car-512-50k-rgb.pkl',
bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
"""Note that this config is just for testing."""
_base_ = [
'../_base_/datasets/lsun_stylegan.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
model = dict(generator=dict(out_size=256), discriminator=dict(in_size=256))
data = dict(
samples_per_gpu=4, train=dict(dataset=dict(imgs_root='./data/lsun-cat')))
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=30)
lr_config = None
log_config = dict(
interval=100,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook'),
])
total_iters = 800002 # need to modify
metrics = dict(
fid50k=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
"""Note that this config is just for testing."""
_base_ = [
'../_base_/datasets/lsun_stylegan.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
model = dict(generator=dict(out_size=256), discriminator=dict(in_size=256))
data = dict(
samples_per_gpu=4,
train=dict(dataset=dict(imgs_root='./data/lsun-church')))
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=30)
lr_config = None
log_config = dict(
interval=100,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook'),
])
total_iters = 800002 # need to modify
metrics = dict(
fid50k=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
"""Note that this config is just for testing."""
_base_ = [
'../_base_/datasets/lsun_stylegan.py',
'../_base_/models/stylegan/stylegan2_base.py',
'../_base_/default_runtime.py'
]
model = dict(generator=dict(out_size=256), discriminator=dict(in_size=256))
data = dict(
samples_per_gpu=4, train=dict(dataset=dict(imgs_root='./data/lsun-horse')))
ema_half_life = 10. # G_smoothing_kimg
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interval=1,
interp_cfg=dict(momentum=0.5**(32. / (ema_half_life * 1000.))),
priority='VERY_HIGH')
]
checkpoint_config = dict(interval=10000, by_epoch=False, max_keep_ckpts=30)
lr_config = None
log_config = dict(
interval=100,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook'),
])
total_iters = 800002 # need to modify
metrics = dict(
fid50k=dict(
type='FID', num_images=50000, inception_pkl=None, bgr2rgb=True),
pr50k3=dict(type='PR', num_images=50000, k=3),
ppl_wend=dict(type='PPL', space='W', sampling='end', num_images=50000))
# StyleGANv3
> [Alias-Free Generative Adversarial Networks](https://nvlabs-fi-cdn.nvidia.com/stylegan3/stylegan3-paper.pdf)
<!-- [ALGORITHM] -->
## Abstract
We observe that despite their hierarchical convolutional nature, the synthesis
process of typical generative adversarial networks depends on absolute pixel coordinates in an unhealthy manner. This manifests itself as, e.g., detail appearing to
be glued to image coordinates instead of the surfaces of depicted objects. We trace
the root cause to careless signal processing that causes aliasing in the generator
network. Interpreting all signals in the network as continuous, we derive generally
applicable, small architectural changes that guarantee that unwanted information
cannot leak into the hierarchical synthesis process. The resulting networks match
the FID of StyleGAN2 but differ dramatically in their internal representations, and
they are fully equivariant to translation and rotation even at subpixel scales. Our
results pave the way for generative models better suited for video and animation.
<!-- [IMAGE] -->
<div align=center>
<img src="https://user-images.githubusercontent.com/22982797/150353023-8f7eeaea-8783-4ed4-98d5-67a226e00cff.png"/>
</div>
## Results and Models
<div align="center">
<b> Results (compressed) from StyleGAN3 config-T converted by MMGeneration</b>
<br/>
<img src="https://user-images.githubusercontent.com/22982797/150450502-c182834f-796f-4397-bd38-df1efe4a8a47.png" width="800"/>
</div>
We perform experiments on StyleGANv3 paper settings and also experimental settings.
For user convenience, we also offer the converted version of official weights.
### Paper Settings
| Model | Dataset | Iter | FID50k | Config | Log | Download |
| :-------------: | :---------------: | :----: | :---------------: | :----------------------------------------------: | :--------------------------------------------: | :-------------------------------------------------: |
| stylegan3-t | ffhq 1024x1024 | 490000 | 3.37<sup>\*</sup> | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8.py) | [log](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8_20220322_090417.log.json) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8_best_fid_iter_490000_20220401_120733-4ff83434.pth) |
| stylegan3-t-ada | metface 1024x1024 | 130000 | 15.09 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8.py) | [log](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8_20220328_142211.log.json) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8_best_fid_iter_130000_20220401_115101-f2ef498e.pth) |
Note<sup>\*</sup>: This setting still needs a few days to run through, we put out currently the best checkpoint, and we will update the results the first time on the end of the experiment.
### Experimental Settings
| Model | Dataset | Iter | FID50k | Config | Log | Download |
| :---------: | :----------: | :----: | :----: | :-----------------------------------------------------: | :--------------------------------------------------: | :--------------------------------------------------------: |
| stylegan3-t | ffhq 256x256 | 740000 | 7.65 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8.py) | [log](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8_20220323_144815.log.json) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8_best_fid_iter_740000_20220401_122456-730e1fba.pth) |
### Converted Weights
| Model | Dataset | Comment | FID50k | EQ-T | EQ-R | Config | Download |
| :---------: | :------------: | :-------------: | :----: | :---: | :---: | :---------------------------------------------------------------------: | :-----------------------------------------------------------------------: |
| stylegan3-t | ffhqu 256x256 | official weight | 4.62 | 63.01 | 13.12 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_ffhqu_256_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ffhqu_256_b4x8_cvt_official_rgb_20220329_235046-153df4c8.pth) |
| stylegan3-t | afhqv2 512x512 | official weight | 4.04 | 60.15 | 13.51 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_afhqv2_512_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_afhqv2_512_b4x8_cvt_official_rgb_20220329_235017-ee6b037a.pth) |
| stylegan3-t | ffhq 1024x1024 | official weight | 2.79 | 61.21 | 13.82 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_ffhq_1024_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ffhq_1024_b4x8_cvt_official_rgb_20220329_235113-db6c6580.pth) |
| stylegan3-r | ffhqu 256x256 | official weight | 4.50 | 66.65 | 40.48 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_ffhqu_256_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhqu_256_b4x8_cvt_official_rgb_20220329_234909-4521d963.pth) |
| stylegan3-r | afhqv2 512x512 | official weight | 4.40 | 64.89 | 40.34 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_afhqv2_512_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_afhqv2_512_b4x8_cvt_official_rgb_20220329_234829-f2eaca72.pth) |
| stylegan3-r | ffhq 1024x1024 | official weight | 3.07 | 64.76 | 46.62 | [config](https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb.py) | [model](https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb_20220329_234933-ac0500a1.pth) |
## Interpolation
We provide a tool to generate video by walking through GAN's latent space.
Run this command to get the following video.
```bash
python apps/interpolate_sample.py configs/styleganv3/stylegan3_t_afhqv2_512_b4x8_official.py https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_afhqv2_512_b4x8_cvt_official.pkl --export-video --samples-path work_dirs/demos/ --endpoint 6 --interval 60 --space z --seed 2022 --sample-cfg truncation=0.8
```
https://user-images.githubusercontent.com/22982797/151506918-83da9ee3-0d63-4c5b-ad53-a41562b92075.mp4
## Equivarience Visualization && Evaluation
We also provide a tool to visualize the equivarience properties for StyleGAN3.
Run these commands to get the results below.
```bash
python tools/utils/equivariance_viz.py configs/styleganv3/stylegan3_r_ffhqu_256_b4x8_official.py https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhqu_256_b4x8_cvt_official.pkl --translate_max 0.5 --transform rotate --seed 5432
python tools/utils/equivariance_viz.py configs/styleganv3/stylegan3_r_ffhqu_256_b4x8_official.py https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmgen/stylegan3/stylegan3_r_ffhqu_256_b4x8_cvt_official.pkl --translate_max 0.25 --transform x_t --seed 5432
python tools/utils/equivariance_viz.py configs/styleganv3/stylegan3_r_ffhqu_256_b4x8_official.py https://openmmlab-share.oss-cn-hangzhou.aliyuncs.com/mmgen/stylegan3/stylegan3_r_ffhqu_256_b4x8_cvt_official.pkl --translate_max 0.25 --transform y_t --seed 5432
```
https://user-images.githubusercontent.com/22982797/151504902-f3cbfef5-9014-4607-bbe1-deaf48ec6d55.mp4
https://user-images.githubusercontent.com/22982797/151504973-b96e1639-861d-434b-9d7c-411ebd4a653f.mp4
https://user-images.githubusercontent.com/22982797/151505099-cde4999e-aab1-42d4-a458-3bb069db3d32.mp4
If you want to get EQ-Metric for StyleGAN3, just add following codes into config.
```python
metrics = dict(
eqv=dict(
type='Equivariance',
num_images=50000,
eq_cfg=dict(
compute_eqt_int=True, compute_eqt_frac=True, compute_eqr=True)))
```
And we highly recommend you to use [slurm_eval_multi_gpu](tools/slurm_eval_multi_gpu.sh) script to accelerate evaluation time.
## Citation
```latex
@inproceedings{Karras2021,
author = {Tero Karras and Miika Aittala and Samuli Laine and Erik H\"ark\"onen and Janne Hellsten and Jaakko Lehtinen and Timo Aila},
title = {Alias-Free Generative Adversarial Networks},
booktitle = {Proc. NeurIPS},
year = {2021}
}
```
Collections:
- Metadata:
Architecture:
- StyleGANv3
Name: StyleGANv3
Paper:
- https://nvlabs-fi-cdn.nvidia.com/stylegan3/stylegan3-paper.pdf
README: configs/styleganv3/README.md
Models:
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8
Results:
- Dataset: FFHQ
Metrics:
FID50k: 3.37<sup>\</sup>
Iter: 490000.0
Log: '[log]'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma32.8_ffhq_1024_b4x8_best_fid_iter_490000_20220401_120733-4ff83434.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8.py
In Collection: StyleGANv3
Metadata:
Training Data: Others
Name: stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8
Results:
- Dataset: Others
Metrics:
FID50k: 15.09
Iter: 130000.0
Log: '[log]'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ada_fp16_gamma6.6_metfaces_1024_b4x8_best_fid_iter_130000_20220401_115101-f2ef498e.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/styleganv3/stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8
Results:
- Dataset: FFHQ
Metrics:
FID50k: 7.65
Iter: 740000.0
Log: '[log]'
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_noaug_fp16_gamma2.0_ffhq_256_b4x8_best_fid_iter_740000_20220401_122456-730e1fba.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_ffhqu_256_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_t_ffhqu_256_b4x8_cvt_official_rgb
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
EQ-R: 13.12
EQ-T: 63.01
FID50k: 4.62
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ffhqu_256_b4x8_cvt_official_rgb_20220329_235046-153df4c8.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_afhqv2_512_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: Others
Name: stylegan3_t_afhqv2_512_b4x8_cvt_official_rgb
Results:
- Dataset: Others
Metrics:
Comment: official weight
EQ-R: 13.51
EQ-T: 60.15
FID50k: 4.04
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_afhqv2_512_b4x8_cvt_official_rgb_20220329_235017-ee6b037a.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_t_ffhq_1024_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_t_ffhq_1024_b4x8_cvt_official_rgb
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
EQ-R: 13.82
EQ-T: 61.21
FID50k: 2.79
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_t_ffhq_1024_b4x8_cvt_official_rgb_20220329_235113-db6c6580.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_ffhqu_256_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_r_ffhqu_256_b4x8_cvt_official_rgb
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
EQ-R: 40.48
EQ-T: 66.65
FID50k: 4.5
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhqu_256_b4x8_cvt_official_rgb_20220329_234909-4521d963.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_afhqv2_512_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: Others
Name: stylegan3_r_afhqv2_512_b4x8_cvt_official_rgb
Results:
- Dataset: Others
Metrics:
Comment: official weight
EQ-R: 40.34
EQ-T: 64.89
FID50k: 4.4
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_afhqv2_512_b4x8_cvt_official_rgb_20220329_234829-f2eaca72.pth
- Config: https://github.com/open-mmlab/mmgeneration/tree/master/configs/_base_/models/stylegan/stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb.py
In Collection: StyleGANv3
Metadata:
Training Data: FFHQ
Name: stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb
Results:
- Dataset: FFHQ
Metrics:
Comment: official weight
EQ-R: 46.62
EQ-T: 64.76
FID50k: 3.07
Task: Unconditional GANs
Weights: https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb_20220329_234933-ac0500a1.pth
_base_ = [
'../_base_/models/stylegan/stylegan3_base.py',
'../_base_/datasets/ffhq_flip.py', '../_base_/default_runtime.py'
]
synthesis_cfg = {
'type': 'SynthesisNetwork',
'channel_base': 65536,
'channel_max': 1024,
'magnitude_ema_beta': 0.999,
'conv_kernel': 1,
'use_radial_filters': True
}
r1_gamma = 3.3 # set by user
d_reg_interval = 16
load_from = 'https://download.openmmlab.com/mmgen/stylegan3/stylegan3_r_ffhq_1024_b4x8_cvt_official_rgb_20220329_234933-ac0500a1.pth' # noqa
# ada settings
aug_kwargs = {
'xflip': 1,
'rotate90': 1,
'xint': 1,
'scale': 1,
'rotate': 1,
'aniso': 1,
'xfrac': 1,
'brightness': 1,
'contrast': 1,
'lumaflip': 1,
'hue': 1,
'saturation': 1
}
model = dict(
type='StaticUnconditionalGAN',
generator=dict(
out_size=1024,
img_channels=3,
rgb2bgr=True,
synthesis_cfg=synthesis_cfg),
discriminator=dict(
type='ADAStyleGAN2Discriminator',
in_size=1024,
input_bgr2rgb=True,
data_aug=dict(type='ADAAug', aug_pipeline=aug_kwargs, ada_kimg=100)),
gan_loss=dict(type='GANLoss', gan_type='wgan-logistic-ns'),
disc_auxiliary_loss=dict(loss_weight=r1_gamma / 2.0 * d_reg_interval))
imgs_root = 'data/metfaces/images/'
data = dict(
samples_per_gpu=4,
train=dict(dataset=dict(imgs_root=imgs_root)),
val=dict(imgs_root=imgs_root))
ema_half_life = 10. # G_smoothing_kimg
ema_kimg = 10
ema_nimg = ema_kimg * 1000
ema_beta = 0.5**(32 / max(ema_nimg, 1e-8))
custom_hooks = [
dict(
type='VisualizeUnconditionalSamples',
output_dir='training_samples',
interval=5000),
dict(
type='ExponentialMovingAverageHook',
module_keys=('generator_ema', ),
interp_mode='lerp',
interp_cfg=dict(momentum=ema_beta),
interval=1,
start_iter=0,
priority='VERY_HIGH')
]
inception_pkl = 'work_dirs/inception_pkl/metface_1024x1024_noflip.pkl'
metrics = dict(
fid50k=dict(
type='FID',
num_images=50000,
inception_pkl=inception_pkl,
inception_args=dict(type='StyleGAN'),
bgr2rgb=True))
evaluation = dict(
type='GenerativeEvalHook',
interval=dict(milestones=[100000], interval=[10000, 5000]),
metrics=dict(
type='FID',
num_images=50000,
inception_pkl=inception_pkl,
inception_args=dict(type='StyleGAN'),
bgr2rgb=True),
sample_kwargs=dict(sample_model='ema'))
lr_config = None
total_iters = 160000
_base_ = ['./stylegan3_base.py']
synthesis_cfg = {
'type': 'SynthesisNetwork',
'channel_base': 65536,
'channel_max': 1024,
'magnitude_ema_beta': 0.999,
'conv_kernel': 1,
'use_radial_filters': True
}
model = dict(
type='StaticUnconditionalGAN',
generator=dict(
type='StyleGANv3Generator',
noise_size=512,
style_channels=512,
out_size=512,
img_channels=3,
rgb2bgr=True,
synthesis_cfg=synthesis_cfg),
discriminator=dict(type='StyleGAN2Discriminator', in_size=512))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment