Offer SCUNet and NLM alongside the guided denoise

The AI denoise panel now picks between three bases: the existing guided
filter, non-local means and a learned SCUNet model run through
onnxruntime-node on overlapping tiles. The base is part of the render key, so
each model keeps its own cached render and switching back is instant, and jobs
report stage and tile progress instead of a bare spinner.

onnxruntime-node is pinned to 1.23.0, the last release that ships both macOS
architectures, and every Docker and desktop install skips its CUDA download
because only the CPU binaries in the package are used. The SCUNet weights and
ONNX Runtime are added to the third-party notices, the deb copyright file and
the README's denoise, API and redistribution sections.
This commit is contained in:
2026-12-01 04:03:53 +00:00
parent b34d34dacb
commit f7942d0bd0
26 changed files with 945 additions and 161 deletions
+17 -4
View File
@@ -10,10 +10,10 @@ import { parentPort, workerData } from 'node:worker_threads';
import fs from 'node:fs/promises';
import sharp from 'sharp';
import { denoiseRgb } from './denoise/rgbPipeline.ts';
import { guidedDenoiser } from './denoise/standin.ts';
import { createBaseDenoiser } from './denoise/baseDenoiser.ts';
try {
const { sourcePath, outPath } = workerData;
const { sourcePath, outPath, base = 'guided' } = workerData;
const buffer = await fs.readFile(sourcePath);
const { data, info } = await sharp(buffer)
.rotate()
@@ -37,8 +37,21 @@ try {
const started = performance.now();
// Always full strength: the Amount slider blends on the client, so one render
// serves every setting and the cache key does not move with the slider.
const out = await denoiseRgb({ rgb, width, height }, { amount: 1 }, guidedDenoiser());
// serves every setting and the cache key does not move with the slider. The
// base denoiser (guided / nlm / scunet) is chosen by the request; the cache
// key already folds it in, so a different model is a different render.
//
// Progress is the only window the panel has into a 95 s SCUNet run, so both
// the stage boundaries and the tile counter are forwarded to the job.
const report = (progress) => parentPort?.postMessage({ type: 'progress', progress });
const out = await denoiseRgb(
{ rgb, width, height },
{ amount: 1 },
createBaseDenoiser(base, (tiles) =>
report({ stage: 'base', done: tiles.done, total: tiles.total }),
),
(stage) => report({ stage }),
);
// 4:4:4 so the chroma work is not immediately thrown away by the encoder.
const jpeg = await sharp(Buffer.from(out.rgb), { raw: { width, height, channels: 3 } })
.jpeg({ quality: 95, chromaSubsampling: '4:4:4' })