{"id":15553586,"url":"https://github.com/zfturbo/segmentation_models_pytorch_3d","last_synced_at":"2025-09-12T00:07:25.191Z","repository":{"id":224016262,"uuid":"761204609","full_name":"ZFTurbo/segmentation_models_pytorch_3d","owner":"ZFTurbo","description":"Segmentation models for 3D data with different backbones. PyTorch.","archived":false,"fork":false,"pushed_at":"2024-08-01T17:43:10.000Z","size":107,"stargazers_count":68,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-20T21:57:09.204Z","etag":null,"topics":["3d","3d-models","pretrained-models","pytorch","segmentation","segmentation-models","unet-segmentation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZFTurbo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-21T12:44:02.000Z","updated_at":"2025-08-13T13:20:00.000Z","dependencies_parsed_at":"2024-03-25T11:28:24.515Z","dependency_job_id":"abf5b775-0043-4d83-9ba5-f4b50c7bcb08","html_url":"https://github.com/ZFTurbo/segmentation_models_pytorch_3d","commit_stats":null,"previous_names":["zfturbo/segmentation_models_pytorch_3d"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZFTurbo/segmentation_models_pytorch_3d","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fsegmentation_models_pytorch_3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fsegmentation_models_pytorch_3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fsegmentation_models_pytorch_3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fsegmentation_models_pytorch_3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZFTurbo","download_url":"https://codeload.github.com/ZFTurbo/segmentation_models_pytorch_3d/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fsegmentation_models_pytorch_3d/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274728651,"owners_count":25338513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-models","pretrained-models","pytorch","segmentation","segmentation-models","unet-segmentation"],"created_at":"2024-10-02T14:39:25.871Z","updated_at":"2025-09-12T00:07:25.094Z","avatar_url":"https://github.com/ZFTurbo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Segmentation Models Pytroch 3D\n\nPython library with Neural Networks for Volume (3D) Segmentation based on PyTorch.\n\nThis library is based on famous [Segmentation Models Pytorch](https://github.com/qubvel/segmentation_models.pytorch) library for images. Most of the documentation can be used directly from there. \n\n## Installation\n\n* Type 1: `pip install segmentation-models-pytorch-3d`\n* Type 2: Copy `segmentation_models_pytorch_3d` folder from this repository in your project folder.\n\n## Quick start\n\nSegmentation model is just a PyTorch nn.Module, which can be created as easy as:\n\n```python\nimport segmentation_models_pytorch_3d as smp\nimport torch\n\nmodel = smp.Unet(\n    encoder_name=\"efficientnet-b0\", # choose encoder, e.g. resnet34\n    in_channels=1,                  # model input channels (1 for gray-scale volumes, 3 for RGB, etc.)\n    classes=3,                      # model output channels (number of classes in your dataset)\n)\n\n# Shape of input (B, C, H, W, D). B - batch size, C - channels, H - height, W - width, D - depth\nres = model(torch.randn(4, 1, 64, 64, 64)) \n```\n\n## Models\n\n### Architectures\n\n - Unet [[paper](https://arxiv.org/abs/1505.04597)] [[docs](https://smp.readthedocs.io/en/latest/models.html#unet)]\n - Unet++ [[paper](https://arxiv.org/pdf/1807.10165.pdf)] [[docs](https://smp.readthedocs.io/en/latest/models.html#id2)]\n - MAnet [[paper](https://ieeexplore.ieee.org/abstract/document/9201310)] [[docs](https://smp.readthedocs.io/en/latest/models.html#manet)]\n - Linknet [[paper](https://arxiv.org/abs/1707.03718)] [[docs](https://smp.readthedocs.io/en/latest/models.html#linknet)]\n - FPN [[paper](http://presentations.cocodataset.org/COCO17-Stuff-FAIR.pdf)] [[docs](https://smp.readthedocs.io/en/latest/models.html#fpn)]\n - PSPNet [[paper](https://arxiv.org/abs/1612.01105)] [[docs](https://smp.readthedocs.io/en/latest/models.html#pspnet)]\n - PAN [[paper](https://arxiv.org/abs/1805.10180)] [[docs](https://smp.readthedocs.io/en/latest/models.html#pan)]\n - DeepLabV3 [[paper](https://arxiv.org/abs/1706.05587)] [[docs](https://smp.readthedocs.io/en/latest/models.html#deeplabv3)]\n\n### Encoders\n\nThe following is a list of supported encoders in the SMP. Select the appropriate family of encoders and click to expand the table and select a specific encoder and its pre-trained weights (`encoder_name` and `encoder_weights` parameters).\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eResNet\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|resnet18                        |imagenet / ssl / swsl           |11M                             |\n|resnet34                        |imagenet                        |21M                             |\n|resnet50                        |imagenet / ssl / swsl           |23M                             |\n|resnet101                       |imagenet                        |42M                             |\n|resnet152                       |imagenet                        |58M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eResNeXt\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|resnext50_32x4d                 |imagenet / ssl / swsl           |22M                             |\n|resnext101_32x4d                |ssl / swsl                      |42M                             |\n|resnext101_32x8d                |imagenet / instagram / ssl / swsl|86M                         |\n|resnext101_32x16d               |instagram / ssl / swsl          |191M                            |\n|resnext101_32x32d               |instagram                       |466M                            |\n|resnext101_32x48d               |instagram                       |826M                            |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eSE-Net\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|senet154                        |imagenet                        |113M                            |\n|se_resnet50                     |imagenet                        |26M                             |\n|se_resnet101                    |imagenet                        |47M                             |\n|se_resnet152                    |imagenet                        |64M                             |\n|se_resnext50_32x4d              |imagenet                        |25M                             |\n|se_resnext101_32x4d             |imagenet                        |46M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eDenseNet\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|densenet121                     |imagenet                        |6M                              |\n|densenet169                     |imagenet                        |12M                             |\n|densenet201                     |imagenet                        |18M                             |\n|densenet161                     |imagenet                        |26M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eEfficientNet\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|efficientnet-b0                 |imagenet                        |4M                              |\n|efficientnet-b1                 |imagenet                        |6M                              |\n|efficientnet-b2                 |imagenet                        |7M                              |\n|efficientnet-b3                 |imagenet                        |10M                             |\n|efficientnet-b4                 |imagenet                        |17M                             |\n|efficientnet-b5                 |imagenet                        |28M                             |\n|efficientnet-b6                 |imagenet                        |40M                             |\n|efficientnet-b7                 |imagenet                        |63M                             |\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eDPN\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|dpn68                           |imagenet                        |11M                             |\n|dpn68b                          |imagenet+5k                     |11M                             |\n|dpn92                           |imagenet+5k                     |34M                             |\n|dpn98                           |imagenet                        |58M                             |\n|dpn107                          |imagenet+5k                     |84M                             |\n|dpn131                          |imagenet                        |76M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eVGG\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|vgg11                           |imagenet                        |9M                              |\n|vgg11_bn                        |imagenet                        |9M                              |\n|vgg13                           |imagenet                        |9M                              |\n|vgg13_bn                        |imagenet                        |9M                              |\n|vgg16                           |imagenet                        |14M                             |\n|vgg16_bn                        |imagenet                        |14M                             |\n|vgg19                           |imagenet                        |20M                             |\n|vgg19_bn                        |imagenet                        |20M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eMix Vision Transformer\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\nBackbone from SegFormer pretrained on Imagenet! Can be used with other decoders from package, you can combine Mix Vision Transformer with Unet, FPN and others!\n\nLimitations:  \n\n   - encoder is **not** supported by Linknet, Unet++\n   - encoder is supported by FPN only for encoder **depth = 5**\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|mit_b0                          |imagenet                        |3M                              |\n|mit_b1                          |imagenet                        |13M                             |\n|mit_b2                          |imagenet                        |24M                             |\n|mit_b3                          |imagenet                        |44M                             |\n|mit_b4                          |imagenet                        |60M                             |\n|mit_b5                          |imagenet                        |81M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary style=\"margin-left: 25px;\"\u003eMobileOne\u003c/summary\u003e\n\u003cdiv style=\"margin-left: 25px;\"\u003e\n\nApple's \"sub-one-ms\" Backbone pretrained on Imagenet! Can be used with all decoders.\n\nNote: In the official github repo the s0 variant has additional num_conv_branches, leading to more params than s1.\n\n|Encoder                         |Weights                         |Params, M                       |\n|--------------------------------|:------------------------------:|:------------------------------:|\n|mobileone_s0                    |imagenet                        |4.6M                              |\n|mobileone_s1                    |imagenet                        |4.0M                              |\n|mobileone_s2                    |imagenet                        |6.5M                              |\n|mobileone_s3                    |imagenet                        |8.8M                              |\n|mobileone_s4                    |imagenet                        |13.6M                             |\n\n\u003c/div\u003e\n\u003c/details\u003e\n\n### Timm 3D encoders\n\nWe now support encoders from [timm_3d](https://github.com/ZFTurbo/timm_3d) library. Full list available [here](https://github.com/ZFTurbo/timm_3d/blob/main/docs/models_list.md). To use them add `tu-` before encoder name.\nExample:\n\n```python\nencoder_name = 'tu-maxvit_base_tf_224.in21k'\nmodel = smp.Unet(\n    encoder_name=encoder_name,\n    encoder_weights=None,\n    in_channels=3,\n    classes=1,\n)\n```\n\n## Notes for 3D version\n\n### Input size\n\nRecommended input size for backbones can be calculated as: `K = pow(N, 2/3)`. \nWhere N - is size for input image for the same model in 2D variant.\n\nFor example for N = 224, K = 32. For N = 512, K = 64.\n\n### Strides\n\nTypical strides for 2D case is 2 for H and W. It applied `depth` times (in almost all cases 5 times). So input image reduced from (224, 224) to (7, 7) on final layers. For 3D case because of very massive input, it's sometimes useful to control strides for every dimension independently. For this you can use input variable `strides`, which default values is: `strides=((2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2), (2, 2, 2))`. Example:\n\nLet's say you have input data of size: (224, 128, 12). You can use strides like that:\n((2, 2, 2), (4, 2, 1), (2, 2, 2), (2, 2, 1), (1, 2, 3)). Output shape for these strides will be: (7, 4, 1)\n```python\nimport segmentation_models_pytorch_3d as smp\nimport torch\n\nmodel = smp.Unet(\n    encoder_name=\"resnet50\",        \n    in_channels=1,                  \n    strides=((2, 2, 2), (4, 2, 1), (2, 2, 2), (2, 2, 1), (1, 2, 3)),\n    classes=3, \n)\n\nres = model(torch.randn(4, 1, 224, 128, 12)) \n```\n\n**Note**: Strides currently supported by `resnet`-family and `densenet` models with `Unet` decoder only.\n\n### Related repositories\n\n * [https://github.com/qubvel/segmentation_models.pytorch](https://github.com/qubvel/segmentation_models.pytorch) - original segmentation 2D repo\n * [segmentation_models_3D](https://github.com/ZFTurbo/segmentation_models_3D) - segmentation models in 3D for keras/tensorflow\n * [timm_3d](https://github.com/ZFTurbo/timm_3d) - classification models in 3D for pytorch \n * [volumentations](https://github.com/ZFTurbo/volumentations) - 3D augmentations\n\n## Citation\n\nIf you find this code useful, please cite it as:\n```\n@article{solovyev20223d,\n  title={3D convolutional neural networks for stalled brain capillary detection},\n  author={Solovyev, Roman and Kalinin, Alexandr A and Gabruseva, Tatiana},\n  journal={Computers in Biology and Medicine},\n  volume={141},\n  pages={105089},\n  year={2022},\n  publisher={Elsevier},\n  doi={10.1016/j.compbiomed.2021.105089}\n}\n```\n\n## To Do List\n* Support for strides for all encoders\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfturbo%2Fsegmentation_models_pytorch_3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfturbo%2Fsegmentation_models_pytorch_3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfturbo%2Fsegmentation_models_pytorch_3d/lists"}