A comprehensive deep learning project for detecting and segmenting brain diseases, particularly tumors, in MRI scans using multiple state-of-the-art architectures including U-Net and Meta's Segment Anything Model (SAM).
- Multi-Model Support: Implementations using both U-Net and SAM architectures
- Advanced Segmentation: Pixel-level precise segmentation of brain anomalies
- Automated Detection: Accurate identification of brain tumors and diseases
- Interactive Visualization: Rich set of visualization and analysis tools
- High Performance: GPU-optimized implementation with excellent metrics
- Flexible Pipeline: Support for various data formats and preprocessing techniques
graph TD
subgraph Data Pipeline
A[Raw MRI Scans] --> B[Image Processing]
B --> C[Dataset Creation]
C --> D[Data Augmentation]
end
subgraph U-Net Architecture
E[Input Layer] --> F[Encoding Path]
F --> G[Bottleneck]
G --> H[Decoding Path]
H --> I[Output Layer]
F -.-> H
end
graph TD
A[Input MRI Image] --> B[SAM Processor]
B --> C[Vision Encoder]
B --> D[Prompt Encoder]
C --> E[Mask Decoder]
D --> E
E --> F[Segmentation Mask]
E --> G[Probability Map]
- DICE Coefficient: 85-87%
- IoU Score: 78%
- Precision: 89%
- Recall: 83%
- Deep Learning Frameworks: PyTorch, HuggingFace Transformers
- Segmentation Models: U-Net, SAM (Segment Anything Model)
- Image Processing: OpenCV, Albumentations
- Analysis Tools: Pandas, NumPy, MONAI
- Visualization: Matplotlib
- Development: Python 3.x
# Clone the repository
git clone https://github.com/AmirrHussain/segmentation-of-brain-diseases.git
# Install requirements
pip install -r requirements.txt
# Install SAM
pip install git+https://github.com/facebookresearch/segment-anything.git
# Additional dependencies
pip install -q git+https://github.com/huggingface/transformers.git
pip install -q monai
├── main.py # Main execution file
├── config.py # Configuration settings
├── brain.py # Neural network architectures
├── trainer.py # Training functions
├── plotter.py # Visualization tools
├── sam_utils.py # SAM-specific utilities
└── dataSets/ # MRI scan datasets
dataSets/
├── patient_1/
│ ├── scan.jpg
│ └── scan_mask.jpg
└── patient_2/
├── scan.jpg
└── scan_mask.jpg
python main.py --model unet --mode train
from transformers import SamModel, SamProcessor
processor = SamProcessor.from_pretrained("facebook/sam-vit-base")
model = SamModel.from_pretrained("facebook/sam-vit-base")
outputs = model(**processor(image, input_boxes=[[prompt]], return_tensors="pt"))
- Multi-modal MRI support
- Web-based interface
- Enhanced augmentation pipeline
- Model ensemble implementation
- 3D volume segmentation
- Real-time processing capabilities
Contributions are welcome! Please feel free to submit a Pull Request:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit changes (
git commit -m 'Add AmazingFeature'
) - Push to branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Hossein Karimi
- Email: hk.karimi.93@gmail.com
- GitHub: @AmirrHussain
- Dataset providers
- PyTorch and HuggingFace communities
- Medical imaging experts
- Meta AI Research team