{"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/tfs-vit-token-level-feature-stylization-for","title":"TFS-ViT: Token-Level Feature Stylization for Domain Generalization","arxiv_id":"2303.15698","date":"2023-03-28","proceeding":null,"authors":["Mehrdad Noori","Milad Cheraghalikhani","Ali Bahri","Gustavo A. Vargas Hakim","David Osowiechi","Ismail Ben Ayed","Christian Desrosiers"],"abstract":"Standard deep learning models such as convolutional neural networks (CNNs) lack the ability of generalizing to domains which have not been seen during training. This problem is mainly due to the common but often wrong assumption of such models that the source and target data come from the same i.i.d. distribution. Recently, Vision Transformers (ViTs) have shown outstanding performance for a broad range of computer vision tasks. However, very few studies have investigated their ability to generalize to new domains. This paper presents a first Token-level Feature Stylization (TFS-ViT) approach for domain generalization, which improves the performance of ViTs to unseen data by synthesizing new domains. Our approach transforms token features by mixing the normalization statistics of images from different domains. We further improve this approach with a novel strategy for attention-aware stylization, which uses the attention maps of class (CLS) tokens to compute and mix normalization statistics of tokens corresponding to different image regions. The proposed method is flexible to the choice of backbone model and can be easily applied to any ViT-based architecture with a negligible increase in computational complexity. Comprehensive experiments show that our approach is able to achieve state-of-the-art performance on five challenging benchmarks for domain generalization, and demonstrate its ability to deal with different types of domain shifts. The implementation is available at: https://github.com/Mehrdad-Noori/TFS-ViT_Token-level_Feature_Stylization.","url_abs":"https://arxiv.org/abs/2303.15698v3","url_pdf":"https://arxiv.org/pdf/2303.15698v3.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":"tfs-vit-token-level-feature-stylization-for","repo_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"domain-generalization","task_name":"Domain Generalization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2303.15698","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2303.15698"}},"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/mehrdad-noori/tfs-vit_token-level_feature_stylization","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":2,"ran":1,"unverified":6},"by_repo_kind":{"official":{"samples":9,"ran":3,"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":"ce7990d7ad5821ff","entry":"Classifier","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/networks.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/networks.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ce7990d7ad5821ff"}},{"code_sha256_prefix":"53fac8d8d949e72b","entry":"get_test_records","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/model_selection.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/model_selection.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"53fac8d8d949e72b"}},{"code_sha256_prefix":"196cab71d7129d62","entry":"remove_batch_norm_from_resnet","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/networks.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/networks.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"196cab71d7129d62"}},{"code_sha256_prefix":"5dac11fdc41c896b","entry":"checkpoint_filter_fn","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/lib/vit.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/lib/vit.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5dac11fdc41c896b"}},{"code_sha256_prefix":"b0bc80b1655a6802","entry":"get_algorithm_class","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/algorithms.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/algorithms.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b0bc80b1655a6802"}},{"code_sha256_prefix":"d0ea85d74c20dea9","entry":"get_dataset_class","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/datasets.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d0ea85d74c20dea9"}},{"code_sha256_prefix":"cc20f931c8f71185","entry":"load_model","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/algorithms.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/algorithms.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cc20f931c8f71185"}},{"code_sha256_prefix":"73f32252eedba6a4","entry":"num_environments","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/datasets.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/datasets.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"73f32252eedba6a4"}},{"code_sha256_prefix":"1dbef2d4da4ee10f","entry":"resize_pos_embed","repo":"mehrdad-noori/tfs-vit_token-level_feature_stylization","repo_kind":"official","path":"domainbed/lib/vit.py","file_url":"https://github.com/mehrdad-noori/tfs-vit_token-level_feature_stylization/blob/HEAD/domainbed/lib/vit.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1dbef2d4da4ee10f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}