Input (B&W) | Colorized Output |
![]() |
![]() |
Image Colorization Application
This application provides a web-based interface for colorizing black and white images using DeOldify technology. It consists of a FastAPI backend for processing images and a Streamlit frontend for a user-friendly interface.
Features
- Colorize black and white images using DeOldify
- Choose between Artistic (more vibrant) and Stable (more realistic) models
- Adjust render factor to control quality and processing time
- Generate multiple renders with different factors to find the optimal result
- Download colorized images
Installation
Prerequisites
- Python 3.10
- CUDA-capable GPU (recommended for faster processing)
- Git, Git-Lfs
Setup Instructions
- Clone the DeOldify repository inside your project directory:
git clone https://huggingface.co/sayed99/Image-Colorizer
- Set up the environment:
You can set up the environment using either Conda (recommended) or pip.
- Using Conda (Recommended):
conda env create -f environment.yml
conda activate deoldify
- Using Pip:
Make sure you have a compatible Python environment (3.10).
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
# On Windows:
.venv\Scripts\activate
# On macOS/Linux:
source .venv/bin/activate
# Install the required dependencies
pip install -r requirements.txt
This installs both the dependencies for our application and most of the dependencies needed for DeOldify.
Directory Structure
DeOldify/
: Cloned repository containing the core DeOldify library.models/
: Contains the downloaded.pth
model weights.input_images/
: Default location for uploaded images (can be configured).output_images/
orresult_images/
: Default location for single colorized images.multiple_renders/
: Default location for images generated using the multiple render factors feature.app.py
: FastAPI backend server.streamlit_app.py
: Streamlit frontend application.requirements.txt
: Pip dependencies.environment.yml
: Conda environment specification.
Running the Application
- Start the FastAPI server:
python app.py
This will start the API server on http://localhost:8000
- In a new terminal window, start the Streamlit web application:
streamlit run streamlit_app.py
This will open the web interface in your browser, typically at http://localhost:8501
API Documentation
Once the FastAPI server is running, you can access the API documentation at:
- http://localhost:8000/docs (Swagger UI)
- http://localhost:8000/redoc (ReDoc)
API Endpoints
POST /colorize
: Colorize a single image with specified parametersPOST /colorize_multiple
: Generate multiple colorizations with different render factorsGET /image/{image_path}
: Retrieve a colorized image by its path
Streamlit Web App
The web application provides an intuitive interface for:
- Uploading images
- Selecting colorization model (Artistic or Stable)
- Adjusting render factor
- Generating and comparing multiple renders
- Downloading colorized images
Technical Details
- The application uses DeOldify's image colorization models
- Default render factor is 10, but can be adjusted between 5-50
- The artistic model is used by default, but can be switched to stable
- For multiple renders, you can specify the minimum and maximum render factors and step size
Performance Tips
- If you encounter CUDA out-of-memory errors, try lowering the render factor
- For best results with the artistic model, a render factor of 10-15 is recommended
- For the stable model, a render factor of 20-25 typically works well
- increasing the render factor consume more gpu memory.
License
This project uses DeOldify, which is licensed under MIT License.