Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: image-to-image
|
| 4 |
+
tags:
|
| 5 |
+
- onnx
|
| 6 |
+
- onnxruntime-web
|
| 7 |
+
- image-colorization
|
| 8 |
+
- ddcolor
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# DDColor-tiny — fp16 ONNX (512×512)
|
| 12 |
+
|
| 13 |
+
An ONNX export of **DDColor-tiny** ([piddnad/DDColor](https://github.com/piddnad/DDColor),
|
| 14 |
+
ICCV 2023) for black-and-white / grayscale **image colorization**, exported for
|
| 15 |
+
in-browser inference with [onnxruntime-web](https://onnxruntime.ai/).
|
| 16 |
+
|
| 17 |
+
This is the model behind the **[Edge Tools](https://app.edgetools.io) Image
|
| 18 |
+
Colorizer** ([`/colorize-image`](https://app.edgetools.io/colorize-image)), which
|
| 19 |
+
runs it fully client-side — images are never uploaded anywhere.
|
| 20 |
+
|
| 21 |
+
## Files
|
| 22 |
+
|
| 23 |
+
| File | Size | What |
|
| 24 |
+
| --- | --- | --- |
|
| 25 |
+
| `ddcolor-tiny-fp16.onnx` | ~130 MB | DDColor-tiny, float16 **weights**, float32 I/O, fixed 512×512 input |
|
| 26 |
+
|
| 27 |
+
## Tensor contract
|
| 28 |
+
|
| 29 |
+
| | Name | Shape | dtype |
|
| 30 |
+
| --- | --- | --- | --- |
|
| 31 |
+
| Input | (first input) | `(1, 3, 512, 512)` | `float32` |
|
| 32 |
+
| Output | (first output) | `(1, 2, 512, 512)` | `float32` |
|
| 33 |
+
|
| 34 |
+
The weights are float16 but the **I/O boundary is plain float32**
|
| 35 |
+
(`keep_io_types=True`), so no fp16 tensor plumbing is needed and op support on the
|
| 36 |
+
ORT wasm execution provider stays maximal.
|
| 37 |
+
|
| 38 |
+
## Pre / post-processing
|
| 39 |
+
|
| 40 |
+
DDColor predicts **chroma only**; luminance comes from the source image. Using
|
| 41 |
+
CIE Lab in OpenCV's float convention (`L∈[0,100]`, `a,b∈~[-127,127]`, D65 white,
|
| 42 |
+
sRGB gamma — DDColor is trained against `cv2.cvtColor` float Lab):
|
| 43 |
+
|
| 44 |
+
1. Normalise input to `[0,1]` and compute the **original-resolution L** channel.
|
| 45 |
+
2. Resize to 512×512, rebuild a grayscale RGB from L (`a=b=0`, Lab→RGB) and feed
|
| 46 |
+
it as `(1,3,512,512)` float32. **No ImageNet normalisation** (`do_normalize=False`).
|
| 47 |
+
3. The model returns **ab** as `(1,2,512,512)`.
|
| 48 |
+
4. Resize ab back to the original size, concatenate with the **original-resolution
|
| 49 |
+
L**, and convert Lab→RGB. Only chroma is low-res; full-res luminance is preserved.
|
| 50 |
+
|
| 51 |
+
A reference JavaScript implementation of exactly this pipeline lives in the
|
| 52 |
+
`ddcolor.mjs` factory of the Edge Tools build (see Provenance).
|
| 53 |
+
|
| 54 |
+
## Provenance
|
| 55 |
+
|
| 56 |
+
Reproducibly built in CI from the upstream PyTorch checkpoint — nothing here is
|
| 57 |
+
hand-massaged:
|
| 58 |
+
|
| 59 |
+
- **Architecture code**: [`piddnad/DDColor`](https://github.com/piddnad/DDColor)
|
| 60 |
+
pinned at `2adb63f2656ac41cbdf7b894cddd94121a3faf13`
|
| 61 |
+
(`basicsr.archs.ddcolor_arch`, `encoder_name="convnext-t"`,
|
| 62 |
+
`decoder_name="MultiScaleColorDecoder"`, `num_output_channels=2`,
|
| 63 |
+
`last_norm="Spectral"`, `num_queries=100`, `num_scales=3`, `dec_layers=9`).
|
| 64 |
+
- **Weights**: [`piddnad/ddcolor_paper_tiny`](https://huggingface.co/piddnad/ddcolor_paper_tiny)
|
| 65 |
+
`pytorch_model.bin`, SHA-256-verified
|
| 66 |
+
(`8a1277bc90a1bfbb6d2d83933a9a6bc821931879ca93e26e4fcec12165d41fce`).
|
| 67 |
+
- **Export**: `torch.onnx.export`, **opset 17**, fixed 512×512 input, then weights
|
| 68 |
+
cast to float16 via `onnxconverter_common.float16.convert_float_to_float16(
|
| 69 |
+
..., keep_io_types=True)`. `onnxsim` / symbolic-shape-infer are skipped — the
|
| 70 |
+
input is fixed-size, so shapes are already static.
|
| 71 |
+
- **Built & published by**: the `edge-tools/wasm/ddcolor` CI project, which also
|
| 72 |
+
runs a colorization test against this exact artifact before publishing it.
|
| 73 |
+
|
| 74 |
+
## License
|
| 75 |
+
|
| 76 |
+
**Apache-2.0**, inherited from the upstream DDColor project
|
| 77 |
+
([LICENSE](https://github.com/piddnad/DDColor/blob/master/LICENSE)).
|
| 78 |
+
|
| 79 |
+
## Citation
|
| 80 |
+
|
| 81 |
+
```bibtex
|
| 82 |
+
@inproceedings{kang2023ddcolor,
|
| 83 |
+
title={DDColor: Towards Photo-Realistic Image Colorization via Dual Decoders},
|
| 84 |
+
author={Kang, Xiaoyang and Yang, Tao and Ouyang, Wenqi and Ren, Peiran and Li, Lingzhi and Xie, Xuansong},
|
| 85 |
+
booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
|
| 86 |
+
year={2023}
|
| 87 |
+
}
|
| 88 |
+
```
|