An AI-powered web application for automated lung cancer detection from chest X-ray images
- Overview
- Features
- Technology Stack
- Model Architecture
- How It Works
- Installation
- Usage
- Project Structure
- Model Performance
- Screenshots
- Future Enhancements
- Contributing
- License
- Contact
This project implements a deep learning-based medical imaging system designed to assist radiologists and healthcare professionals in the early detection of lung cancer from chest X-ray images. Using a fine-tuned InceptionV3 convolutional neural network, the application can classify chest X-rays into four distinct categories:
- Adenocarcinoma - Lung Cancer
- Large Cell Carcinoma - Lung Cancer
- Squamous Cell Carcinoma - Lung Cancer
- Normal - No Cancer Detected
The model is deployed as an interactive Streamlit web application, making it accessible to medical professionals without requiring deep technical expertise.
Lung cancer is one of the leading causes of cancer-related deaths worldwide. Early detection significantly improves survival rates, but manual analysis of X-rays is time-consuming and requires expert radiologists. This project aims to provide an AI-assisted diagnostic tool to:
- ✅ Speed up the diagnostic process
- ✅ Reduce human error and improve accuracy
- ✅ Make preliminary screening more accessible
- ✅ Assist in areas with limited access to expert radiologists
- 🔍 Real-Time Prediction - Upload chest X-rays and receive instant AI-powered predictions
- 🎯 Multi-Class Classification - Detects 3 types of lung cancer + normal cases
- 📊 Confidence Scores - Displays prediction confidence percentage for transparency
- 🖼️ Image Preprocessing - Automatic image resizing and normalization
- 🌐 Web-Based Interface - No installation required for end-users (via live deployment)
- ⚡ Fast Inference - Optimized model for quick predictions
- 🧠 Pre-trained InceptionV3 architecture with transfer learning
- 📁 Support for multiple image formats (PNG, JPG, JPEG)
- 🔄 Automatic image conversion to RGB
- 📈 Confidence-based result visualization
- 🎨 User-friendly Streamlit interface
- TensorFlow 2.x - Deep learning framework
- Keras - High-level neural networks API
- InceptionV3 - Pre-trained CNN architecture for image classification
- NumPy - Numerical computing
- Streamlit - Interactive web application framework
- Pillow (PIL) - Image manipulation and processing
- Matplotlib - Visualization (optional)
- Streamlit Cloud - Production deployment
- Git LFS - Large file storage for model weights
This project uses InceptionV3, a state-of-the-art convolutional neural network architecture developed by Google, pre-trained on ImageNet. The model leverages:
- Inception Modules - Multi-scale feature extraction using parallel convolutions
- Factorized Convolutions - Reduced computational cost
- Auxiliary Classifiers - Better gradient flow during training
| Parameter | Value |
|---|---|
| Architecture | InceptionV3 |
| Input Size | 224 × 224 × 3 (RGB) |
| Output Classes | 4 (3 Cancer Types + Normal) |
| Activation | Softmax |
| Loss Function | Categorical Crossentropy |
| Optimizer | Adam (presumed) |
classes = [
"Adenocarcinoma Chest Lung Cancer",
"Large cell carcinoma Lung Cancer",
"No Lung Cancer / NORMAL",
"Squamous cell carcinoma Lung Cancer"
]┌─────────────────┐
│ User Uploads │
│ Chest X-Ray │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Image Loading & │
│ Preprocessing │ ← Convert to RGB, Resize to 224×224
└────────┬────────┘
│
▼
┌─────────────────┐
│ Normalization │ ← Pixel values scaled to [0, 1]
└────────┬────────┘
│
▼
┌─────────────────┐
│ InceptionV3 CNN │ ← Feature extraction & classification
└────────┬────────┘
│
▼
┌─────────────────┐
│ Softmax Layer │ ← Probability distribution
└────────┬────────┘
│
▼
┌─────────────────┐
│ Prediction │ ← Highest probability class
│ + Confidence │
└─────────────────┘
- Input - User uploads a chest X-ray image (PNG/JPG/JPEG)
- Preprocessing - Image is converted to RGB and resized to 224×224 pixels
- Normalization - Pixel values are scaled from [0, 255] to [0, 1]
- Inference - The preprocessed image is fed through the InceptionV3 model
- Prediction - Softmax layer outputs probability distribution across 4 classes
- Result - The class with the highest probability is displayed along with confidence score
Make sure you have the following installed:
- Python 3.7+ - Download Python
- Git - Download Git
- Git LFS - Install Git LFS (Required for model file)
git clone https://github.com/amitkumar2308/Cancer-detection-streamlit.git
cd Cancer-detection-streamlitOn Windows:
python -m venv .venv
.venv\Scripts\activateOn macOS/Linux:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtIf the model file (inception_chest.h5) wasn't downloaded automatically:
git lfs install
git lfs pullstreamlit run model.pyThe application will open in your default browser at http://localhost:8501
-
Start the application:
streamlit run model.py
-
Upload an X-ray image:
- Click on "Choose an image..." button
- Select a chest X-ray image (PNG, JPG, or JPEG format)
-
Get Prediction:
- Click the "Predict" button
- View the predicted cancer type and confidence score
Visit the deployed application: 🚀 Live Demo
Cancer-detection-streamlit/
│
├── assests/
│ └── project.png # Screenshot of the application
│
├── inception_chest.h5 # Pre-trained InceptionV3 model weights
├── model.py # Main Streamlit application
├── requirements.txt # Python dependencies
│
├── .gitattributes # Git LFS configuration
├── README.md # Project documentation
└── LICENSE # MIT License
-
model.py- Main application file containing:- Model loading function
- Image preprocessing pipeline
- Prediction logic
- Streamlit UI components
-
inception_chest.h5- Fine-tuned InceptionV3 model (stored via Git LFS) -
requirements.txt- Dependencies:tensorflow numpy pillow streamlit matplotlib
The model was trained on a chest X-ray dataset containing labeled images of:
- Adenocarcinoma cases
- Large cell carcinoma cases
- Squamous cell carcinoma cases
- Normal/healthy chest X-rays
Note: Add your actual metrics here if available
- Accuracy: ~XX%
- Precision: ~XX%
- Recall: ~XX%
- F1-Score: ~XX%
Screenshot showing the Streamlit interface with prediction results
- Grad-CAM Visualization - Highlight regions of the X-ray that influenced the prediction
- Batch Processing - Upload and analyze multiple X-rays simultaneously
- Patient History Tracking - Store and compare previous scans
- PDF Report Generation - Export diagnostic reports
- Model Ensemble - Combine multiple models for improved accuracy
- API Endpoint - RESTful API for integration with hospital systems
- Mobile App - Native mobile application for iOS/Android
- Multi-language Support - Internationalization for global accessibility
- Model quantization for faster inference
- A/B testing with other architectures (ResNet, EfficientNet, Vision Transformer)
- Active learning pipeline for continuous model improvement
- DICOM format support for medical imaging standards
- Integration with PACS (Picture Archiving and Communication System)
Contributions are what make the open-source community such an amazing place to learn, inspire, and create! Any contributions you make are greatly appreciated.
-
Fork the Project
git clone https://github.com/your-username/Cancer-detection-streamlit.git
-
Create a 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
- Follow PEP 8 style guide for Python code
- Use
blackfor code formatting - Write meaningful commit messages
- Add comments for complex logic
- Test thoroughly before submitting PRs
This project is licensed under the MIT License - see the LICENSE file for details.
Amit Kumar
- 💼 GitHub: @amitkumar2308
- 📧 Email: amitkumar@example.com
- 🌐 Live Application: Cancer Detection App
- TensorFlow & Keras - For providing robust deep learning frameworks
- Streamlit - For the amazing web app framework
- Google Research - For the InceptionV3 architecture
- Chest X-ray Dataset Contributors - For making medical imaging data available for research
This application is for educational and research purposes only. It should not be used as a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of qualified health providers with any questions regarding a medical condition.
⭐ If you found this project helpful, please consider giving it a star!
Made with ❤️ by Amit Kumar
