onnx-web-upscale / src /lib /types.ts
notaneimu's picture
match colors, exposure, grain
44f343d
import type * as ort from "onnxruntime-web";
export type DownscaleAlgorithm = "lanczos" | "area" | "bicubic" | "nearest";
export interface ModelConfigEntry {
id: string;
name: string;
file: string;
scale?: number;
size?: number;
recommended?: boolean;
}
export interface AssetRecord {
name: string;
size: number;
type: string;
saved: boolean;
blob: Blob;
predefined?: boolean;
modelId?: string;
scale?: number;
}
export interface ImageInfo {
width: number;
height: number;
}
export interface ModelInputPreviewInfo extends ImageInfo {
sourceWidth: number;
sourceHeight: number;
resized: boolean;
fixed: boolean;
}
export interface RunPreview {
url: string;
width: number;
height: number;
}
export interface ResultInfo {
resolution: string;
size: string;
progress: string;
tiles: string;
speed: string;
totalTime: string;
}
export interface TensorSummary {
name: string;
type: string;
dims: Array<number | string>;
count: number;
min: number | null;
max: number | null;
mean: number | null;
sample: number[];
}
export interface CurrentRun {
createdAt: string;
modelName: string;
imageName: string;
durationMs: number;
inputSummary: Record<string, unknown>;
outputs: TensorSummary[];
primaryOutputName: string;
preview: RunPreview | null;
}
export interface InspectorControls {
selectedPredefinedModelId: string;
autoLoadModel: boolean;
provider: "webgpu" | "wasm" | "webgl";
tileSize: string;
tileBlendingEnabled: boolean;
seamBlendWidth: string;
seamCorrectionStrength: string;
width: string;
height: string;
outputScale: string;
preResizeAlgorithm: DownscaleAlgorithm;
outputScaleAlgorithm: DownscaleAlgorithm;
colorCorrectionEnabled: boolean;
colorCorrectionStrength: string;
colorCorrectionClip: string;
filmGrainEnabled: boolean;
filmGrainAmount: string;
filmGrainSize: string;
filmGrainMonochrome: boolean;
compareWithClassicUpscale: boolean;
classicCompareAlgorithm: DownscaleAlgorithm;
optLevel: "all" | "extended" | "basic" | "disabled";
webgpuLayout: "NCHW" | "NHWC";
webgpuValidation: "basic" | "full" | "wgpuOnly" | "disabled";
layout: "nchw" | "nhwc";
channelOrder: "rgb" | "bgr";
normalize: boolean;
mean: string;
std: string;
}
export interface ModelGroup {
label: string;
options: Array<{
value: string;
label: string;
}>;
}
export interface Size {
width: number;
height: number;
}
export interface NormalizedMetadata {
type: string;
dimensions: Array<number | string | null>;
dimensionLabels: Array<string | null>;
}
export interface SessionMetadataSummary {
inputCount: number;
outputCount: number;
inputs: Array<
{
name: string;
} & NormalizedMetadata
>;
outputs: Array<
{
name: string;
} & NormalizedMetadata
>;
primaryInput: ({
name: string;
} & NormalizedMetadata) | null;
primaryOutput: ({
name: string;
} & NormalizedMetadata) | null;
}
export interface PreprocessResult {
tensor: ort.Tensor;
summary: Record<string, unknown>;
outputCrop: {
inputWidth: number;
inputHeight: number;
paddedWidth: number;
paddedHeight: number;
};
}
export interface DiagnosticsLog {
secureContext: boolean | null;
crossOriginIsolated: boolean | null;
hasSharedArrayBuffer: boolean;
hasNavigatorGpu: boolean;
userAgent: string | null;
adapter?: string;
adapterInfo?: Record<string, string>;
features?: string[];
error?: string;
}
export interface PredefinedModelConfigFile {
models?: ModelConfigEntry[];
}