File size: 5,079 Bytes
98adee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26e1e6b
98adee0
26e1e6b
 
 
 
 
98adee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: cc-by-nc-4.0
pipeline_tag: image-to-image
library_name: pytorch
datasets:
- ILSVRC/imagenet-1k
tags:
- image-colorization
- colorization
- one-step-generation
- mean-flow
---

# ColorMF

ColorMF colorizes gray images and gives a different plausible colorization for each noise seed,
**in one forward pass per sample**. It is a conditional pixel mean-flow transformer that maps the
CIELAB lightness and Gaussian noise to the `a*b*` chroma channels. The generator was trained from
scratch on ImageNet-1k at 256×256. The `-d` models also read frozen DINOv3 features of the gray
image.

Code, training and evaluation: **[github.com/AdelZakirov/ColorMF](https://github.com/AdelZakirov/ColorMF)**

![One forward pass, several plausible colorizations](teaser.jpg)

*One forward pass, several plausible colorizations (selected examples). Left: ImageNet validation
images and three noise seeds of ColorMF-B+D (`ω = 2`), compared with DDColor, which always gives
the same answer. Right: genuine black-and-white press photographs from 1940 and earlier
(Finna-JOKA, Finnish Heritage Agency, CC BY 4.0), for which no ground truth exists, and one sample
of ColorMF-B+D★.*

## Usage

```bash
pip install git+https://github.com/AdelZakirov/ColorMF.git
```

```python
from colormf import ColorMF

model = ColorMF.from_pretrained("b-d-star")              # any folder name of this repository
images = model.colorize("photo.jpg", num_samples=3)      # PIL images at the photo's full size
for seed, image in enumerate(images):
    image.save(f"colorized_{seed}.png")
```

Or from the command line: `colormf photo.jpg --samples 3 --output colorized/`.

The models `b-d`, `l-d` and `b-d-star` load the DINOv3 encoder from the Hub, where it is
distributed under Meta's DINOv3 license. Before the first use, accept the license on the page of
[facebook/dinov3-vitb16-pretrain-lvd1689m](https://huggingface.co/facebook/dinov3-vitb16-pretrain-lvd1689m)
(`b-d`, `b-d-star`) or
[facebook/dinov3-vitl16-pretrain-lvd1689m](https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m)
(`l-d`), and log in with `hf auth login`.

## Models

Each folder holds `model.safetensors` (float32) and `config.json` (architecture and the default
sampling settings). The metrics are on ImageNet val images 1–5000 (center crop, 256×256), first
seed, guidance `ω = 2`. Diversity is the LPIPS between two seeds, and CF is the colorfulness
(38.5 for the ground truth). Time is per image on one RTX 4090.

| folder | model | inference parameters | encoder (frozen) | ms | FID ↓ | FD<sub>CLIP</sub> ↓ | LPIPS ↓ | ΔE00 ↓ | CF | diversity |
|---|---|---:|---|---:|---:|---:|---:|---:|---:|---:|
| `tiny` | ColorMF-Tiny | 4M | – | 0.1 | 12.20 | 13.82 | 0.208 | 13.18 | 28.3 | 0.179 |
| `s` | ColorMF-S | 22M | – | 0.5 | 8.78 | 9.26 | 0.190 | 12.55 | 30.6 | 0.171 |
| `b` | ColorMF-B | 116M | – | 1.9 | 6.70 | 7.61 | 0.166 | 11.57 | 28.9 | 0.126 |
| `l` | ColorMF-L | 406M | – | 6.0 | 6.38 | 6.75 | 0.160 | 11.33 | 30.7 | 0.104 |
| `b-d` | ColorMF-B+D | 116M | DINOv3 ViT-B/16 | 2.5 | 5.32 | 6.09 | 0.148 | 10.66 | 29.5 | 0.106 |
| `b-d-star` | ColorMF-B+D★ | 116M | DINOv3 ViT-B/16 | 2.5 | 5.14 | 6.28 | 0.149 | 10.30 | 37.0 | 0.088 |
| `l-d` | ColorMF-L+D | 406M | DINOv3 ViT-L/16 | 7.8 | 4.98 | 5.76 | 0.142 | 10.57 | 30.5 | 0.090 |

The safetensors files also hold the auxiliary head that is used only in training, so they are
larger than the inference parameter count suggests. ColorMF-B+D★ is ColorMF-B+D after
Fréchet-distance post-training and distilled autoguidance (weight 2, still one pass). In a blind
pairwise study, people preferred it to DDColor in 55% of 3867 comparisons. ColorMF-L+D has the
best FID and FD<sub>CLIP</sub>.

Weights: the EMA (power-function, 500 kimg) of epoch 500 for the six base models, and the raw
post-trained weights for ColorMF-B+D★.

## Intended use and limitations

- The models are for research and non-commercial colorization of photographs. They were
  trained on ImageNet-1k, whose terms allow non-commercial research use only, so the weights are
  released under CC BY-NC 4.0.
- The models work at 256×256. Larger images are resized to 256×256 for the prediction, and the
  colors are resized back and combined with the original lightness. Fine colored details smaller
  than about 1/256 of the image are therefore not resolved.
- About half of the difference between two seeds is a global tint, and some old photographs get
  a strong overall color cast. Draw several seeds and pick one.
- The models' outputs are less saturated than real photos on average (colorfulness 29–31 against
  38.5 for the ground truth), except for ColorMF-B+D★ (37.0).
- The colors are guesses learned from ImageNet statistics, not a reconstruction of the true colors.
  Do not use the outputs as evidence of what a historical scene looked like.

## License

Weights: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/). Code: MIT
([GitHub](https://github.com/AdelZakirov/ColorMF)). The `-d` models need DINOv3, which has its own
license.