SEN-D (StackedEnsembleNet Detection) is an advanced AI system for automated kidney stone detection from CT scan images using deep learning ensemble methods with explainable AI visualizations.
SEN-D uses a sophisticated ensemble of convolutional neural networks to provide accurate, reliable kidney stone detection with 98.74% accuracy. The system combines multiple CNN architectures with Grad-CAM visualizations to assist radiologists in clinical diagnosis.
- π― High Accuracy: 98.74% classification accuracy with 98.57% precision
- π§ Ensemble Learning: Combines InceptionV3, InceptionResNetV2, and Xception models
- π Explainable AI: Grad-CAM visualizations for transparent decision making
- π Production Ready: FastAPI backend deployed on Fly.io with React frontend
- π Real-time Analysis: Fast prediction with comprehensive model outputs
- π₯ Clinical Grade: Validated on hospital-grade CT imaging data
Input CT Scan (299x299)
β
βββββββββββββββ¬βββββββββββββ-β¬ββββββββββββββ
β InceptionV3 βInceptionResV2β Xception β
βββββββββββββββ΄βββββββββββββ-β΄ββββββββββββββ
β β β
βββββββββββββββ¬βββββββββββββ-β¬ββββββββββββββ
β Custom Head β Custom Head β Custom Head β
β 256β128β2 β 256β128β2 β 256β128β2 β
βββββββββββββββ΄βββββββββββββ-β΄ββββββββββββββ
β β β
StackedEnsembleNet Meta-Learner
β
Final Classification
(Kidney Stone / Normal)
Frontend:
- React 19 with Vite
- TailwindCSS for styling
- React Icons for UI components
- Responsive design with animations
- Deployed on Vercel
Backend:
- FastAPI for REST API
- PyTorch for deep learning
- Grad-CAM for explainability
- Docker containerization
- Fly.io deployment
AI/ML:
- Custom ensemble architecture (See References)
- Transfer learning with pre-trained models
- Data augmentation pipeline
- Cross-entropy loss optimization
| Metric | Score |
|---|---|
| Accuracy | 98.74% |
| Precision | 98.57% |
| Recall/Sensitivity | 98.96% |
| F1-Score | 98.76% |
| MCC | 97.48% |
- Python 3.8+
- Node.js 16+
- GPU recommended for training (CUDA support)
- Clone the repository
git clone https://github.com/yourusername/SEN-D.git
cd SEN-D- Backend Setup
cd Backend
pip install -r requirements.txt- Frontend Setup
cd Frontend
npm install- Start the Backend
cd Backend
python app.py
# API available at http://localhost:8000- Start the Frontend
cd Frontend
npm run dev
# Frontend available at http://localhost:5173curl http://localhost:8000/healthcurl -X POST "http://localhost:8000/predict" \
-H "Content-Type: multipart/form-data" \
-F "file=@ct_scan.jpg"import requests
with open("ct_scan.jpg", "rb") as f:
files = {"file": ("ct_scan.jpg", f, "image/jpeg")}
response = requests.post("http://localhost:8000/predict", files=files)
result = response.json()
print(f"Prediction: {result['ensemble']['prediction']}")
print(f"Confidence: {result['ensemble']['confidence']:.2%}"){
"ensemble": {
"prediction": "Normal",
"confidence": 0.85,
"probabilities": {
"Kidney_stone": 0.15,
"Normal": 0.85
}
},
"individual_models": {
"inception_v3": {
"prediction": "Normal",
"confidence": 0.82,
"probabilities": {...},
"gradcam_overlay": "base64_encoded_image",
"gradcam_heatmap": "base64_encoded_image"
},
"inception_resnet_v2": {...},
"xception": {...}
},
"processing_time": 2.345,
"success": true
}The project uses a hybrid dataset from:
- Kaggle Axial CT Imaging Dataset
- ElazΔ±Δ Fethi Sekin City Hospital, Turkey (Reference)
Place your dataset in:
Backend/Dataset/
βββ Train/
β βββ Kidney_stone/
β βββ Normal/
βββ Test/
βββ Kidney_stone/
βββ Normal/
- Data Augmentation
cd Backend
python augment.py # Generate augmented training data- Open Training Notebook
jupyter notebook Notebook.ipynb- Follow the notebook sections:
- Data loading and preprocessing
- Model architecture setup
- Training individual models
- Ensemble training
- Evaluation and testing
The training supports multiple architectures:
inception_v3: InceptionV3 with custom classifierinception_resnet_v2: InceptionResNetV2 with residual connectionsxception: Xception with depthwise separable convolutionsstacked_ensemble: Complete ensemble with meta-learner
SEN-D/
βββ Frontend/ # React application
β βββ src/
β β βββ components/ # UI components
β β βββ assets/ # Static assets
β β βββ main.jsx # Application entry
β βββ public/ # Public assets
β βββ package.json
β βββ vite.config.ts
βββ Backend/ # FastAPI application
β βββ Dataset/ # Training/test data
β β βββ Train/
β β βββ Test/
β βββ Dataset_Augmented/ # Augmented training data
β βββ models/ # Trained model files
β βββ app.py # FastAPI main application
β βββ app_utils.py # Utility functions
β βββ architectures.py # Model architectures
β βββ augment.py # Data augmentation
β βββ Notebook.ipynb # Training notebook
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Container configuration
βββ README.md
βββ LICENSE
Good Examples:
- Single CT scan slices (299x299+ pixels)
- Clear kidney regions visible
- Proper contrast and orientation
- DICOM windowing applied
Avoid:
- Multi-panel reports
- Images with annotations/text
- Non-medical images
- Low resolution scans
- Input Size: Minimum 299x299 pixels
- Format: RGB color channels
- File Size: Maximum 10MB
- Supported Types: JPG, PNG, JPEG
This system is based on the research:
"An Optimized Fusion of Deep Learning Models for Kidney Stone Detection from CT Images"
Computers in Biology and Medicine, 2024 - ScienceDirect
- Binary classification: Kidney Stone vs Normal
- Support early detection and diagnosis
- Assist radiologists in CT scan analysis
- Improve diagnostic efficiency and accuracy
cd Backend
fly deploy- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Any contributions will be greatly appreciated!
This project is licensed under the MIT License - see the LICENSE file for details.
- Research team for the original StackedEnsembleNet architecture
- Kaggle community for the CT imaging dataset
- ElazΔ±Δ Fethi Sekin City Hospital for clinical data
- Open source community for the amazing tools and libraries