{"id":21410911,"url":"https://github.com/zfturbo/classification_models_3d","last_synced_at":"2025-04-05T14:04:44.967Z","repository":{"id":40554477,"uuid":"280381176","full_name":"ZFTurbo/classification_models_3D","owner":"ZFTurbo","description":"Set of models for classifcation of 3D volumes","archived":false,"fork":false,"pushed_at":"2024-05-02T13:51:50.000Z","size":135,"stargazers_count":168,"open_issues_count":16,"forks_count":28,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T13:09:25.542Z","etag":null,"topics":["3d-classification","deep-learning","image-classification","keras"],"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":"CHANGES.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/zfturbo"]}},"created_at":"2020-07-17T09:17:59.000Z","updated_at":"2025-03-29T10:21:30.000Z","dependencies_parsed_at":"2024-11-15T03:41:18.734Z","dependency_job_id":"5fc3f01a-78ef-408e-9aa5-96ea15bc3d9a","html_url":"https://github.com/ZFTurbo/classification_models_3D","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.1351351351351351,"last_synced_commit":"1e9b42c60e5f7896353dd8b259dfb140dc7a13d3"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fclassification_models_3D","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fclassification_models_3D/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fclassification_models_3D/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZFTurbo%2Fclassification_models_3D/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZFTurbo","download_url":"https://codeload.github.com/ZFTurbo/classification_models_3D/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345850,"owners_count":20924102,"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","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-classification","deep-learning","image-classification","keras"],"created_at":"2024-11-22T17:42:15.331Z","updated_at":"2025-04-05T14:04:44.929Z","avatar_url":"https://github.com/ZFTurbo.png","language":"Python","funding_links":["https://www.buymeacoffee.com/zfturbo"],"categories":[],"sub_categories":[],"readme":"# Classification models 3D Zoo for Keras 3\n\nThis repository contains 3D variants of popular classification CNN models like ResNets, DenseNets, VGG, etc for keras module. It also contains weights \nobtained by converting ImageNet weights from the same 2D models. \n\nThis repository is based on great [classification_models](https://github.com/qubvel/classification_models) repo by [@qubvel](https://github.com/qubvel/)\n\n### Architectures: \n- [VGG](https://arxiv.org/abs/1409.1556) [16, 19]\n- [ResNet](https://arxiv.org/abs/1512.03385) [18, 34, 50, 101, 152]\n- [ResNeXt](https://arxiv.org/abs/1611.05431) [50, 101]\n- [SE-ResNet](https://arxiv.org/abs/1709.01507) [18, 34, 50, 101, 152]\n- [SE-ResNeXt](https://arxiv.org/abs/1709.01507) [50, 101]\n- [SE-Net](https://arxiv.org/abs/1709.01507) [154]\n- [DenseNet](https://arxiv.org/abs/1608.06993) [121, 169, 201]\n- [Inception ResNet V2](https://arxiv.org/abs/1602.07261)\n- [Inception V3](http://arxiv.org/abs/1512.00567)\n- [MobileNet](https://arxiv.org/pdf/1704.04861.pdf)\n- [MobileNet v2](https://arxiv.org/abs/1801.04381)\n- [EfficientNet](https://arxiv.org/abs/1905.11946) [B0, B1, B2, B3, B4, B5, B6, B7]\n- [EfficientNet v2](https://arxiv.org/abs/2104.00298) [B0, B1, B2, B3, S, M, L]\n- [ConvNeXt](https://arxiv.org/pdf/2201.03545.pdf)\n\n### Installation \n\n`pip install classification-models-3D`\n\n### Examples \n\n#### Loading model with `imagenet` weights:\n\n```python\n\nfrom classification_models_3D.kkeras import Classifiers\n\nResNet18, preprocess_input = Classifiers.get('resnet18')\nmodel = ResNet18(input_shape=(128, 128, 128, 3), weights='imagenet')\n```\n\n#### Create model examples:\nKeras 3 support different backends like: Tensorflow, Torch and Jax. Below you can find examples for different backends:\n- Tensorflow: [tst_keras_tensorflow.py](tst_keras_tensorflow.py)\n- Tensorflow: [tst_special_cases_keras_tensorflow.py](tst_special_cases_keras_tensorflow.py)\n- Torch: [tst_keras_torch.py](tst_keras_torch.py)\n- Torch: [tst_special_cases_keras_torch.py](tst_special_cases_keras_torch.py)\n- Jax: [tst_keras_jax.py](tst_keras_jax.py)\n- Jax: [tst_special_cases_keras_jax.py](tst_special_cases_keras_jax.py)\n\n#### Training examples:\n- Tensorflow: [training_example_keras_tensorflow.py](training_example_keras_tensorflow.py)\n- Torch: [training_example_keras_torch.py](training_example_keras_torch.py)\n- Jax: [training_example_keras_jax.py](training_example_keras_jax.py)\n\n#### All possible nets for `Classifiers.get()` method: \n`'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'seresnet18', 'seresnet34', 'seresnet50',\n        'seresnet101', 'seresnet152', 'seresnext50', 'seresnext101', 'senet154', 'resnext50', 'resnext101',\n        'vgg16', 'vgg19', 'densenet121', 'densenet169', 'densenet201', 'mobilenet', 'mobilenetv2',\n        'inceptionresnetv2', 'inceptionv3',  'efficientnetb0', 'efficientnetb1', 'efficientnetb2', 'efficientnetb3',\n        'efficientnetb4', 'efficientnetb5', 'efficientnetb6', 'efficientnetb7', 'efficientnetv2-b0',\n        'efficientnetv2-b1', 'efficientnetv2-b2', 'efficientnetv2-b3', 'efficientnetv2-s', 'efficientnetv2-m',\n        'efficientnetv2-l', 'convnext_tiny', 'convnext_small', 'convnext_base', 'convnext_large', 'convnext_xlarge'`\n\n### Convert imagenet weights (2D -\u003e 3D)\n\nCode to convert 2D imagenet weights to 3D variant is available here: [convert_imagenet_weights_to_3D_models.py](convert_imagenet_weights_to_3D_models.py). \n\n### How to choose input shape\n\nIf initial 2D model had shape (512, 512, 3) then you can use shape (D, H, W, 3) where `D * H * W ~= 512*512`, so something like\n(64, 64, 64, 3) will be ok.\n\nTraining with single NVIDIA 1080Ti (11 GB) worked with:\n* DenseNet121, DenseNet169 and ResNet50 with shape (96, 128, 128, 3) and batch size 6\n* DenseNet201 with shape (96, 128, 128, 3) and batch size 5\n* ResNet18 with shape (128, 160, 160, 3) and batch size 6\n\n### Additional features\n\n#### Pooling\nDefault pooling/stride size for 3D models is set equal to 2. You can change it for your needs using parameter \n `stride_size`. Example:\n \n ```python\nfrom classification_models_3D.kkeras import Classifiers\n\nResNet18, preprocess_input = Classifiers.get('resnet18')\nmodel = ResNet18(\n    input_shape=(224, 224, 224, 3),\n    stride_size=4,\n    kernel_size=3, \n    weights=None\n)\n```\n\n`stride_size` can be: \n- single integer. Example: `4`\n- tuple of size 5 (if you didn't change `repetition` parameter). Example: `(2, 2, 4, 2, 2)`\n- tuple of tuples. Example: `(\n(2, 2, 1), (2, 2, 4), (2, 2, 2), (2, 1, 2), (2, 4, 2),  \n)`. Each number in `(2, 2, 1)` control stride of individual dimension.\n\n#### More blocks\n\n* For some models like (resnet, resnext, senet, vgg16, vgg19, densenet) it's possible to change number of blocks/poolings. \nFor example if you want to make more poolings overall. You can do it like that:\n\n ```python\nfrom classification_models_3D.kkeras import Classifiers\n\nResNet18, preprocess_input = Classifiers.get('resnet18')\nmodel = ResNet18(\n    input_shape=(128, 128, 128, 3),\n    include_top=False,\n    weights=None,\n    stride_size=(1, 1, 2, 2, 2, 2, 2, 2),\n    repetitions=(2, 2, 2, 2, 2, 2, 2),\n    init_filters=16,\n)\n```\n\n- **Note 1**: Since number of filters grows 2 times, you can set initial number of filters with `init_filters` parameter.\n- **Note 2**: There is no `imagenet` weights for models which were modified this way. \n\n### Related repositories\n\n* [https://github.com/qubvel/classification_models](https://github.com/qubvel/classification_models) - original 2D repo\n* [timm_3d](https://github.com/ZFTurbo/timm_3d) - models for classification in 3D for PyTorch\n* [segmentation models 3D](https://github.com/ZFTurbo/segmentation_models_3D) - models for segmentation in 3D for Keras/Tensorflow\n* [volumentations](https://github.com/ZFTurbo/volumentations) - 3D augmentations\n* [driven_data_repo](https://github.com/ZFTurbo/DrivenData-Alzheimer-Research-1st-place-solution) - code for training and inference on real dataset\n \n### Older versions\n\nLast version which supports Keras2 is 1.0.10\n\n`pip install classification-models-3D==1.0.10`\n\n### Unresolved problems\n\n* There is no DepthwiseConv3D layer in keras, so repo used custom layer from [this repo](https://github.com/alexandrosstergiou/keras-DepthwiseConv3D) by [@alexandrosstergiou]( https://github.com/alexandrosstergiou/keras-DepthwiseConv3D) which can be slower than native implementation. \n* There is no imagenet weights for 'inceptionresnetv2' and 'inceptionv3'.\n \n### Description\n \nThis code was used to get 1st place in [DrivenData: Advance Alzheimer’s Research with Stall Catchers](https://www.drivendata.org/competitions/65/clog-loss-alzheimers-research/leaderboard/) competition.\n \nMore details on ArXiv: https://arxiv.org/abs/2104.01687\n\n## Citation\n\nFor more details, please refer to the publication: https://doi.org/10.1016/j.compbiomed.2021.105089\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfturbo%2Fclassification_models_3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfturbo%2Fclassification_models_3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfturbo%2Fclassification_models_3d/lists"}