{"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/dynast-dynamic-sparse-transformer-for","title":"DynaST: Dynamic Sparse Transformer for Exemplar-Guided Image Generation","arxiv_id":"2207.06124","date":"2022-07-13","proceeding":null,"authors":["Songhua Liu","Jingwen Ye","Sucheng Ren","Xinchao Wang"],"abstract":"One key challenge of exemplar-guided image generation lies in establishing fine-grained correspondences between input and guided images. Prior approaches, despite the promising results, have relied on either estimating dense attention to compute per-point matching, which is limited to only coarse scales due to the quadratic memory cost, or fixing the number of correspondences to achieve linear complexity, which lacks flexibility. In this paper, we propose a dynamic sparse attention based Transformer model, termed Dynamic Sparse Transformer (DynaST), to achieve fine-level matching with favorable efficiency. The heart of our approach is a novel dynamic-attention unit, dedicated to covering the variation on the optimal number of tokens one position should focus on. Specifically, DynaST leverages the multi-layer nature of Transformer structure, and performs the dynamic attention scheme in a cascaded manner to refine matching results and synthesize visually-pleasing outputs. In addition, we introduce a unified training objective for DynaST, making it a versatile reference-based image translation framework for both supervised and unsupervised scenarios. Extensive experiments on three applications, pose-guided person image generation, edge-based face synthesis, and undistorted image style transfer, demonstrate that DynaST achieves superior performance in local details, outperforming the state of the art while reducing the computational cost significantly. Our code is available at https://github.com/Huage001/DynaST","url_abs":"https://arxiv.org/abs/2207.06124v3","url_pdf":"https://arxiv.org/pdf/2207.06124v3.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":"dynast-dynamic-sparse-transformer-for","repo_url":"https://github.com/huage001/dynast","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"face-generation","task_name":"Face Generation"},{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"style-transfer","task_name":"Style Transfer"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"sparse-transformer","method_name":"Sparse Transformer"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2207.06124","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2207.06124"}},"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/huage001/dynast","reach":null}],"summary":{"ran":2,"ran_honours":1,"ran_fixture":2,"unverified":3},"by_repo_kind":{"official":{"samples":8,"ran":5,"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":0,"samples":[{"code_sha256_prefix":"98f313b85608aafc","entry":"SPADE","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"98f313b85608aafc"}},{"code_sha256_prefix":"f8d0c394ed57e1f0","entry":"_SynchronizedBatchNorm","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f8d0c394ed57e1f0"}},{"code_sha256_prefix":"e185a8fcdcbab43f","entry":"_unsqueeze_ft","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e185a8fcdcbab43f"}},{"code_sha256_prefix":"9fe0655522228a35","entry":"inner_scale_dynamic_sparse_attention","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"9fe0655522228a35"}},{"code_sha256_prefix":"a5fffce03d7edcd3","entry":"inter_scale_dynamic_sparse_attention","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a5fffce03d7edcd3"}},{"code_sha256_prefix":"7976cd9b3bbe5998","entry":"DynamicSparseTransformerBlock","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7976cd9b3bbe5998"}},{"code_sha256_prefix":"67f416d92289a7b5","entry":"ResidualBlock","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"67f416d92289a7b5"}},{"code_sha256_prefix":"b5692d4688d3d881","entry":"SynchronizedBatchNorm2d","repo":"huage001/dynast","repo_kind":"official","path":"models/networks/dynast_transformer.py","file_url":"https://github.com/huage001/dynast/blob/HEAD/models/networks/dynast_transformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b5692d4688d3d881"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}