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:
@@ -0,0 +1,57 @@
|
||||
import type { DenoiseProgress } from './api';
|
||||
import type { Edits } from '../types';
|
||||
|
||||
/** One of the base denoisers the AI denoise panel can render with. */
|
||||
export type DenoiseModel = Edits['aiDenoise']['model'];
|
||||
export type AiDenoise = Edits['aiDenoise'];
|
||||
|
||||
/**
|
||||
* The models in panel order. `guided` is the default and the fast one; the two
|
||||
* learned/classical alternates are additive, so the list is also the contract
|
||||
* the picker and the help text are built from.
|
||||
*/
|
||||
export const DENOISE_MODELS: { value: DenoiseModel; label: string; title: string }[] = [
|
||||
{ value: 'guided', label: 'Guided', title: 'Guided filter — fast, keeps the most fine texture' },
|
||||
{ value: 'scunet', label: 'SCUNet', title: 'SCUNet — learned model, removes the most grain, smooths more' },
|
||||
{ value: 'nlm', label: 'NLM', title: 'Non-local means — slower, between Guided and SCUNet' },
|
||||
];
|
||||
|
||||
export function denoiseModelLabel(model: DenoiseModel): string {
|
||||
return DENOISE_MODELS.find((option) => option.value === model)?.label ?? 'Guided';
|
||||
}
|
||||
|
||||
/** Human names for the pipeline stages the worker reports. */
|
||||
const STAGE_LABELS: Record<DenoiseProgress['stage'], string> = {
|
||||
analyse: 'reading the noise profile',
|
||||
base: 'denoising',
|
||||
gate: 'mapping detail',
|
||||
render: 'blending the result',
|
||||
};
|
||||
|
||||
/**
|
||||
* One line describing a running render. The stage names and the tile counter
|
||||
* come from the worker, so this is real progress rather than a spinner -- the
|
||||
* elapsed time is only the fallback for the first second or two.
|
||||
*/
|
||||
export function denoiseProgressLabel(
|
||||
progress: DenoiseProgress | null | undefined,
|
||||
model: DenoiseModel,
|
||||
elapsedSeconds: number,
|
||||
): string {
|
||||
const seconds = Math.max(0, Math.round(elapsedSeconds));
|
||||
const stage = progress?.stage ? (STAGE_LABELS[progress.stage] ?? 'working') : 'starting';
|
||||
const tiles =
|
||||
progress?.stage === 'base' && progress.total
|
||||
? ` ${Math.min(progress.done ?? 0, progress.total)}/${progress.total} tiles`
|
||||
: '';
|
||||
return `Rendering with ${denoiseModelLabel(model)} · ${stage}${tiles} · ${seconds}s elapsed`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit a finished render to the edit. The cache key belongs to the base that
|
||||
* produced it, so the picker follows that base: a caller holding an older copy
|
||||
* of the edit cannot put the previous model back in front of a fresh key.
|
||||
*/
|
||||
export function withDenoiseRender(ai: AiDenoise, base: DenoiseModel, key: string): AiDenoise {
|
||||
return { ...ai, model: base, key };
|
||||
}
|
||||
Reference in New Issue
Block a user