Commit 3de731a
* feat(onnx): Real-ESRGAN texture upscaling — core + facade + CLI (#405)
ONNX-backed 2x/4x super-resolution, reusing the #404 ONNX infra (ENABLE_ONNX,
ModelDownloader, NCHW conversion).
- TextureUpscaler (Ogre-free, like PbrMapSynth): scale-aware overlapping-tile
upscale that composites results in OUTPUT space with a feathered seam blend.
Detects the scale factor from the model's output/input ratio at runtime
(validates the output tensor element count before copying). Reuses
PbrMapSynth::toNCHW / nchwToRgb.
- AIAssistManager: Map enum extended with UpscaleX2/UpscaleX4 (BSD-3
Real-ESRGAN models, downloaded on first use from the same HF repo);
upscaleTexture(srcPath, scale, overwrite) ensures+runs+caches, writes
<stem>_upscaled.png, emits upscaleStarted/Completed/Error. Sentry breadcrumb
ai.assist.upscale.
- CLI: `qtmesh material --texture low.png --upscale {2|4} [-o high.png]`
(cmdMaterialUpscale, delegates to the facade). ENABLE_ONNX-guarded.
Model: Real-ESRGAN x4plus / x2plus (BSD-3-Clause, xinntao), exported to ONNX
and hosted at fernandotonon/QtMeshEditor-models. Verified end-to-end: 256x256
→ 1024x1024 (4x) and 128 → 256 (2x), model auto-downloaded from HF; bad
factor / missing texture rejected with usage errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(#405): Real-ESRGAN upscaling — MCP + GUI + tests + docs
- MCP: upscale_texture tool (texture_path, scale 2/4, overwrite) → AIAssistManager.
- GUI: "Upscale 2× / 4×" buttons in the Material Editor Texture Properties panel
(ONNX-only), via MaterialEditorQML::upscaleCurrentTexture which relays the
facade's upscale signals.
- Tests: CLIPipeline upscale coverage (missing texture / bad factor / non-numeric
/ no-model-fails-clean, offline-guarded) + TextureUpscaler error-contract tests.
- scripts/export-realesrgan-onnx.py: one-time offline .pth→ONNX exporter (BSD-3
Real-ESRGAN x4plus/x2plus, pinned release assets). NOT shipped.
- docs: CLAUDE.md CLI line + architecture entry; refreshed the #404 hosting note
(models are now hosted on HF) + the QTMESH_PBR_NO_DOWNLOAD offline guard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(onnx): bundle ONNX Runtime SONAME symlinks so the packaged binary loads (#405)
scan-assets-qtmesh failed: the Linux .deb/Docker binary aborts with
"libonnxruntime.so.1: cannot open shared object file". Root cause (latent since
#404 turned ENABLE_ONNX on for the Linux release): the POST_BUILD copied only
the single RESOLVED versioned lib (libonnxruntime.so.1.20.1) next to the binary,
but the loader requests the SONAME (libonnxruntime.so.1), which wasn't shipped —
so `./bin/*.so*` packaging never included a name the binary could load.
- OnnxRuntime.cmake exposes QTMESH_ONNX_LIB_DIR.
- The app + UnitTests POST_BUILD now glob-copy every libonnxruntime.so* /
.dylib / .dll (versioned file + SONAME symlinks) next to the binary, so the
packaged .deb/Docker image resolves libonnxruntime.so.1 at runtime.
Verified on macOS: both libonnxruntime.1.20.1.dylib and libonnxruntime.dylib are
now copied next to the binary (previously only one).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(#405): address PR review — upscale robustness, threading, supply chain
CodeRabbit findings on the Real-ESRGAN work:
Major:
- Scale-aware cache: output is now <stem>_upscaled_x{2,4}.png so a cached 2×
result is never returned for a 4× request (and vice versa).
- GUI no longer freezes: upscaleCurrentTexture ensures the model on the GUI
thread (download needs an event loop), then runs the pure-CPU tiled inference
on a std::thread and marshals the result back via a queued invocation.
Added AIAssistManager::ensureUpscaleModel for the main-thread ensure step.
(CLI/MCP keep the synchronous path.)
- Preserve source alpha: cutout/opacity textures keep their alpha (upscaled
nearest-to-match and reapplied) instead of coming back fully opaque.
- Guard the output-canvas allocation: compute size in 64-bit, cap at 256 Mpx,
and catch std::bad_alloc so a huge input / bad scale fails cleanly instead of
overflowing int or terminating outside the Ort handler.
- CLI honors -o strictly: rename→copy fallback (cross-device), and return exit 1
if the requested output file can't be produced (was silently exit 0).
- Export scripts verify SHA-256 of each .pth before deserializing (.pth is a
code-execution boundary) — both realesrgan + pbrify scripts.
Minor:
- Validate the detected scale is a uniform integer factor on BOTH axes, and that
each tile returns exactly tw*scale × th*scale (else fail, not silent crop).
- CLAUDE.md: correct the stale "empty default" model-base-URL wording (now the
hosted HF repo).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(#405): upscale progress + cancel + download status + multithreading
The GUI gave no feedback during an upscale (a 2h run looked hung), and CPU
inference was pinned to a single core.
- TextureUpscaler: optional ProgressFn(done,total) reported per tile; returning
false cancels (error="cancelled"). SetIntraOpNumThreads now uses
hardware_concurrency-1 instead of 1 — a 256→1024 4× drops from ~2 min to ~7.5s
(~7 cores). (Scoped to upscaling; PbrMapSynth stays single-threaded — its maps
are small/fast.)
- MaterialEditorQML: upscaleCurrentTexture runs on a worker, emits
upscaleDownloading (first-run model fetch), upscaleProgress (per tile), and
upscaleCompleted/Error; cancelUpscale() sets a shared atomic the worker's
progress callback checks. Model-ensure stays on the GUI thread (download needs
an event loop).
- QML: status shows "Downloading upscale model…" / "Upscaling… tile X/Y", the
scale buttons disable mid-run, and a Cancel button is shown.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d3d7c7c commit 3de731a
18 files changed
Lines changed: 919 additions & 7 deletions
File tree
- qml
- scripts
- src
- tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
319 | 346 | | |
320 | 347 | | |
321 | 348 | | |
322 | 349 | | |
323 | 350 | | |
324 | 351 | | |
325 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
326 | 365 | | |
327 | 366 | | |
328 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
44 | 66 | | |
45 | 67 | | |
46 | 68 | | |
| |||
82 | 104 | | |
83 | 105 | | |
84 | 106 | | |
85 | | - | |
| 107 | + | |
86 | 108 | | |
87 | 109 | | |
88 | 110 | | |
89 | 111 | | |
| 112 | + | |
90 | 113 | | |
91 | 114 | | |
92 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
299 | 304 | | |
300 | 305 | | |
301 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
80 | 96 | | |
81 | 97 | | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
85 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
| |||
0 commit comments