Transform grayscale images into vibrant color using VGG16 deep learning****Transform grayscale images into vibrant color using Advanced Encoder-Decoder Architecture
Get started in under 2 minutes!### Getting Started:
- οΏ½ Install dependencies:
pip install -r requirements.txt
```bash2. π Run the app: python app.py
pip install -r requirements.txt4. οΏ½ Upload grayscale images
- π Download colorized results
python app.py## π― Project Overview
Visit http://localhost:5000- πΌοΈ Input: Grayscale images
- π **Output**: Realistic color images
## β¨ Features
### **Key Features:**
- π§ **VGG16 Architecture** - Industry-standard pretrained network- β
**Advanced Architecture**: Multi-layer encoder-decoder design
- π¨ **LAB Color Space** - Perceptually uniform color processing- β
**LAB Color Space**: Perceptually uniform color processing
- β‘ **Fast Inference** - Real-time colorization on GPU/CPU- β
**Skip Connections**: Preserves fine details during colorization
- π **Beautiful Web UI** - Modern, responsive interface- β
**Auto-optimization**: Detects hardware and optimizes settings
- π **Privacy First** - Images processed locally, never stored- β
**Web Interface**: Flask + Bootstrap frontend
## π― What It Does## π **Project Structure**
This application uses the power of deep learning to automatically add realistic colors to black & white images:```
image-colorization/
1. **Upload** a grayscale imageβββ οΏ½οΈ app.py # Web interface (Flask)
2. **VGG16** extracts meaningful featuresβββ π§ models/ # Model architecture
3. **Decoder network** predicts color channelsβ βββ colorization_model.py # Deep encoder-decoder network
4. **Download** your colorized image!β βββ best_tiny_imagenet_colorization_model.pth # Trained weights
βββ π data/ # Data processing
## ποΈ Architectureβββ οΏ½ templates/ # Web UI templates
βββ οΏ½ static/ # CSS and JavaScript
```βββ π requirements.txt # Dependencies
Input (Grayscale) β VGG16 Features β Decoder β Color Prediction β Output (Color)```
[L channel] [256 filters] [Upsampling] [AB channels] [RGB Image]
```## π₯οΈ **Usage**
### Technical Details### **Web Interface:**
```bash
- **Feature Extractor**: VGG16 (pretrained on ImageNet)# Install dependencies
- **Processing**: LAB color space for better perceptual resultspip install -r requirements.txt
- **Input Resolution**: 256x256 (auto-resized)
- **Output**: Full-color RGB image# Run the application
- **Backend**: Flask REST APIpython app.py
- **Frontend**: Modern HTML5/CSS3/JavaScript
# Open browser at http://localhost:5000
## π¦ Installation```
### Requirements### **Upload and Colorize:**
1. Click "Choose File" to select a grayscale image
- Python 3.8 or higher2. Click "Colorize" to process the image
- PyTorch 2.0+3. View and download the colorized result
- 4GB+ RAM (8GB recommended)
- GPU optional (CUDA support for faster processing)## ποΈ **Technical Details**
### Step-by-Step### **Architecture:**
- **Encoder**: Deep convolutional layers with dilated convolutions
```bash- **Decoder**: Multi-scale feature aggregation with skip connections
# Clone the repository- **Input**: L channel (lightness) from LAB color space
git clone https://github.com/mihir0209/ColourDreams.git- **Output**: AB channels (color) predictions
cd ColourDreams/image-colorization- **Color Space**: LAB for perceptually uniform color representation
# Install dependencies### **Model Specifications:**
pip install -r requirements.txt- **Input Resolution**: 256x256 (automatically resized)
- **Output Resolution**: Matches input resolution
# Run the server- **Processing**: Efficient CPU/GPU inference
python app.py- **Color Accuracy**: Trained on diverse image datasets
The model learns to colorize various objects:
- ποΈ Landscapes: Natural sky and vegetation
-
Start the server:
python app.py- π Animals: Proper fur and eye colors -
Open browser:
http://localhost:5000- π Objects: Context-aware colorization -
Drag & drop or click to upload an image
-
Click "Colorize My Image"## π§ Requirements
-
Download your colorized result!
### Python APItorch >= 2.0.0
torchvision >= 0.15.0
```pythonnumpy
from inference_pipeline import ColorizationInferencePillow
from PIL import Imagescikit-image
flask
# Initialize modelrequests
colorizer = ColorizationInference()```
# Load image## π― **Features**
img = Image.open('grayscale_photo.jpg')
### **1. π Web Interface**
# Colorize- Upload images via browser
colorized = colorizer.colorize_image(img)- Real-time colorization
- User-friendly interface
# Save result- Download colorized results
colorized.save('colorized_photo.jpg')
```### **2. π§ Advanced Model**
- Deep encoder-decoder architecture
## π οΈ Project Structure- Skip connections for detail preservation
- LAB color space processing
```- CPU and GPU support
image-colorization/
βββ app.py # Flask web server### **3. οΏ½ High-Quality Results**
βββ inference_pipeline.py # Inference wrapper- Natural-looking colors
βββ models/- Context-aware colorization
β βββ colorization_model.py # VGG16 + Decoder architecture- Works on various image types
βββ templates/
β βββ index.html # Modern web UI## π **Citation**
βββ temp_uploads/ # Temporary file storage
βββ requirements.txt # Python dependenciesIf you use this project, please cite:
@misc{image-colorization-2025,
author={Your Name},
url={https://github.com/mihir0209/ColourDreams}
We use LAB color space instead of RGB:}
-
L channel: Lightness (0-100)```
-
A channel: Green to Red (-128 to 127)
-
B channel: Blue to Yellow (-128 to 127)## π License
This separation allows the model to focus on predicting color (A & B) while preserving the original brightness (L).MIT License - see LICENSE file for details.
VGG16, pretrained on ImageNet, extracts rich semantic features from the grayscale input. We use layers up to pool3 to maintain spatial resolution.Contributions welcome! Please feel free to submit issues and pull requests.
A lightweight CNN decoder upsamples the features and predicts the AB color channels using:π Transform your grayscale memories into vibrant color!
- Convolutional layers for feature transformation
- Bilinear upsampling for resolution recovery
- Tanh activation for bounded color predictions
The predicted AB channels are combined with the original L channel and converted back to RGB for display.
torch>=2.0.0
torchvision>=0.15.0
numpy
Pillow
scikit-image
flask
flask-cors
Werkzeug| Component | Details |
|---|---|
| Architecture | VGG16 + Custom Decoder |
| Parameters | ~15M (decoder only, VGG16 frozen) |
| Input Size | 256Γ256 |
| Color Space | LAB |
| Framework | PyTorch |
| Inference Time | ~0.1s (GPU) / ~0.5s (CPU) |
The model can colorize various types of images:
- π· Old photographs - Bring family memories to life
- ποΈ Landscapes - Natural skies and vegetation
- π€ Portraits - Realistic skin tones
- ποΈ Architecture - Context-aware building colors
Upload and colorize an image
Request:
FormData {
file: <image file>
}Response:
{
"status": "success",
"original_base64": "...",
"colorized_base64": "...",
"message": "Image colorized successfully with VGG16"
}Check server status
Response:
{
"status": "healthy",
"model_loaded": true
}Get model information
Response:
{
"model_type": "VGG16 Colorization Network",
"architecture": "VGG16 + Decoder",
"device": "cuda",
"input_size": "256x256",
"color_space": "LAB"
}- Use clear, well-lit grayscale images
- Higher resolution inputs generally work better
- The model works best on natural scenes
- For best results, images should have good contrast
- May produce unexpected colors for unusual objects
- Performance depends on input image quality
- Not trained specifically for artistic/creative colorization
- Works best with photographic content
Contributions are welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Improve documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- VGG16: Very Deep Convolutional Networks for Large-Scale Image Recognition
- PyTorch: Deep learning framework
- Flask: Web framework
- Bootstrap: UI components
For questions or feedback:
- GitHub: @mihir0209
- Repository: ColourDreams
Made with β€οΈ using VGG16 and PyTorch