A comprehensive deep learning solution for automated bone age assessment from pediatric X-ray images using Convolutional Neural Networks (CNN).
- Introduction
- Features
- Installation
- Project Structure
- Usage
- Model Architecture
- Data
- Results
- API Reference
- Contributing
- References
Bone and skeletal age assessment is a common clinical practice to check the effectiveness of treatment for diagnosed endocrine abnormalities in a child's development. This project implements a fully automated deep learning approach to bone age assessment using data from the 2017 Pediatric Bone Age Challenge organized by the Radiological Society of North America.
The dataset consists of 12,600 radiographs of the left hand and wrist, which are the most frequently used images for bone age determination. Deep learning-based methods have shown significant performance improvements compared to traditional machine learning approaches.
- Modular Architecture: Clean, organized codebase with separate modules for different functionalities
- Multiple Model Architectures: Standard and advanced CNN architectures
- Comprehensive Evaluation: Detailed metrics and visualization tools
- Batch Processing: Support for single image and batch predictions
- Data Augmentation: Advanced image preprocessing and augmentation
- Visualization Tools: Rich plotting and analysis utilities
- Command-line Interface: Easy-to-use CLI for training and prediction
- Configuration Management: Centralized configuration system
- Python 3.8 or higher
- CUDA-compatible GPU (recommended for training)
- 8GB+ RAM (16GB+ recommended)
-
Clone the repository:
git clone <repository-url> cd Predict-Bone-Age
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Verify installation:
python -c "import tensorflow as tf; print('TensorFlow version:', tf.__version__)"
Predict-Bone-Age/
โโโ bone_age_prediction.py # Main training and evaluation script
โโโ model.py # CNN model definitions
โโโ utils.py # Utility functions and visualization
โโโ config.py # Configuration management
โโโ predict.py # Prediction script for inference
โโโ train.py # Simple training interface
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ FINALL PROJECT.ipynb # Original Jupyter notebook
โโโ outputs/ # Generated outputs (created during training)
โโโ models/ # Saved models
โโโ plots/ # Generated plots
โโโ results/ # Training results
python train.py --csv boneage-training-dataset.csv --images images/train --epochs 50python bone_age_prediction.pypython train.py \
--csv boneage-training-dataset.csv \
--images images/train \
--model-type advanced \
--epochs 100 \
--batch-size 64 \
--output-dir results/experiment_1python predict.py --model outputs/bone_age_model_standard.h5 --image path/to/image.png --visualizepython predict.py --model outputs/bone_age_model_standard.h5 --directory path/to/images/ --output predictions.jsonfrom predict import BoneAgePredictor
# Initialize predictor
predictor = BoneAgePredictor(model_path='outputs/bone_age_model_standard.h5')
# Predict single image
result = predictor.predict_single_image('path/to/image.png')
print(f"Predicted age: {result['predicted_age_years']:.1f} years")
# Batch prediction
results = predictor.predict_from_directory('path/to/images/')from utils import plot_bone_age_distribution, analyze_dataset
import pandas as pd
# Load data
df = pd.read_csv('boneage-training-dataset.csv')
# Analyze dataset
mean_age, std_age = analyze_dataset(df)
# Plot distributions
plot_bone_age_distribution(df, save_path='data_analysis.png')- Input: 385x385x3 RGB images
- Convolutional Layers: 4 blocks with 16, 32, 64, 128 filters
- Pooling: MaxPooling2D after each conv block
- Regularization: Dropout layers (0.2, 0.2, 0.3)
- Dense Layers: 64 โ 128 โ 1 neurons
- Output: Linear regression for age prediction
- Input: 385x385x3 RGB images
- Convolutional Layers: 8 blocks with double conv layers
- Filters: 32, 32, 64, 64, 128, 128, 256, 256
- Regularization: Enhanced dropout and batch normalization
- Dense Layers: 512 โ 256 โ 128 โ 1 neurons
- Optimizer: Adam with learning rate scheduling
- Source: RSNA Bone Age Challenge 2017
- Total Images: 12,600 radiographs
- Age Range: 1-228 months (0.08-19 years)
- Gender Distribution: ~50% male, ~50% female
- Image Format: PNG, 1653x1334 pixels (resized to 385x385)
- Normalization: Pixel values scaled to [0, 1]
- Augmentation: Rotation, zoom, shift, flip
- Z-score Normalization: Age values normalized using mean and std
- Train/Validation Split: 90/10 split
- Mean Absolute Error: ~23-27 months
- Predictions within 6 months: ~40-50%
- Predictions within 12 months: ~70-80%
- Predictions within 24 months: ~90-95%
The model shows good performance across different age groups, with slightly better accuracy for older children.
Main class for training and evaluation.
predictor = BoneAgePredictor(batch_size=32)
train_gen, val_gen, test_data = predictor.load_and_preprocess_data(csv_path, image_dir)
predictor.create_model()
predictor.train_model(train_gen, val_gen, epochs=50)CNN model definition and management.
cnn = BoneAgeCNN()
model = cnn.create_model()
cnn.save_model('model.h5')analyze_dataset(df): Dataset analysis and statisticsplot_bone_age_distribution(df): Age distribution visualizationevaluate_predictions(y_true, y_pred): Comprehensive evaluation metricsplot_training_history(history): Training progress visualization
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- RSNA Bone Age Challenge 2017
- Deep Learning for Bone Age Assessment
- Radiological Society of North America (RSNA)
This project is licensed under the MIT License - see the LICENSE file for details.
- RSNA for providing the bone age dataset
- The deep learning community for open-source tools and frameworks
- Contributors and researchers in medical imaging and AI
Note: This is a research project for educational purposes. For clinical use, please consult with medical professionals and ensure proper validation and regulatory approval.