{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/styleswin-transformer-based-gan-for-high-1","title":"StyleSwin: Transformer-based GAN for High-resolution Image Generation","arxiv_id":"2112.10762","date":"2021-12-20","proceeding":"CVPR 2022 1","authors":["BoWen Zhang","Shuyang Gu","Bo Zhang","Jianmin Bao","Dong Chen","Fang Wen","Yong Wang","Baining Guo"],"abstract":"Despite the tantalizing success in a broad of vision tasks, transformers have not yet demonstrated on-par ability as ConvNets in high-resolution image generative modeling. In this paper, we seek to explore using pure transformers to build a generative adversarial network for high-resolution image synthesis. To this end, we believe that local attention is crucial to strike the balance between computational efficiency and modeling capacity. Hence, the proposed generator adopts Swin transformer in a style-based architecture. To achieve a larger receptive field, we propose double attention which simultaneously leverages the context of the local and the shifted windows, leading to improved generation quality. Moreover, we show that offering the knowledge of the absolute position that has been lost in window-based transformers greatly benefits the generation quality. The proposed StyleSwin is scalable to high resolutions, with both the coarse geometry and fine structures benefit from the strong expressivity of transformers. However, blocking artifacts occur during high-resolution synthesis because performing the local attention in a block-wise manner may break the spatial coherency. To solve this, we empirically investigate various solutions, among which we find that employing a wavelet discriminator to examine the spectral discrepancy effectively suppresses the artifacts. Extensive experiments show the superiority over prior transformer-based GANs, especially on high resolutions, e.g., 1024x1024. The StyleSwin, without complex training strategies, excels over StyleGAN on CelebA-HQ 1024, and achieves on-par performance on FFHQ-1024, proving the promise of using transformers for high-resolution image generation. The code and models will be available at https://github.com/microsoft/StyleSwin.","url_abs":"https://arxiv.org/abs/2112.10762v2","url_pdf":"https://arxiv.org/pdf/2112.10762v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"styleswin-transformer-based-gan-for-high-1","repo_url":"https://github.com/microsoft/StyleSwin","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"blocking","task_name":"Blocking"},{"task_slug":"computational-efficiency","task_name":"Computational Efficiency"},{"task_slug":null,"task_name":"Generative Adversarial Network"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"high","task_name":"Vocal Bursts Intensity Prediction"}],"methods":[{"method_slug":"adaptive-instance-normalization","method_name":"Adaptive Instance Normalization"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"feedforward-network","method_name":"Feedforward Network"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"r1-regularization","method_name":"R1 Regularization"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"styleswin","method_name":"StyleSwin"},{"method_slug":"swin-transformer","method_name":"Swin Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/image-generation-on-celeba-256x256","task":"Image Generation","dataset":"CelebA 256x256","model":"StyleSwin","rank_in_archive_order":11,"of":17,"metrics":{"FID":"3.25"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-celeba-hq-1024x1024","task":"Image Generation","dataset":"CelebA-HQ 1024x1024","model":"StyleSwin","rank_in_archive_order":1,"of":10,"metrics":{"FID":"4.43"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-celeba-hq-256x256","task":"Image Generation","dataset":"CelebA-HQ 256x256","model":"StyleSwin","rank_in_archive_order":2,"of":19,"metrics":{"FID":"3.25"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-ffhq","task":"Image Generation","dataset":"FFHQ","model":"StyleSwin","rank_in_archive_order":5,"of":12,"metrics":{"FID":"5.07"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-ffhq-1024-x-1024","task":"Image Generation","dataset":"FFHQ 1024 x 1024","model":"StyleSwin","rank_in_archive_order":14,"of":20,"metrics":{"FID":"5.07"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-ffhq-256-x-256","task":"Image Generation","dataset":"FFHQ 256 x 256","model":"StyleSwin","rank_in_archive_order":10,"of":51,"metrics":{"FID":"2.81"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-ffhq-256-x-256","task":"Image Generation","dataset":"FFHQ 256 x 256","model":"StyleSwin (DINOv2)","rank_in_archive_order":44,"of":51,"metrics":{"FD":"300.18","Precision":"0.79","Recall":"0.28"},"uses_additional_data":false},{"leaderboard":"/sota/image-generation-on-lsun-churches-256-x-256","task":"Image Generation","dataset":"LSUN Churches 256 x 256","model":"StyleSwin","rank_in_archive_order":6,"of":27,"metrics":{"FID":"2.95"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2112.10762","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2112.10762"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/microsoft/StyleSwin","reach":null}],"summary":{"ran_fixture":1,"ran_draft_wrong":4},"by_repo_kind":{"official":{"samples":2,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":3,"samples":[{"code_sha256_prefix":"144d10b49baeb8a6","entry":"window_partition","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_fixture","verification_level":2,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"144d10b49baeb8a6"}},{"code_sha256_prefix":"f50887cc6f5e3a39","entry":"d_logistic_loss","repo":"microsoft/StyleSwin","repo_kind":"official","path":"train_styleswin.py","file_url":"https://github.com/microsoft/StyleSwin/blob/HEAD/train_styleswin.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f50887cc6f5e3a39"}},{"code_sha256_prefix":"ea988988102f1c1d","entry":"d_r1_loss","repo":"microsoft/StyleSwin","repo_kind":"official","path":"train_styleswin.py","file_url":"https://github.com/microsoft/StyleSwin/blob/HEAD/train_styleswin.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ea988988102f1c1d"}},{"code_sha256_prefix":"dbb756dcd778f52f","entry":"data_sampler","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"dbb756dcd778f52f"}},{"code_sha256_prefix":"61bf152e6a42a184","entry":"window_reverse","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"61bf152e6a42a184"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}