hintauc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hintauc-0.1.0/LICENSE +21 -0
- hintauc-0.1.0/PKG-INFO +170 -0
- hintauc-0.1.0/README.md +131 -0
- hintauc-0.1.0/hintauc/__init__.py +66 -0
- hintauc-0.1.0/hintauc/auc.py +73 -0
- hintauc-0.1.0/hintauc/cli.py +84 -0
- hintauc-0.1.0/hintauc/hints.py +485 -0
- hintauc-0.1.0/hintauc/longest_path.py +176 -0
- hintauc-0.1.0/hintauc/metrics.py +305 -0
- hintauc-0.1.0/hintauc.egg-info/PKG-INFO +170 -0
- hintauc-0.1.0/hintauc.egg-info/SOURCES.txt +16 -0
- hintauc-0.1.0/hintauc.egg-info/dependency_links.txt +1 -0
- hintauc-0.1.0/hintauc.egg-info/entry_points.txt +2 -0
- hintauc-0.1.0/hintauc.egg-info/requires.txt +15 -0
- hintauc-0.1.0/hintauc.egg-info/top_level.txt +1 -0
- hintauc-0.1.0/pyproject.toml +56 -0
- hintauc-0.1.0/setup.cfg +4 -0
- hintauc-0.1.0/tests/test_longest_path.py +105 -0
hintauc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 xuekt98
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
hintauc-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hintauc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic region-based hint generation (DHT) and Hint-AUC evaluation for line-art colorization
|
|
5
|
+
Author: Koki Madono
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/MADONOKOUKI/DetFill-with-DHT
|
|
8
|
+
Project-URL: Repository, https://github.com/MADONOKOUKI/DetFill-with-DHT
|
|
9
|
+
Project-URL: Issues, https://github.com/MADONOKOUKI/DetFill-with-DHT/issues
|
|
10
|
+
Project-URL: Paper, https://doi.org/10.1109/TVCG.2026.3738401
|
|
11
|
+
Keywords: line art,colorization,evaluation,hint generation,Hint-AUC,diffusion
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: <3.13,>=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Requires-Dist: opencv-python
|
|
26
|
+
Requires-Dist: scikit-image>=0.19
|
|
27
|
+
Requires-Dist: fil_finder<1.8,>=1.7
|
|
28
|
+
Requires-Dist: astropy<6,>=5.0
|
|
29
|
+
Requires-Dist: pillow
|
|
30
|
+
Provides-Extra: perceptual
|
|
31
|
+
Requires-Dist: torch; extra == "perceptual"
|
|
32
|
+
Requires-Dist: torchvision; extra == "perceptual"
|
|
33
|
+
Requires-Dist: lpips; extra == "perceptual"
|
|
34
|
+
Requires-Dist: open_clip_torch; extra == "perceptual"
|
|
35
|
+
Requires-Dist: transformers; extra == "perceptual"
|
|
36
|
+
Requires-Dist: dreamsim; extra == "perceptual"
|
|
37
|
+
Requires-Dist: torchmetrics; extra == "perceptual"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# DetFill-with-DHT: Deterministic Hints and Hint-AUC for Line Art Colorization
|
|
41
|
+
|
|
42
|
+
[](https://doi.org/10.1109/TVCG.2026.3738401)
|
|
43
|
+
[](https://doi.org/10.1109/TVCG.2026.3738401)
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
[](#installation)
|
|
46
|
+
[](#installation)
|
|
47
|
+
[](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases)
|
|
48
|
+
|
|
49
|
+
Official implementation of **"Hint-AUC: Deterministic Region-based Hint Generation for Line Art Colorization Evaluation"**
|
|
50
|
+
(Koki Madono, Yuan Mingcheng, Edgar Simo-Serra — IEEE Transactions on Visualization and Computer Graphics, 2026).
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
## Highlights
|
|
55
|
+
|
|
56
|
+
- **Deterministic hints (DHT).** The same illustration always yields the same scribble and dot hints, so
|
|
57
|
+
hint-based colorization methods can be compared without random-seed luck.
|
|
58
|
+
- **Hint-AUC.** One number that scores a model over the *whole* range of hint ratios, from no hints to fully hinted.
|
|
59
|
+
- **DetFill.** A pixel-space diffusion colorization model trained with these hints, with all checkpoints released.
|
|
60
|
+
- **Reproducible.** Tables are rebuilt from released metric files, every experiment can be re-run on example images
|
|
61
|
+
with one command, and the paper's key figure is reproduced end-to-end by a single script.
|
|
62
|
+
|
|
63
|
+
## News
|
|
64
|
+
|
|
65
|
+
- **2026-09** — Code, checkpoints, data and the full reproduction package are public. The paper is accepted at IEEE TVCG.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install git+https://github.com/MADONOKOUKI/DetFill-with-DHT.git
|
|
71
|
+
# with the perceptual metrics (LPIPS / OpenCLIP / DINOv2 / DreamSim):
|
|
72
|
+
pip install "hintauc[perceptual] @ git+https://github.com/MADONOKOUKI/DetFill-with-DHT.git"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For training or inference with DetFill, or for reproducing the paper, use the conda environment
|
|
76
|
+
`replicability/environment.yml` (Python 3.9, PyTorch 2.5.1, CUDA 12.4; it also runs on CPU).
|
|
77
|
+
|
|
78
|
+
## Quick start
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
import hintauc
|
|
82
|
+
|
|
83
|
+
hints = hintauc.generate_hints("illustration.png", size=64) # image -> deterministic hints
|
|
84
|
+
color, mask = hints.at_ratio(0.10, hint_type="scribble") # hints of the largest 10 % of the regions
|
|
85
|
+
hints.save("out/illustration") # files in the DetFill data layout
|
|
86
|
+
|
|
87
|
+
evaluator = hintauc.Evaluator(metrics=("psnr", "lpips", "dreamsim"))
|
|
88
|
+
print(evaluator("colorized.png", "ground_truth.png")) # the paper's metrics
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Command line: `hintauc generate image.png --ratio 0.1` and `hintauc eval pred_dir gt_dir --metrics mse psnr ssim`.
|
|
92
|
+
DetFill inference over the hint-ratio grid: `cd detfill && GPU=0 bash run_inference.sh scribble`
|
|
93
|
+
(data layout and options in [detfill/README.md](detfill/README.md)).
|
|
94
|
+
|
|
95
|
+
## Model zoo
|
|
96
|
+
|
|
97
|
+
| Model | Hints | Base channels | Trained on | Download |
|
|
98
|
+
|---|---|---|---|---|
|
|
99
|
+
| DetFill (paper) | scribble | 96 | Danbooru2021 | [v1.0](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.0) `detfill_scribble_illust_200ep.pth` (1.08 GB) |
|
|
100
|
+
| DetFill (paper) | dot | 64 | Danbooru2021 | [v1.0](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.0) `detfill_dot_illust_200ep.pth` (0.48 GB) |
|
|
101
|
+
| DetFill, DanbooRegion hints | scribble | 96 | Danbooru2021 | [v1.1](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.1) |
|
|
102
|
+
| DetFill, SLIC hints | scribble | 96 | Danbooru2021 | [v1.1](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.1) |
|
|
103
|
+
| DetFill, natural images | scribble / dot | 96 | ImageNet subset | [v1.2](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.2) |
|
|
104
|
+
| Diffusart retrained with our hints | scribble / dot | — | Danbooru2021 | [v1.2](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.2) |
|
|
105
|
+
| DetFill, channel ablation | scribble | 32 / 64 | Danbooru2021 | [legacy-2024](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/legacy-2024) |
|
|
106
|
+
| DetFill, 2024 submission | scribble / dot | 64 | Danbooru2021 / ImageNet | [legacy-2024](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/legacy-2024) |
|
|
107
|
+
|
|
108
|
+
Data: the stored hint maps of the 3,000 test images (v1.0), the test-split line art from the three extractors, the
|
|
109
|
+
alternative-segmenter hint maps, the example bundle and the user-study stimuli (v1.3). Every file with size and
|
|
110
|
+
SHA-256: [checkpoints/README.md](checkpoints/README.md).
|
|
111
|
+
|
|
112
|
+
## Reproducing the paper
|
|
113
|
+
|
|
114
|
+
All scripts fetch what they need from the releases (SHA-256 verified). Requirements: Linux, Miniconda, ~10 GB of disk,
|
|
115
|
+
an NVIDIA GPU (CPU works but is slow).
|
|
116
|
+
|
|
117
|
+
| Goal | Command (no arguments) | Time |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| **Fig. 9** end to end (the Replicability-Stamp script) | `bash replicability/run.sh` | GPU ≈ 3 min, CPU ≈ 30 min |
|
|
120
|
+
| **Every table** rebuilt from the released metric files | `python reproduce/scripts/A1_tables_from_released_metrics.py` (322/324 cells match)<br>`python reproduce/scripts/A2_userstudy_glmm.py` (all values match) | < 2 min, CPU |
|
|
121
|
+
| **Every experiment** re-run on 12 example illustrations | `bash reproduce/examples/run_examples.sh` | smoke ≈ 5 min, default ≈ 1 h, full = hours |
|
|
122
|
+
| **A whole table row** on the 3,000 test images | `DATA_ROOT=… bash reproduce/scripts/run_hauc_pipeline.sh` | ≈ 14 GPU-h per row |
|
|
123
|
+
| **Training** from scratch | `bash reproduce/scripts/B9_train_detfill.sh` | days, 10 GPUs |
|
|
124
|
+
|
|
125
|
+
Results are compared automatically with the paper's numbers, the paper's archived images of the same examples and the
|
|
126
|
+
authors' reference run. Guide, coverage table and the list of what is bit-exact and what is not:
|
|
127
|
+
[reproduce/README.md](reproduce/README.md). Background on every component: [detail_explanation.md](detail_explanation.md).
|
|
128
|
+
|
|
129
|
+
## Added features (since the paper) for improving our library
|
|
130
|
+
|
|
131
|
+
- `hintauc` pip library and command line (hint generation, the seven metrics, Hint-AUC).
|
|
132
|
+
- Dependency-free, bit-exact longest path `path_method="geodesic"`; dot options `medoid` / `mean` / `nearest_mean`;
|
|
133
|
+
region tie-breaking `tie_break="stable"`.
|
|
134
|
+
- Protocol switch `hint_order: area | label` (Table II vs. Table III) in the DetFill loader; training option `include_full_hint`.
|
|
135
|
+
- CPU inference, a flat user-configurable data layout, deterministic region-id colours, other segmenters in the generator.
|
|
136
|
+
- The replicability script, the reproduction package and the additional releases (v1.1–v1.3, legacy-2024).
|
|
137
|
+
|
|
138
|
+
Small documented differences between the paper's text and the released code/data are listed in
|
|
139
|
+
[detail_explanation.md](detail_explanation.md#changes-relative-to-the-paper).
|
|
140
|
+
|
|
141
|
+
## Repository structure
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
replicability/ one-command reproduction of Fig. 9
|
|
145
|
+
reproduce/ reproduction package: scripts/, examples/, expected/ (released metrics), data/, paper_experiments/
|
|
146
|
+
hintauc/ the library: hints.py, metrics.py, auc.py, cli.py
|
|
147
|
+
detfill/ the DetFill model (BBDM fork): training, inference, configs
|
|
148
|
+
hint_generation/ original research scripts behind the library
|
|
149
|
+
evaluation/ original evaluation scripts
|
|
150
|
+
checkpoints/ inventory of all released files with hashes
|
|
151
|
+
assets/ images for this page; representative image for the Replicability Stamp
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Citation
|
|
155
|
+
|
|
156
|
+
```bibtex
|
|
157
|
+
@article{madono2026hintauc,
|
|
158
|
+
title = {Hint-AUC: Deterministic Region-based Hint Generation for Line Art Colorization Evaluation},
|
|
159
|
+
author = {Madono, Koki and Mingcheng, Yuan and Simo-Serra, Edgar},
|
|
160
|
+
journal = {IEEE Transactions on Visualization and Computer Graphics},
|
|
161
|
+
year = {2026},
|
|
162
|
+
doi = {10.1109/TVCG.2026.3738401}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License and acknowledgements
|
|
167
|
+
|
|
168
|
+
MIT License; third-party components in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). `detfill/` is built on
|
|
169
|
+
[BBDM](https://github.com/xuekt98/BBDM) (MIT). Released data files are derived from Danbooru2021 illustrations and are
|
|
170
|
+
provided for non-commercial research use only.
|
hintauc-0.1.0/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# DetFill-with-DHT: Deterministic Hints and Hint-AUC for Line Art Colorization
|
|
2
|
+
|
|
3
|
+
[](https://doi.org/10.1109/TVCG.2026.3738401)
|
|
4
|
+
[](https://doi.org/10.1109/TVCG.2026.3738401)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](#installation)
|
|
7
|
+
[](#installation)
|
|
8
|
+
[](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases)
|
|
9
|
+
|
|
10
|
+
Official implementation of **"Hint-AUC: Deterministic Region-based Hint Generation for Line Art Colorization Evaluation"**
|
|
11
|
+
(Koki Madono, Yuan Mingcheng, Edgar Simo-Serra — IEEE Transactions on Visualization and Computer Graphics, 2026).
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Highlights
|
|
16
|
+
|
|
17
|
+
- **Deterministic hints (DHT).** The same illustration always yields the same scribble and dot hints, so
|
|
18
|
+
hint-based colorization methods can be compared without random-seed luck.
|
|
19
|
+
- **Hint-AUC.** One number that scores a model over the *whole* range of hint ratios, from no hints to fully hinted.
|
|
20
|
+
- **DetFill.** A pixel-space diffusion colorization model trained with these hints, with all checkpoints released.
|
|
21
|
+
- **Reproducible.** Tables are rebuilt from released metric files, every experiment can be re-run on example images
|
|
22
|
+
with one command, and the paper's key figure is reproduced end-to-end by a single script.
|
|
23
|
+
|
|
24
|
+
## News
|
|
25
|
+
|
|
26
|
+
- **2026-09** — Code, checkpoints, data and the full reproduction package are public. The paper is accepted at IEEE TVCG.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install git+https://github.com/MADONOKOUKI/DetFill-with-DHT.git
|
|
32
|
+
# with the perceptual metrics (LPIPS / OpenCLIP / DINOv2 / DreamSim):
|
|
33
|
+
pip install "hintauc[perceptual] @ git+https://github.com/MADONOKOUKI/DetFill-with-DHT.git"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For training or inference with DetFill, or for reproducing the paper, use the conda environment
|
|
37
|
+
`replicability/environment.yml` (Python 3.9, PyTorch 2.5.1, CUDA 12.4; it also runs on CPU).
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import hintauc
|
|
43
|
+
|
|
44
|
+
hints = hintauc.generate_hints("illustration.png", size=64) # image -> deterministic hints
|
|
45
|
+
color, mask = hints.at_ratio(0.10, hint_type="scribble") # hints of the largest 10 % of the regions
|
|
46
|
+
hints.save("out/illustration") # files in the DetFill data layout
|
|
47
|
+
|
|
48
|
+
evaluator = hintauc.Evaluator(metrics=("psnr", "lpips", "dreamsim"))
|
|
49
|
+
print(evaluator("colorized.png", "ground_truth.png")) # the paper's metrics
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Command line: `hintauc generate image.png --ratio 0.1` and `hintauc eval pred_dir gt_dir --metrics mse psnr ssim`.
|
|
53
|
+
DetFill inference over the hint-ratio grid: `cd detfill && GPU=0 bash run_inference.sh scribble`
|
|
54
|
+
(data layout and options in [detfill/README.md](detfill/README.md)).
|
|
55
|
+
|
|
56
|
+
## Model zoo
|
|
57
|
+
|
|
58
|
+
| Model | Hints | Base channels | Trained on | Download |
|
|
59
|
+
|---|---|---|---|---|
|
|
60
|
+
| DetFill (paper) | scribble | 96 | Danbooru2021 | [v1.0](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.0) `detfill_scribble_illust_200ep.pth` (1.08 GB) |
|
|
61
|
+
| DetFill (paper) | dot | 64 | Danbooru2021 | [v1.0](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.0) `detfill_dot_illust_200ep.pth` (0.48 GB) |
|
|
62
|
+
| DetFill, DanbooRegion hints | scribble | 96 | Danbooru2021 | [v1.1](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.1) |
|
|
63
|
+
| DetFill, SLIC hints | scribble | 96 | Danbooru2021 | [v1.1](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.1) |
|
|
64
|
+
| DetFill, natural images | scribble / dot | 96 | ImageNet subset | [v1.2](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.2) |
|
|
65
|
+
| Diffusart retrained with our hints | scribble / dot | — | Danbooru2021 | [v1.2](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/v1.2) |
|
|
66
|
+
| DetFill, channel ablation | scribble | 32 / 64 | Danbooru2021 | [legacy-2024](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/legacy-2024) |
|
|
67
|
+
| DetFill, 2024 submission | scribble / dot | 64 | Danbooru2021 / ImageNet | [legacy-2024](https://github.com/MADONOKOUKI/DetFill-with-DHT/releases/tag/legacy-2024) |
|
|
68
|
+
|
|
69
|
+
Data: the stored hint maps of the 3,000 test images (v1.0), the test-split line art from the three extractors, the
|
|
70
|
+
alternative-segmenter hint maps, the example bundle and the user-study stimuli (v1.3). Every file with size and
|
|
71
|
+
SHA-256: [checkpoints/README.md](checkpoints/README.md).
|
|
72
|
+
|
|
73
|
+
## Reproducing the paper
|
|
74
|
+
|
|
75
|
+
All scripts fetch what they need from the releases (SHA-256 verified). Requirements: Linux, Miniconda, ~10 GB of disk,
|
|
76
|
+
an NVIDIA GPU (CPU works but is slow).
|
|
77
|
+
|
|
78
|
+
| Goal | Command (no arguments) | Time |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| **Fig. 9** end to end (the Replicability-Stamp script) | `bash replicability/run.sh` | GPU ≈ 3 min, CPU ≈ 30 min |
|
|
81
|
+
| **Every table** rebuilt from the released metric files | `python reproduce/scripts/A1_tables_from_released_metrics.py` (322/324 cells match)<br>`python reproduce/scripts/A2_userstudy_glmm.py` (all values match) | < 2 min, CPU |
|
|
82
|
+
| **Every experiment** re-run on 12 example illustrations | `bash reproduce/examples/run_examples.sh` | smoke ≈ 5 min, default ≈ 1 h, full = hours |
|
|
83
|
+
| **A whole table row** on the 3,000 test images | `DATA_ROOT=… bash reproduce/scripts/run_hauc_pipeline.sh` | ≈ 14 GPU-h per row |
|
|
84
|
+
| **Training** from scratch | `bash reproduce/scripts/B9_train_detfill.sh` | days, 10 GPUs |
|
|
85
|
+
|
|
86
|
+
Results are compared automatically with the paper's numbers, the paper's archived images of the same examples and the
|
|
87
|
+
authors' reference run. Guide, coverage table and the list of what is bit-exact and what is not:
|
|
88
|
+
[reproduce/README.md](reproduce/README.md). Background on every component: [detail_explanation.md](detail_explanation.md).
|
|
89
|
+
|
|
90
|
+
## Added features (since the paper) for improving our library
|
|
91
|
+
|
|
92
|
+
- `hintauc` pip library and command line (hint generation, the seven metrics, Hint-AUC).
|
|
93
|
+
- Dependency-free, bit-exact longest path `path_method="geodesic"`; dot options `medoid` / `mean` / `nearest_mean`;
|
|
94
|
+
region tie-breaking `tie_break="stable"`.
|
|
95
|
+
- Protocol switch `hint_order: area | label` (Table II vs. Table III) in the DetFill loader; training option `include_full_hint`.
|
|
96
|
+
- CPU inference, a flat user-configurable data layout, deterministic region-id colours, other segmenters in the generator.
|
|
97
|
+
- The replicability script, the reproduction package and the additional releases (v1.1–v1.3, legacy-2024).
|
|
98
|
+
|
|
99
|
+
Small documented differences between the paper's text and the released code/data are listed in
|
|
100
|
+
[detail_explanation.md](detail_explanation.md#changes-relative-to-the-paper).
|
|
101
|
+
|
|
102
|
+
## Repository structure
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
replicability/ one-command reproduction of Fig. 9
|
|
106
|
+
reproduce/ reproduction package: scripts/, examples/, expected/ (released metrics), data/, paper_experiments/
|
|
107
|
+
hintauc/ the library: hints.py, metrics.py, auc.py, cli.py
|
|
108
|
+
detfill/ the DetFill model (BBDM fork): training, inference, configs
|
|
109
|
+
hint_generation/ original research scripts behind the library
|
|
110
|
+
evaluation/ original evaluation scripts
|
|
111
|
+
checkpoints/ inventory of all released files with hashes
|
|
112
|
+
assets/ images for this page; representative image for the Replicability Stamp
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Citation
|
|
116
|
+
|
|
117
|
+
```bibtex
|
|
118
|
+
@article{madono2026hintauc,
|
|
119
|
+
title = {Hint-AUC: Deterministic Region-based Hint Generation for Line Art Colorization Evaluation},
|
|
120
|
+
author = {Madono, Koki and Mingcheng, Yuan and Simo-Serra, Edgar},
|
|
121
|
+
journal = {IEEE Transactions on Visualization and Computer Graphics},
|
|
122
|
+
year = {2026},
|
|
123
|
+
doi = {10.1109/TVCG.2026.3738401}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## License and acknowledgements
|
|
128
|
+
|
|
129
|
+
MIT License; third-party components in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). `detfill/` is built on
|
|
130
|
+
[BBDM](https://github.com/xuekt98/BBDM) (MIT). Released data files are derived from Danbooru2021 illustrations and are
|
|
131
|
+
provided for non-commercial research use only.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""hintauc — Deterministic region-based hint generation (DHT) and Hint-AUC
|
|
2
|
+
evaluation for line-art colorization.
|
|
3
|
+
|
|
4
|
+
Library form of the method proposed in
|
|
5
|
+
"Hint-AUC: Deterministic Region-based Hint Generation for Line Art
|
|
6
|
+
Colorization Evaluation" (Madono, Mingcheng, Simo-Serra).
|
|
7
|
+
|
|
8
|
+
Quick start
|
|
9
|
+
-----------
|
|
10
|
+
>>> import hintauc
|
|
11
|
+
>>> hints = hintauc.generate_hints("illustration.png") # 1. hints
|
|
12
|
+
>>> color, mask = hints.at_ratio(0.10, hint_type="scribble") # top-10% regions
|
|
13
|
+
>>> hints.save("out/illustration") # canonical files
|
|
14
|
+
|
|
15
|
+
>>> ev = hintauc.Evaluator(metrics=("mse", "psnr", "ssim", "lpips"))
|
|
16
|
+
>>> scores = ev("colorized.png", "ground_truth.png") # 2. evaluation
|
|
17
|
+
>>> auc = hintauc.hint_auc({0.0: 0.44, 0.01: 0.33, 0.03: 0.27,
|
|
18
|
+
... 0.05: 0.24, 0.10: 0.20, 0.25: 0.15,
|
|
19
|
+
... 0.50: 0.12, 1.00: 0.10})
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from .longest_path import geodesic_longest_path
|
|
23
|
+
from .hints import (
|
|
24
|
+
DEFAULT_HINT_SIZE,
|
|
25
|
+
FELZENSZWALB_PARAMS,
|
|
26
|
+
HintResult,
|
|
27
|
+
generate_hints,
|
|
28
|
+
region_ids,
|
|
29
|
+
segment_regions,
|
|
30
|
+
)
|
|
31
|
+
from .metrics import (
|
|
32
|
+
DEFAULT_METRICS,
|
|
33
|
+
LOWER_IS_BETTER,
|
|
34
|
+
Evaluator,
|
|
35
|
+
evaluate_dirs,
|
|
36
|
+
evaluate_pair,
|
|
37
|
+
)
|
|
38
|
+
from .auc import (
|
|
39
|
+
DEFAULT_ALPHAS,
|
|
40
|
+
evaluate_hint_curve,
|
|
41
|
+
hint_auc,
|
|
42
|
+
hint_auc_table,
|
|
43
|
+
trapz,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__version__ = "0.1.0"
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"DEFAULT_ALPHAS",
|
|
50
|
+
"DEFAULT_HINT_SIZE",
|
|
51
|
+
"DEFAULT_METRICS",
|
|
52
|
+
"FELZENSZWALB_PARAMS",
|
|
53
|
+
"LOWER_IS_BETTER",
|
|
54
|
+
"Evaluator",
|
|
55
|
+
"HintResult",
|
|
56
|
+
"evaluate_dirs",
|
|
57
|
+
"evaluate_hint_curve",
|
|
58
|
+
"evaluate_pair",
|
|
59
|
+
"generate_hints",
|
|
60
|
+
"hint_auc",
|
|
61
|
+
"hint_auc_table",
|
|
62
|
+
"region_ids",
|
|
63
|
+
"segment_regions",
|
|
64
|
+
"trapz",
|
|
65
|
+
"__version__",
|
|
66
|
+
]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Hint-AUC: integrate per-ratio metric scores over the hint-ratio grid.
|
|
2
|
+
|
|
3
|
+
Port of ``evaluation/calc_hint_auc.py``: plain trapezoidal integration
|
|
4
|
+
of metric(alpha) over alpha in [0, 1] (the alpha range has length 1, so the
|
|
5
|
+
integral equals the range-normalized value).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Dict, Mapping, Optional, Sequence
|
|
11
|
+
|
|
12
|
+
#: the paper's front-loaded hint-ratio grid
|
|
13
|
+
DEFAULT_ALPHAS = (0.00, 0.01, 0.03, 0.05, 0.10, 0.25, 0.50, 1.00)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def trapz(xs: Sequence[float], ys: Sequence[float]) -> float:
|
|
17
|
+
"""Trapezoidal rule (port of calc_hint_auc.trapz)."""
|
|
18
|
+
if len(xs) != len(ys) or len(xs) < 2:
|
|
19
|
+
raise ValueError("need >= 2 (x, y) points with matching lengths")
|
|
20
|
+
area = 0.0
|
|
21
|
+
for i in range(1, len(xs)):
|
|
22
|
+
area += (xs[i] - xs[i - 1]) * (ys[i] + ys[i - 1]) / 2.0
|
|
23
|
+
return area
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def hint_auc(scores_by_alpha: Mapping[float, float]) -> float:
|
|
27
|
+
"""Hint-AUC of one metric from ``{alpha: score}``.
|
|
28
|
+
|
|
29
|
+
>>> hint_auc({0.0: 0.44, 0.01: 0.33, ..., 1.0: 0.10})
|
|
30
|
+
"""
|
|
31
|
+
xs = sorted(scores_by_alpha)
|
|
32
|
+
ys = [scores_by_alpha[a] for a in xs]
|
|
33
|
+
return trapz(xs, ys)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def hint_auc_table(
|
|
37
|
+
metrics_by_alpha: Mapping[float, Mapping[str, float]],
|
|
38
|
+
metrics: Optional[Sequence[str]] = None,
|
|
39
|
+
) -> Dict[str, float]:
|
|
40
|
+
"""Hint-AUC per metric from ``{alpha: {metric: score}}``."""
|
|
41
|
+
alphas = sorted(metrics_by_alpha)
|
|
42
|
+
if metrics is None:
|
|
43
|
+
metrics = sorted({m for a in alphas for m in metrics_by_alpha[a]})
|
|
44
|
+
out = {}
|
|
45
|
+
for m in metrics:
|
|
46
|
+
out[m] = hint_auc({a: metrics_by_alpha[a][m] for a in alphas})
|
|
47
|
+
return out
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def evaluate_hint_curve(
|
|
51
|
+
preds_by_alpha: Mapping[float, str],
|
|
52
|
+
gt_dir: str,
|
|
53
|
+
evaluator=None,
|
|
54
|
+
metrics: Sequence[str] = ("mse", "psnr", "ssim"),
|
|
55
|
+
pairing: str = "sorted",
|
|
56
|
+
limit: int = 0,
|
|
57
|
+
) -> Dict[str, object]:
|
|
58
|
+
"""End-to-end Hint-AUC over per-ratio prediction directories.
|
|
59
|
+
|
|
60
|
+
``preds_by_alpha`` maps each hint ratio alpha to a directory of the
|
|
61
|
+
colorizations produced with hints at that ratio (paper grid:
|
|
62
|
+
:data:`DEFAULT_ALPHAS`). Returns per-alpha mean metrics and the
|
|
63
|
+
Hint-AUC of every metric.
|
|
64
|
+
"""
|
|
65
|
+
from .metrics import Evaluator, evaluate_dirs
|
|
66
|
+
|
|
67
|
+
ev = evaluator or Evaluator(metrics=metrics)
|
|
68
|
+
per_alpha: Dict[float, Dict[str, float]] = {}
|
|
69
|
+
for alpha in sorted(preds_by_alpha):
|
|
70
|
+
per_alpha[alpha] = evaluate_dirs(
|
|
71
|
+
preds_by_alpha[alpha], gt_dir, evaluator=ev,
|
|
72
|
+
pairing=pairing, limit=limit)
|
|
73
|
+
return {"per_alpha": per_alpha, "hint_auc": hint_auc_table(per_alpha)}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Command-line interface: ``hintauc generate`` / ``hintauc eval``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main(argv=None):
|
|
12
|
+
p = argparse.ArgumentParser(
|
|
13
|
+
prog="hintauc",
|
|
14
|
+
description="Deterministic hint generation (DHT) and Hint-AUC evaluation")
|
|
15
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
16
|
+
|
|
17
|
+
g = sub.add_parser("generate", help="generate deterministic hints for an image")
|
|
18
|
+
g.add_argument("image", help="input image (ground-truth color image)")
|
|
19
|
+
g.add_argument("-o", "--out_stem", default=None,
|
|
20
|
+
help="output stem (default: <image without extension>)")
|
|
21
|
+
g.add_argument("--size", type=int, default=64, help="hint resolution (default 64)")
|
|
22
|
+
g.add_argument("--segmenter", default="felzenszwalb",
|
|
23
|
+
choices=["felzenszwalb", "slic", "quickshift"])
|
|
24
|
+
g.add_argument("--ratio", type=float, default=None,
|
|
25
|
+
help="also write hints masked to this hint ratio (0..1)")
|
|
26
|
+
g.add_argument("--hint_type", default="scribble", choices=["scribble", "dot"])
|
|
27
|
+
g.add_argument("--path_method", default="filfinder", choices=["filfinder", "geodesic"],
|
|
28
|
+
help="longest-path extraction: 'filfinder' (paper) or 'geodesic' (dependency-free, deterministic)")
|
|
29
|
+
g.add_argument("--tie_break", default="default", choices=["default", "stable"],
|
|
30
|
+
help="order of equal-area regions when selecting by --ratio: 'default' (paper: NumPy argsort) or 'stable' (ascending label; version-independent)")
|
|
31
|
+
g.add_argument("--dot_method", default="medoid", choices=["medoid", "mean", "nearest_mean"],
|
|
32
|
+
help="dot placement: 'mean' (paper: truncated mean of the path, may leave the region) or 'medoid' (in-region path pixel nearest to the mean)")
|
|
33
|
+
g.add_argument("-v", "--verbose", action="store_true")
|
|
34
|
+
|
|
35
|
+
e = sub.add_parser("eval", help="evaluate colorization(s) against ground truth")
|
|
36
|
+
e.add_argument("pred", help="predicted image or directory")
|
|
37
|
+
e.add_argument("gt", help="ground-truth image or directory")
|
|
38
|
+
e.add_argument("--metrics", nargs="+",
|
|
39
|
+
default=["mse", "psnr", "ssim"],
|
|
40
|
+
help="subset of: mse psnr ssim lpips openclip dino dreamsim")
|
|
41
|
+
e.add_argument("--pairing", default="sorted", choices=["sorted", "name"])
|
|
42
|
+
e.add_argument("--resize", type=int, default=256)
|
|
43
|
+
e.add_argument("--device", default=None)
|
|
44
|
+
e.add_argument("--limit", type=int, default=0)
|
|
45
|
+
|
|
46
|
+
args = p.parse_args(argv)
|
|
47
|
+
|
|
48
|
+
if args.cmd == "generate":
|
|
49
|
+
from .hints import generate_hints
|
|
50
|
+
import cv2
|
|
51
|
+
|
|
52
|
+
res = generate_hints(args.image, size=args.size,
|
|
53
|
+
segmenter=args.segmenter, verbose=args.verbose,
|
|
54
|
+
path_method=args.path_method, dot_method=args.dot_method)
|
|
55
|
+
stem = args.out_stem or os.path.splitext(args.image)[0]
|
|
56
|
+
paths = res.save(stem)
|
|
57
|
+
if args.ratio is not None:
|
|
58
|
+
color, mask = res.at_ratio(args.ratio, hint_type=args.hint_type, tie_break=args.tie_break)
|
|
59
|
+
pct = int(round(args.ratio * 100))
|
|
60
|
+
cv2.imwrite(f"{stem}_{args.hint_type}_col{res.size}_r{pct}.png", color)
|
|
61
|
+
cv2.imwrite(f"{stem}_{args.hint_type}_mask{res.size}_r{pct}.png", mask)
|
|
62
|
+
paths[f"ratio_{pct}"] = f"{stem}_{args.hint_type}_*{res.size}_r{pct}.png"
|
|
63
|
+
info = {"n_regions": res.n_regions(), "failed_regions": res.failed_regions,
|
|
64
|
+
"path_method": res.path_method, "dot_method": res.dot_method, "outputs": paths}
|
|
65
|
+
print(json.dumps(info, indent=1))
|
|
66
|
+
return 0
|
|
67
|
+
|
|
68
|
+
if args.cmd == "eval":
|
|
69
|
+
from .metrics import Evaluator, evaluate_dirs
|
|
70
|
+
|
|
71
|
+
ev = Evaluator(metrics=args.metrics, device=args.device, resize=args.resize)
|
|
72
|
+
if os.path.isdir(args.pred):
|
|
73
|
+
scores = evaluate_dirs(args.pred, args.gt, evaluator=ev,
|
|
74
|
+
pairing=args.pairing, limit=args.limit)
|
|
75
|
+
else:
|
|
76
|
+
scores = ev(args.pred, args.gt)
|
|
77
|
+
print(json.dumps(scores, indent=1))
|
|
78
|
+
return 0
|
|
79
|
+
|
|
80
|
+
return 1
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
sys.exit(main())
|