A cutting-edge medical AI system that automatically designs and trains highly accurate convolutional neural networks for lung and colon cancer detection using Neural Architecture Search (NAS) and Explainable AI.
- Overview
- Key Features
- Architecture
- Results
- Quick Start
- Project Structure
- Usage
- Model Details
- API Documentation
- Contributing
- License
This project demonstrates a modern approach to medical AI by leveraging Automated Machine Learning (AutoML) and Neural Architecture Search (NAS) to automatically design optimal neural network architectures for cancer image classification. The system achieves 99.04% validation accuracy on the LC25000 dataset, significantly outperforming traditional manually-designed models.
- 99.04% validation accuracy - State-of-the-art performance
- Automated architecture design - No manual neural network engineering required
- Explainable AI - Grad-CAM visualizations and textual explanations
- Production-ready web interface - Professional React.js frontend with Flask backend
- Neural Architecture Search (NAS): Automatically explores thousands of possible CNN architectures
- Explainable AI (XAI): Grad-CAM heatmaps showing decision regions
- Real-time Predictions: Fast inference with professional web interface
- Multi-class Classification: Detects 5 types of lung and colon tissues
- AutoML Pipeline: End-to-end automated model design and training
- Hyperparameter Optimization: Intelligent search space exploration
- Data Augmentation: Comprehensive image preprocessing pipeline
- Model Interpretability: Detailed explanations for medical professionals
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β React.js β β Flask API β β PyTorch β
β Frontend βββββΊβ Backend βββββΊβ NAS Model β
β β β β β β
β - Model Testing β β - Image Preproc β β - 99.04% Acc β
β - Explanations β β - Predictions β β - Grad-CAM β
β - Results Viz β β - Explanations β β - AutoML β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- Search Space Definition: 15+ architectural parameters
- Configuration Sampling: Intelligent random sampling
- Rapid Evaluation: Fast training with early stopping
- Best Model Selection: Performance-based architecture selection
- Final Training: Full training of optimal architecture
Metric | NAS-Optimized Model | Traditional CNN | Improvement |
---|---|---|---|
Validation Accuracy | 99.04% | 89.6% | +9.44% |
Validation Loss | 0.015 | 0.24 | +93.75% |
Training Time | 5 hours (NAS + Training) | 1 hour | +4 hours |
Generalization | Excellent | Good | Better |
The model accurately detects five tissue types:
- Lung Benign (Non-cancerous lung tissue)
- Lung Adenocarcinoma (Lung cancer type)
- Lung Squamous Cell Carcinoma (Lung cancer type)
- Colon Adenocarcinoma (Colon cancer type)
- Colon Benign (Non-cancerous colon tissue)
- Python 3.8+
- Node.js 16+
- PyTorch 2.0+
- CUDA (optional, for GPU acceleration)
- Clone the Repository
git clone https://github.com/Villwin007/Cancer-Image-Classification-with-AutoML-Driven-Neural-Architecture-Optimization.git
cd Cancer-Image-Classification-with-AutoML-Driven-Neural-Architecture-Optimization
- Backend Setup
cd backend
pip install -r requirements.txt
python app.py
- Frontend Setup (New Terminal)
cd lung-cancer-detection-web
npm install
npm run dev
- Access the Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Open http://localhost:5173 in your browser
- Navigate to "Model Testing" tab
- Upload a lung/colon tissue image
- View AI predictions with explanations
Cancer-Image-Classification/
βββ Model_Training
βββ backend/
β βββ app.py # Flask API with Grad-CAM explanations
β βββ requirements.txt # Python dependencies
β βββ lung_colon_cancer_nas_model_*.pth # Trained NAS model
β βββ src/
β β βββ components/ # React components
β β β βββ Header/ # Application header
β β β βββ Tabs/ # Tabbed interface
β β β βββ InfoTab/ # Project information
β β β βββ TestTab/ # Model testing interface
β β β βββ UploadInterface/ # Image upload component
β β β βββ Results/ # Prediction results
β β β βββ ExplanationView/ # AI explanations
β β β βββ Footer/ # Project information
β β βββ App.jsx # Main application component
β β βββ main.jsx # Application entry point
β βββ package.json # Node.js dependencies
β βββ vite.config.js # Vite configuration
βββ README.md # This file
# Run Neural Architecture Search
python training_code.py
# This will:
# 1. Perform NAS with 15 configurations
# 2. Select best architecture (99.04% accuracy)
# 3. Train final model
# 4. Generate performance plots and reports
- Project Information Tab: Learn about NAS and model architecture
- Model Testing Tab: Upload images for AI analysis
- Results View: See predictions with confidence scores
- Explanation Panel: Understand AI reasoning with heatmaps
# Health check
curl http://localhost:5000/health
# Model information
curl http://localhost:5000/model-info
# Prediction with explanation
curl -X POST -F "image=@path_to_image.jpg" http://localhost:5000/predict-with-explanation
SEARCH_SPACE = {
'num_conv_blocks': [3, 4, 5],
'filters_multiplier': [1, 2, 4],
'kernel_sizes_options': [[3,3,3], [3,5,3], [5,3,5], [3,3,5,3], [3,5,5,3]],
'use_batch_norm': [True, False],
'conv_dropout': [0.1, 0.2, 0.3],
'dense_units_options': [[512,256], [256,128], [512], [256]],
'dense_dropout': [0.3, 0.4, 0.5],
'learning_rate': [1e-3, 1e-4, 1e-5]
}
- Convolutional Blocks: 4 layers with 4Γ filter multiplier
- Kernel Sizes: [3, 3, 5, 3] optimized pattern
- Dense Layers: [256, 128] units with 0.5 dropout
- Learning Rate: 0.0001 with ReduceLROnPlateau scheduler
- Batch Size: 32 with extensive data augmentation
Check API status and model loading status.
Response:
{
"status": "healthy",
"model_loaded": true,
"mode": "real",
"explainable_ai": true
}
Get detailed model information and configuration.
Response:
{
"model_name": "NAS-Optimized Cancer Detection Model",
"validation_accuracy": "99.04%",
"model_loaded": true,
"classes": ["Colon Adenocarcinoma", "Colon Benign", ...],
"features": ["Grad-CAM explanations", "Textual reasoning"]
}
Analyze image with AI explanations.
Request:
curl -X POST -F "image=@tissue_image.jpg" http://localhost:5000/predict-with-explanation
Response:
{
"success": true,
"predictions": [...],
"confidence": 0.9904,
"diagnosis": "Lung Adenocarcinoma",
"explanation": {
"textual": "The model detected irregular glandular patterns...",
"heatmap_image": "base64_encoded_image",
"key_factors": ["Glandular architecture", "Nuclear features"]
}
}
We welcome contributions to enhance this medical AI system! Here's how you can help:
- Model Performance: Experiment with different NAS algorithms
- Explainability: Enhance Grad-CAM and add LIME/SHAP explanations
- Frontend Features: Add prediction history and comparison tools
- Deployment: Docker containers and cloud deployment scripts
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
Please use the GitHub issue tracker for:
- Bug reports
- Feature requests
- Documentation improvements
- Security vulnerabilities
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this work in your research, please cite:
@software{CancerClassificationNAS2025,
author = {Dhanush Saravanan},
title = {Cancer Image Classification with AutoML-Driven Neural Architecture Optimization},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/Villwin007/Cancer-Image-Classification-with-AutoML-Driven-Neural-Architecture-Optimization}}
}
Medical Disclaimer: This tool is for research and educational purposes only. It should not be used for actual medical diagnosis, treatment, or clinical decision-making. Always consult qualified healthcare professionals for medical advice.
Research Use: The model achieves 99.04% accuracy on the LC25000 dataset but should be clinically validated before any medical application.
For questions, issues, or collaborations:
- GitHub Issues: Create an issue
- Email: s.dhanush1106@gmail.com
- Documentation: See code comments and this README
This project demonstrates:
- AutoML superiority over manual architecture design in medical imaging
- Explainable AI importance in healthcare applications
- Neural Architecture Search practical implementation
- End-to-end ML system design from research to deployment
β Star this repository if you find it helpful!
Advancing medical AI through automated machine learning and explainable artificial intelligence.