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:
@@ -105,6 +105,13 @@ export interface DenoiseStats {
|
||||
timings: StageTimings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where a run currently is. The base stage is the expensive one (SCUNet runs it
|
||||
* tile by tile); the rest are seconds at most, but naming them beats a dead
|
||||
* spinner while the base is between tiles.
|
||||
*/
|
||||
export type DenoiseStage = 'analyse' | 'base' | 'gate' | 'render';
|
||||
|
||||
export interface DenoiseOutput {
|
||||
rgb: Uint8Array;
|
||||
/** Luma of the denoised base, before detail re-injection, for inspection. */
|
||||
@@ -184,6 +191,7 @@ export async function denoiseRgb(
|
||||
image: RgbImage,
|
||||
options: Partial<DenoiseOptions>,
|
||||
runBase: BaseDenoiser,
|
||||
onStage?: (stage: DenoiseStage) => void,
|
||||
): Promise<DenoiseOutput> {
|
||||
const opts: DenoiseOptions = { ...DEFAULT_OPTIONS, ...options, gate: { ...DEFAULT_GATE, ...options.gate } };
|
||||
const started = now();
|
||||
@@ -193,6 +201,7 @@ export async function denoiseRgb(
|
||||
const { y, cb, cr } = toYcc(image);
|
||||
|
||||
let mark = now();
|
||||
onStage?.('analyse');
|
||||
const noise: NoiseModel = estimateNoise(y, width, height);
|
||||
const timings: StageTimings = {
|
||||
noise: now() - mark,
|
||||
@@ -231,6 +240,7 @@ export async function denoiseRgb(
|
||||
const decimatedSigma =
|
||||
backscale > 1.001 ? (prefilterWidth - 1 / 3) / (prefilterWidth * prefilterWidth) : 1;
|
||||
const baseSigma = noise.sigmaAt(110) * decimatedSigma;
|
||||
onStage?.('base');
|
||||
const baseOut = await runBase(baseInput, baseSigma);
|
||||
const baseUp = toYcc(upsampleBase(baseOut, width, height));
|
||||
timings.base = now() - mark;
|
||||
@@ -266,6 +276,7 @@ export async function denoiseRgb(
|
||||
timings.structure = now() - mark;
|
||||
|
||||
mark = now();
|
||||
onStage?.('gate');
|
||||
let gate = detailGate(detail, width, height, sigmaMap, coherence, opts.gate);
|
||||
|
||||
// Second, coarser band: `smooth2 - smooth6` is a band-pass around 3-8 px. It
|
||||
@@ -292,6 +303,7 @@ export async function denoiseRgb(
|
||||
const autoGate = opts.cleanSigma > 0 ? smoothstep(0.8, opts.cleanSigma, noise.global) : 1;
|
||||
const amount = clamp01(opts.amount) * autoGate;
|
||||
|
||||
onStage?.('render');
|
||||
const outY = new Float32Array(pixels);
|
||||
const outCb = new Float32Array(pixels);
|
||||
const outCr = new Float32Array(pixels);
|
||||
|
||||
Reference in New Issue
Block a user