| # SegMamba & GliomaSAM3-MoE: Complete Reproduction Package | |
| This repository contains **everything needed to reproduce** our brain tumor segmentation experiments on BraTS 2023 dataset, including source code, pre-trained weights, and evaluation results. | |
| ## Repository Structure | |
| ``` | |
| . | |
| ├── source_code/ | |
| │ ├── gliomasam3_moe/ # GliomaSAM3-MoE source code | |
| │ ├── SegMamba/ # SegMamba source code (with mamba/monai) | |
| │ └── sam3/ # SAM3 dependency module | |
| │ | |
| ├── pretrained_weights/ | |
| │ └── sam3.pt # SAM3 pretrained weights (3.3GB) | |
| │ | |
| ├── gliomasam3_moe/ | |
| │ ├── checkpoints/ # GliomaSAM3-MoE trained weights | |
| │ │ ├── ckpt_step2000.pt | |
| │ │ ├── ckpt_step2600.pt | |
| │ │ └── ckpt_step3000.pt # Best checkpoint | |
| │ ├── configs/ | |
| │ │ └── train.yaml # Training configuration | |
| │ ├── eval_results/ | |
| │ │ ├── table4_et_absent.json # ET presence classification results | |
| │ │ └── table7_boundary_dice.json # Boundary-band Dice results | |
| │ └── vis_res/ # Visualization results | |
| │ ├── method_comparison/ # Side-by-side comparisons | |
| │ ├── boundary/ # Boundary analysis figures | |
| │ ├── moe_routing/ # MoE routing visualizations | |
| │ └── ... | |
| │ | |
| ├── segmamba/ | |
| │ ├── checkpoints/ # SegMamba trained weights | |
| │ │ ├── tmp_model_ep599_0.8295.pt | |
| │ │ └── tmp_model_ep799_0.8498.pt # Best checkpoint (Dice=0.8498) | |
| │ └── prediction_results/ | |
| │ ├── segmamba_brats23_ep799/ # Prediction NIfTI files | |
| │ └── result_metrics/ # Evaluation metrics | |
| │ | |
| └── README.md | |
| ``` | |
| ## Model Performance | |
| ### GliomaSAM3-MoE (ckpt_step3000) | |
| **Boundary-band Dice (3-voxel band):** | |
| | Region | Dice | | |
| |--------|------| | |
| | WT | 0.789 ± 0.057 | | |
| | TC | 0.766 ± 0.154 | | |
| | ET | 0.697 ± 0.161 | | |
| | **Mean** | **0.750** | | |
| **ET Presence Classification:** | |
| | Metric | Value | | |
| |--------|-------| | |
| | AUROC | 0.896 | | |
| | Accuracy | 0.795 | | |
| | Sensitivity | 0.792 | | |
| | Specificity | 1.000 | | |
| ### SegMamba (ep799) | |
| - Mean Dice: 0.8498 | |
| - Trained for 800 epochs on BraTS 2023 | |
| ## Quick Start: Reproduction | |
| ### 1. Download this repository | |
| ```bash | |
| # Clone the dataset | |
| git clone https://huggingface.co/datasets/ChipYTY/segmamba | |
| cd segmamba | |
| ``` | |
| ### 2. Prepare BraTS 2023 Data | |
| Download BraTS 2023 GLI Challenge data from [Synapse](https://www.synapse.org/#!Synapse:syn51514105) and preprocess: | |
| ```bash | |
| cd source_code/SegMamba | |
| python 2_preprocessing_mri.py --input_dir /path/to/BraTS2023 --output_dir /path/to/processed | |
| ``` | |
| ### 3. Run GliomaSAM3-MoE Inference | |
| ```bash | |
| cd source_code/gliomasam3_moe | |
| # Set SAM3 path | |
| export PYTHONPATH=/path/to/source_code/sam3:$PYTHONPATH | |
| export SAM3_CKPT=/path/to/pretrained_weights/sam3.pt | |
| # Run inference | |
| python infer.py \ | |
| --config configs/train.yaml \ | |
| --checkpoint /path/to/gliomasam3_moe/checkpoints/ckpt_step3000.pt \ | |
| --data_dir /path/to/processed \ | |
| --output_dir ./predictions | |
| ``` | |
| ### 4. Run SegMamba Inference | |
| ```bash | |
| cd source_code/SegMamba | |
| python 4_predict.py \ | |
| --checkpoint /path/to/segmamba/checkpoints/tmp_model_ep799_0.8498.pt \ | |
| --data_dir /path/to/processed \ | |
| --output_dir ./predictions | |
| ``` | |
| ## Usage | |
| ### Loading GliomaSAM3-MoE | |
| ```python | |
| import torch | |
| # Load checkpoint | |
| ckpt = torch.load("gliomasam3_moe/checkpoints/ckpt_step3000.pt", map_location="cpu") | |
| # Model state dict is in ckpt["model"] | |
| model.load_state_dict(ckpt["model"]) | |
| ``` | |
| ### Loading SegMamba | |
| ```python | |
| import torch | |
| # Load checkpoint | |
| ckpt = torch.load("segmamba/checkpoints/tmp_model_ep799_0.8498.pt", map_location="cpu") | |
| # Model state dict | |
| model.load_state_dict(ckpt["model"]) | |
| ``` | |
| ## Data | |
| Models were trained and evaluated on BraTS 2023 GLI Challenge dataset. | |
| - **Download**: [Synapse BraTS 2023](https://www.synapse.org/#!Synapse:syn51514105) | |
| - **Preprocessing**: Use `source_code/SegMamba/2_preprocessing_mri.py` | |
| ## Requirements | |
| - Python 3.10+ | |
| - PyTorch 2.0+ | |
| - CUDA 11.8+ (for SegMamba's Mamba CUDA kernels) | |
| - See `source_code/gliomasam3_moe/requirements.txt` for full list | |
| ## Citation | |
| If you use these models, please cite the relevant papers. | |
| ## License | |
| Please refer to the original model repositories for licensing information. | |