Positional Encoding in GANs

September 13, 2022 ยท View on GitHub

Positional Encoding as Spatial Inductive Bias in GANs

Abstract

SinGAN shows impressive capability in learning internal patch distribution despite its limited effective receptive field. We are interested in knowing how such a translation-invariant convolutional generator could capture the global structure with just a spatially i.i.d. input. In this work, taking SinGAN and StyleGAN2 as examples, we show that such capability, to a large extent, is brought by the implicit positional encoding when using zero padding in the generators. Such positional encoding is indispensable for generating images with high fidelity. The same phenomenon is observed in other generative architectures such as DCGAN and PGGAN. We further show that zero padding leads to an unbalanced spatial bias with a vague relation between locations. To offer a better spatial inductive bias, we investigate alternative positional encodings and analyze their effects. Based on a more flexible positional encoding explicitly, we propose a new multi-scale training strategy and demonstrate its effectiveness in the state-of-the-art unconditional generator StyleGAN2. Besides, the explicit spatial inductive bias substantially improve SinGAN for more versatile image manipulation.

Results and models for MS-PIE

896x896 results generated from a 256 generator using MS-PIE
ModelsReference in PaperScalesFID50kP&R10kConfigDownload
stylegan2_c2_256_baselineTab.5 config-a2565.5675.92/51.24configmodel
stylegan2_c2_512_baselineTab.5 config-b5124.9175.65/54.58configmodel
ms-pie_stylegan2_c2_config-cTab.5 config-c256, 384, 5123.3573.84/55.77configmodel
ms-pie_stylegan2_c2_config-dTab.5 config-d256, 384, 5123.5073.28/56.16configmodel
ms-pie_stylegan2_c2_config-eTab.5 config-e256, 384, 5123.1574.13/56.88configmodel
ms-pie_stylegan2_c2_config-fTab.5 config-f256, 384, 5122.9373.51/57.32configmodel
ms-pie_stylegan2_c1_config-gTab.5 config-g256, 384, 5123.4073.05/56.45configmodel
ms-pie_stylegan2_c2_config-hTab.5 config-h256, 384, 5124.0172.81/54.35configmodel
ms-pie_stylegan2_c2_config-iTab.5 config-i256, 384, 5123.7673.26/54.71configmodel
ms-pie_stylegan2_c2_config-jTab.5 config-j256, 384, 5124.2373.11/54.63configmodel
ms-pie_stylegan2_c2_config-kTab.5 config-k256, 384, 5124.1773.05/51.07configmodel
ms-pie_stylegan2_c2_config-fhigher-resolution256, 512, 8964.1072.21/50.29configmodel
ms-pie_stylegan2_c1_config-fhigher-resolution256, 512, 10246.2471.79/49.92configmodel

Note that we report the FID and P&R metric (FFHQ dataset) in the largest scale.

Results and Models for SinGAN

Positional Encoding in SinGAN
ModelDataNum ScalesConfigDownload
SinGAN + no padballoons.png8configckpt | pkl
SinGAN + no pad + no bn in discballoons.png8configckpt | pkl
SinGAN + no pad + no bn in discfish.jpg10configckpt | pkl
SinGAN + CSGfish.jpg10configckpt | pkl
SinGAN + CSGbohemian.png10configckpt | pkl
SinGAN + SPE-dim4fish.jpg10configckpt | pkl
SinGAN + SPE-dim4bohemian.png10configckpt | pkl
SinGAN + SPE-dim8bohemian.png10configckpt | pkl

Citation

@article{xu2020positional,
  title={Positional Encoding as Spatial Inductive Bias in GANs},
  author={Xu, Rui and Wang, Xintao and Chen, Kai and Zhou, Bolei and Loy, Chen Change},
  journal={arXiv preprint arXiv:2012.05217},
  year={2020},
  url={https://openaccess.thecvf.com/content/CVPR2021/html/Xu_Positional_Encoding_As_Spatial_Inductive_Bias_in_GANs_CVPR_2021_paper.html},
}