File size: 7,149 Bytes
5dc545c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
---
license: mit
tags:
- image-colorization
- gan
- computer-vision
- pytorch
- onnx
library_name: pytorch
---
# DeOldify Model Weights
This repository contains pretrained weights for **DeOldify**, a deep learning model for colorizing and restoring old black and white images and videos.
**Original Repository**: [thookham/DeOldify](https://github.com/thookham/DeOldify)
**Original Author**: Jason Antic ([jantic/DeOldify](https://github.com/jantic/DeOldify))
## Model Overview
DeOldify uses a Self-Attention Generative Adversarial Network (SAGAN) with a novel **NoGAN** training approach to achieve stable, high-quality colorization without the typical GAN artifacts.
### Three Specialized Models
1. **Artistic** - Highest quality with vibrant colors and interesting details
- Best for: General images, historical photos
- Backbone: ResNet34 U-Net
- Training: 5 NoGAN cycles, 32% ImageNet
2. **Stable** - Best for portraits and landscapes, reduced artifacts
- Best for: Faces, nature scenes
- Backbone: ResNet101 U-Net
- Training: 3 NoGAN cycles, 7% ImageNet
3. **Video** - Optimized for smooth, flicker-free video
- Best for: Video colorization, consistency
- Backbone: ResNet101 U-Net
- Training: Initial cycle only, 2.2% ImageNet
## Available Files
### ONNX Models (Browser/Inference)
| File | Size | Description |
|------|------|-------------|
| `deoldify-art.onnx` | 243 MB | Artistic model in ONNX format for browser use |
| `deoldify-quant.onnx` | 61 MB | Quantized artistic model (75% smaller, slightly lower quality) |
### PyTorch Weights (Training & Inference)
**Generator Weights** (Main):
- `ColorizeArtistic_gen.pth` (243 MB)
- `ColorizeStable_gen.pth` (834 MB)
- `ColorizeVideo_gen.pth` (834 MB)
**Critic Weights** (Main):
- `ColorizeArtistic_crit.pth` (361 MB)
- `ColorizeStable_crit.pth` (361 MB)
- `ColorizeVideo_crit.pth` (361 MB)
**PretrainOnly Weights** (For continued training):
- `ColorizeArtistic_PretrainOnly_gen.pth` (729 MB)
- `ColorizeArtistic_PretrainOnly_crit.pth` (1.05 GB)
- `ColorizeStable_PretrainOnly_crit.pth` (1.05 GB)
- `ColorizeVideo_PretrainOnly_crit.pth` (1.05 GB)
> **Note**: Stable and Video PretrainOnly generators are split files hosted on [GitHub Releases](https://github.com/thookham/DeOldify/releases/tag/v2.0-models).
## Usage
### Browser (ONNX)
```html
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
</head>
<body>
<script>
async function colorize() {
// Load model from Hugging Face
const session = await ort.InferenceSession.create(
"https://huggingface.co/thookham/DeOldify/resolve/main/deoldify-art.onnx"
);
// Run inference (see full example in GitHub repo)
// ...
}
</script>
</body>
</html>
```
### PyTorch (Python)
```python
from huggingface_hub import hf_hub_download
import torch
# Download model weights
model_path = hf_hub_download(
repo_id="thookham/DeOldify",
filename="ColorizeArtistic_gen.pth"
)
# Load weights (requires deoldify package installed)
# See GitHub repository for full usage examples
```
### Installation
```bash
# Clone the main repository
git clone https://github.com/thookham/DeOldify
cd DeOldify
# Install dependencies
pip install -r requirements.txt
# Download a model
from huggingface_hub import hf_hub_download
model = hf_hub_download(repo_id="thookham/DeOldify", filename="ColorizeStable_gen.pth")
```
## Technical Details
### Architecture
- **Generator**: U-Net with ResNet34/101 backbone, spectral normalization, self-attention layers
- **Critic**: PatchGAN discriminator
- **Loss**: Perceptual loss (VGG16) + GAN loss
### NoGAN Training
A novel training approach that combines:
1. Generator pretraining with feature loss
2. Critic pretraining on generated images
3. Short GAN training (30-60 minutes) at inflection point
4. Optional cycle repeats for more colorful results
This eliminates typical GAN artifacts while maintaining realistic colorization.
### Training Data
- Dataset: ImageNet subsets (1-32% depending on model)
- Resolution: 192px during training
- Augmentation: Gaussian noise for video stability
## Model Card
### Model Details
- **Developed by**: Jason Antic (original), Travis Hookham (modernization)
- **Model type**: Conditional GAN for image-to-image translation
- **Language(s)**: N/A (computer vision)
- **License**: MIT
- **Parent Model**: Based on FastAI U-Net and Self-Attention GAN papers
### Intended Use
**Primary Use**: Colorizing black and white photographs and videos
**Out-of-Scope**: Real-time processing, guaranteed historical accuracy
### Limitations
- Colors may not be historically accurate
- Performance degrades on very low quality/damaged images
- Artistic model may require render_factor tuning
- Video model trades some color vibrancy for consistency
## Related Models & Resources
### Similar Colorization Models on Hugging Face
**GAN-based Colorization:**
- [Hammad712/GAN-Colorization-Model](https://huggingface.co/Hammad712/GAN-Colorization-Model) - GAN model for grayscale to color transformation
- [jessicanono/filparty_colorization](https://huggingface.co/jessicanono/filparty_colorization) - ResNet-based model for historical photos
**Stable Diffusion-based:**
- [rsortino/ColorizeNet](https://huggingface.co/rsortino/ColorizeNet) - ControlNet adaptation of SD 2.1 for colorization
- [AlekseyCalvin/ColorizeTruer_KontextFluxVar6_BySAP](https://huggingface.co/AlekseyCalvin/ColorizeTruer_KontextFluxVar6_BySAP) - Advanced Flux-based colorization
**Interactive Demos (Spaces):**
- [aryadytm/Photo-Colorization](https://huggingface.co/spaces/aryadytm/Photo-Colorization)
- [Shashank009/Black-And-White-Image-Colorization](https://huggingface.co/spaces/Shashank009/Black-And-White-Image-Colorization)
- [CA611/Image-Colorization](https://huggingface.co/spaces/CA611/Image-Colorization)
### Why Choose DeOldify?
DeOldify stands out for:
- **NoGAN Training**: Unique approach eliminating typical GAN artifacts
- **Specialized Models**: Three purpose-built models (Artistic, Stable, Video)
- **Video Support**: Flicker-free temporal consistency
- **Proven Track Record**: Powers MyHeritage InColor and widely adopted
- **ONNX Support**: Browser-ready models for offline use
## Citation
If you use these models, please cite:
```bibtex
@misc{deoldify,
author = {Antic, Jason},
title = {DeOldify},
year = {2019},
publisher = {GitHub},
url = {https://github.com/jantic/DeOldify}
}
```
## Links
- **GitHub Repository**: https://github.com/thookham/DeOldify
- **Original DeOldify**: https://github.com/jantic/DeOldify
- **MyHeritage InColor** (Commercial version): https://www.myheritage.com/incolor
- **Demo (Browser)**: See browser/ folder in GitHub repo
## License
MIT License. See [LICENSE](https://github.com/thookham/DeOldify/blob/master/LICENSE) file.
|