| title | BoneAge AI |
|---|---|
| emoji | 𦴠|
| colorFrom | blue |
| colorTo | indigo |
| sdk | docker |
| app_port | 7860 |
| pinned | true |
| license | mit |
| short_description | Automated Bone Age Assessment with Grad-CAM Explainability |
Automated Bone Age Assessment using Deep Learning Ensemble with Explainable AI
A production-ready web application for pediatric bone age assessment from hand radiographs, powered by a ResNet50 + XGBoost + Ridge ensemble with Grad-CAM explainability.
- Overview
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- API Reference
- Docker Deployment
- Model Details
- Contributing
- License
BoneAge AI automates skeletal maturity assessment from pediatric hand X-rays. It combines:
- ResNet50 deep learning backbone for feature extraction
- XGBoost + Ridge ensemble for robust regression
- Grad-CAM heatmaps highlighting anatomically relevant regions
- Gender-aware predictions using biological sex as an input feature
The system processes a hand radiograph and returns a predicted bone age (in months/years), developmental stage classification, and an explainable heatmap overlay.
βββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββ
β React Frontendβ POST β FastAPI Backend β
β (Vite :5173) ββββββββββΆβ (:8000) β
β β β βββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββ β β β ModelManager (Singleton) β β
β β Upload Zoneβ β β β ββββββββββββ βββββββββ βββββββββ β β
β β Sex Input β β β β β ResNet50 β βXGBoostβ β Ridge β β β
β β Age Input β β β β ββββββ¬ββββββ βββββ¬ββββ βββββ¬ββββ β β
β ββββββββββββββ β β β β β β β β
β βββββββββββ β Feature Ext. ββββ΄ββββββββββ β β
β ββββββββββββββ β JSON β β β Ensemble Weighted β β
β β Results β β β β βΌ Prediction β β
β β Dashboard β β β β Grad-CAM βββΆ Heatmap Overlay β β
β β + Grad-CAM β β β βββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββ β βββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββ
| Layer | Technology |
|---|---|
| Frontend | React 19 Β· Vite 7 Β· Vanilla CSS |
| Backend | FastAPI Β· Uvicorn Β· Python-Multipart |
| ML/DL | PyTorch Β· torchvision Β· XGBoost Β· scikit-learn |
| Explainability | Grad-CAM (layer4 hooks) Β· OpenCV |
| Containerization | Docker Β· Docker Compose Β· Nginx |
prmlpro/
βββ π README.md
βββ π .gitignore
βββ π docker-compose.yml # Container orchestration
βββ π save_models.py # One-time model export script
βββ π PRML_CODE.ipynb # Training notebook
β
βββ π backend/
β βββ main.py # FastAPI app + endpoints
β βββ model_manager.py # Singleton model loader
β βββ pipeline_orchestrator.py # Inference pipeline
β βββ explainability.py # Grad-CAM generator
β βββ requirements.txt # Python dependencies
β βββ Dockerfile
β
βββ π frontend/
βββ index.html
βββ Dockerfile
βββ src/
βββ main.jsx
βββ index.css # Clinical design system
βββ App.jsx # State management
βββ components/
βββ UploadWorkspace.jsx
βββ ProcessingIndicator.jsx
βββ ResultsDashboard.jsx
- Python 3.10+ with pip
- Node.js 18+ with npm
- RSNA Bone Age dataset (for model export step)
- (Optional) Docker & Docker Compose
Because the pre-trained model weights exceed GitHub's file size limits, they are hosted externally.
Before running the FastAPI backend, please download the following artifacts and place them directly into the folder directory:
Required Files:
best_bone_age_model.pth(ResNet50 Backbone)xgb_model.joblib(XGBoost Regressor)ridge_model.joblib(Ridge Regressor)ensemble_weights.joblib(Optimized Blend Weights)scaler.joblib(Tabular Feature Scaler)
git clone https://github.com/RGK1305/boneage-ai.git
cd boneage-aiThe PyTorch model (best_bone_age_model.pth) must be downloaded separately due to its size (~100MB). Place it in the project root, then:
# Create/activate Python environment
python -m venv bone_env
bone_env\Scripts\activate # Windows
# source bone_env/bin/activate # Linux/Mac
pip install torch torchvision xgboost scikit-learn pandas joblib
# Export XGBoost, Ridge, and scaler
python save_models.pyNote: This requires the RSNA dataset. Update
BASE_DIRinsave_models.pyif your dataset is at a different path.
cd backend
pip install -r requirements.txt
python -m uvicorn main:app --reload --port 8000Verify: open http://localhost:8000/api/v1/health
cd frontend
npm install
npm run devOpen http://localhost:5173 in your browser.
GET /api/v1/health
Response:
{
"status": "healthy",
"models_loaded": true,
"device": "cuda"
}POST /api/v1/predict
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image |
File | β | Hand radiograph (JPEG, PNG, BMP, TIFF) |
patient_sex |
String | β | "M" or "F" |
chronological_age_months |
Float | β | Patient's actual age for delta |
Response:
{
"status": "success",
"predicted_bone_age_months": 142.5,
"developmental_stage": "Adolescent",
"gradcam_overlay_base64": "data:image/png;base64,...",
"processing_time_ms": 850,
"chronological_age_months": 150,
"delta_months": -7.5
}# Build and start both services
docker-compose up --build
# Frontend: http://localhost:3000
# Backend: http://localhost:8000The Nginx reverse proxy in the frontend container forwards /api/ requests to the backend automatically.
| Component | Details |
|---|---|
| Backbone | ResNet50 (ImageNet pretrained) |
| Input | 384Γ384 RGB image + biological sex |
| Feature Dim | 2048 (backbone) + 1 (sex Γ 5.0) = 2049 |
| Ensemble | DL (~3.6%) + XGBoost (~87.3%) + Ridge (~9.1%) |
| Normalization | ImageNet mean/std: [0.485, 0.456, 0.406] / [0.229, 0.224, 0.225] |
| Output Scale | MAX_AGE_SCALE = 240.0 months |
| Explainability | Grad-CAM on backbone.layer4 |
| Dataset | RSNA Pediatric Bone Age Challenge |
| Stage | Age Range |
|---|---|
| Child | 0β143 months |
| Adolescent | 144β215 months |
| Adult | 216+ months |
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit changes (
git commit -m 'Add feature') - Push to branch (
git push origin feature/improvement) - Open a Pull Request
This project is licensed under the MIT License. See LICENSE for details.
Built with β€οΈ for pediatric radiology