File size: 2,071 Bytes
a4cc406
 
c7d348d
 
 
 
 
 
 
 
 
a4cc406
c7d348d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
library_name: onnx
pipeline_tag: image-to-image
base_model: piddnad/ddcolor_paper_tiny
tags:
  - colorization
  - image-colorization
  - onnx
  - onnxruntime-web
  - int8
---

# DDColor tiny, ONNX 512x512 (int8)

An ONNX export of **DDColor paper-tiny** for automatic image colorization, built for in-browser use with
onnxruntime-web. It powers the Colorize neural filter in the ToolsMonk Photo Editor, where it runs entirely on
the user's device.

## Provenance

- Model and code: [piddnad/DDColor](https://github.com/piddnad/DDColor) (Apache-2.0), weights
  `ddcolor_paper_tiny` ([piddnad/ddcolor_paper_tiny](https://huggingface.co/piddnad/ddcolor_paper_tiny)).
- Architecture settings match the upstream `scripts/export_onnx.py` for `model_size=tiny`: ConvNeXt-T encoder,
  MultiScaleColorDecoder, 100 queries, 3 scales, 9 decoder layers, input 512x512.
- Exported with `torch.onnx.export`, opset 17, fixed input shape `[1, 3, 512, 512]`.
- Weights of MatMul and Gemm nodes quantized to uint8 with `onnxruntime.quantization.quantize_dynamic`
  (fp32 export 257.7 MiB, this file 107.5 MiB). Mean absolute difference against the fp32 export on a test
  image: about 1.1 ab units.

## File

| File | Bytes | SHA-256 |
|---|---|---|
| `ddcolor_tiny_512_int8.onnx` | 112,723,138 | `e983347272b8e218edc974a0af2bd66f53b73212abb800e103c64806e4c14a14` |

## Input and output

- `input`: float32 `[1, 3, 512, 512]`, RGB in 0..1. Feed a grey image: take the CIELAB lightness L of the photo,
  set a = b = 0 and convert back to RGB.
- `output`: float32 `[1, 2, 512, 512]`, the predicted CIELAB a and b planes.

To colorize, resize the predicted a/b planes to the original size and combine them with the original photo's
L channel, then convert Lab to RGB. Detail and brightness come from the original photo.

## Licence

Apache License 2.0, the same licence as the upstream DDColor code and weights. See the upstream repository for
the paper and citation:

> Kang et al., "DDColor: Towards Photo-Realistic Image Colorization via Dual Decoders", ICCV 2023.