{"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/swin-unet-unet-like-pure-transformer-for","title":"Swin-Unet: Unet-like Pure Transformer for Medical Image Segmentation","arxiv_id":"2105.05537","date":"2021-05-12","proceeding":null,"authors":["Hu Cao","Yueyue Wang","Joy Chen","Dongsheng Jiang","Xiaopeng Zhang","Qi Tian","Manning Wang"],"abstract":"In the past few years, convolutional neural networks (CNNs) have achieved milestones in medical image analysis. Especially, the deep neural networks based on U-shaped architecture and skip-connections have been widely applied in a variety of medical image tasks. However, although CNN has achieved excellent performance, it cannot learn global and long-range semantic information interaction well due to the locality of the convolution operation. In this paper, we propose Swin-Unet, which is an Unet-like pure Transformer for medical image segmentation. The tokenized image patches are fed into the Transformer-based U-shaped Encoder-Decoder architecture with skip-connections for local-global semantic feature learning. Specifically, we use hierarchical Swin Transformer with shifted windows as the encoder to extract context features. And a symmetric Swin Transformer-based decoder with patch expanding layer is designed to perform the up-sampling operation to restore the spatial resolution of the feature maps. Under the direct down-sampling and up-sampling of the inputs and outputs by 4x, experiments on multi-organ and cardiac segmentation tasks demonstrate that the pure Transformer-based U-shaped Encoder-Decoder network outperforms those methods with full-convolution or the combination of transformer and convolution. The codes and trained models will be publicly available at https://github.com/HuCaoFighting/Swin-Unet.","url_abs":"https://arxiv.org/abs/2105.05537v1","url_pdf":"https://arxiv.org/pdf/2105.05537v1.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":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/HuCaoFighting/Swin-Unet","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/Arnukk/CASPIAN","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/WonJunPark/swinUNet_custom_training","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/simonustc/mcpa-for-2d-medical-image-segmentation","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/yingkaisha/keras-unet-collection","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"tf","reach":null},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/L-A-Sandhu/Swin-Unet-","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"tf","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"swin-unet-unet-like-pure-transformer-for","repo_url":"https://github.com/MindSpore-scientific-2/code-4/tree/main/D-Unet_Mindspore","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[{"task_slug":"cardiac-segmentation","task_name":"Cardiac Segmentation"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"image-segmentation","task_name":"Image Segmentation"},{"task_slug":"medical-image-analysis","task_name":"Medical Image Analysis"},{"task_slug":"medical-image-segmentation","task_name":"Medical Image Segmentation"},{"task_slug":"semantic-segmentation","task_name":"Semantic Segmentation"}],"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":"bpe","method_name":"BPE"},{"method_slug":"convolution","method_name":"Convolution"},{"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":"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":"stochastic-depth","method_name":"Stochastic Depth"},{"method_slug":"swin-transformer","method_name":"Swin Transformer"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/medical-image-segmentation-on-acdc","task":"Medical Image Segmentation","dataset":"ACDC","model":"Swin UNet","rank_in_archive_order":5,"of":6,"metrics":{"Dice Score":"0.9"},"uses_additional_data":false},{"leaderboard":"/sota/medical-image-segmentation-on-automatic","task":"Medical Image Segmentation","dataset":"Automatic Cardiac Diagnosis Challenge (ACDC)","model":"SwinUnet","rank_in_archive_order":16,"of":20,"metrics":{"Avg DSC":"90.00"},"uses_additional_data":false},{"leaderboard":"/sota/medical-image-segmentation-on-synapse-multi","task":"Medical Image Segmentation","dataset":"Synapse multi-organ CT","model":"SwinUnet","rank_in_archive_order":21,"of":23,"metrics":{"Avg DSC":"79.13","Avg HD":"21.55"},"uses_additional_data":true}],"syntology":{"syntology_url":"https://syntology.ai/paper/2105.05537","atlas_url":"https://app.syntology.ai/?focus=2105.05537","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2105.05537"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/HuCaoFighting/Swin-Unet","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yingkaisha/keras-unet-collection","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-4/tree/main/D-Unet_Mindspore","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/WonJunPark/swinUNet_custom_training","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Arnukk/CASPIAN","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/L-A-Sandhu/Swin-Unet-","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/simonustc/mcpa-for-2d-medical-image-segmentation","reach":{"status":"ok"}}],"summary":{"ran":14,"ran_fixture":2,"ran_draft_wrong":1,"unverified":1},"by_repo_kind":{"listed":{"samples":18,"ran":17,"repositories":2}},"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":"dda41d1bd5f7d32e","entry":"bce_loss_fn","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/AUC_LOSS.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/AUC_LOSS.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":"dda41d1bd5f7d32e"}},{"code_sha256_prefix":"f4820de6705b381d","entry":"clear_ds","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/utils.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":"f4820de6705b381d"}},{"code_sha256_prefix":"d5165a7134b3051a","entry":"compute_binary_metrics","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/metrics.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/metrics.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":"d5165a7134b3051a"}},{"code_sha256_prefix":"14ef6380261ac759","entry":"compute_multiclass_metrics","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/metrics.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/metrics.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":"14ef6380261ac759"}},{"code_sha256_prefix":"9c8302514c4e7b35","entry":"dice_loss_fn","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/AUC_LOSS.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/AUC_LOSS.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":"9c8302514c4e7b35"}},{"code_sha256_prefix":"4bbaba82e75c9aff","entry":"drop_path_","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/util_layers.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/util_layers.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4bbaba82e75c9aff"}},{"code_sha256_prefix":"db4d0a3eecb8e0db","entry":"dummy_loader","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/keras_swin_unet/utils.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/keras_swin_unet/utils.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":"db4d0a3eecb8e0db"}},{"code_sha256_prefix":"4a0971f8b14ed3d9","entry":"find_scenario","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/utils.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":"4a0971f8b14ed3d9"}},{"code_sha256_prefix":"dc39ed696312e230","entry":"focal_loss","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/AUC_LOSS.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/AUC_LOSS.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":"dc39ed696312e230"}},{"code_sha256_prefix":"49481c5cc405f648","entry":"image_to_array","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/utils.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":"49481c5cc405f648"}},{"code_sha256_prefix":"8e18cbe83a5ae888","entry":"image_to_array","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/keras_swin_unet/utils.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/keras_swin_unet/utils.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":"8e18cbe83a5ae888"}},{"code_sha256_prefix":"17e354bf251f8085","entry":"rmv_aug","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/utils.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":"17e354bf251f8085"}},{"code_sha256_prefix":"8802de1b1b8688a8","entry":"shuffle_ind","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8802de1b1b8688a8"}},{"code_sha256_prefix":"000032b4e43a1534","entry":"shuffle_ind","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/keras_swin_unet/utils.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/keras_swin_unet/utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"000032b4e43a1534"}},{"code_sha256_prefix":"17f6210c3a9f9f5b","entry":"split_dataset","repo":"L-A-Sandhu/Swin-Unet-","repo_kind":"listed","path":"src/swin_transformer/split_data.py","file_url":"https://github.com/L-A-Sandhu/Swin-Unet-/blob/HEAD/src/swin_transformer/split_data.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":"17f6210c3a9f9f5b"}},{"code_sha256_prefix":"dd1296fb557f6f49","entry":"window_partition","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/swin_layers.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/swin_layers.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dd1296fb557f6f49"}},{"code_sha256_prefix":"24a9365e0448ac64","entry":"window_reverse","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/swin_layers.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/swin_layers.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"24a9365e0448ac64"}},{"code_sha256_prefix":"f4c0270069e690f7","entry":"dummy_loader","repo":"Arnukk/CASPIAN","repo_kind":"listed","path":"models/keras_vision_transformer/utils.py","file_url":"https://github.com/Arnukk/CASPIAN/blob/HEAD/models/keras_vision_transformer/utils.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":"f4c0270069e690f7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}