Skip to main content

constructor

Instantiates an instance of UpscalerJS.

Example

import Upscaler from 'upscaler';
import x2 from '@upscalerjs/models/esrgan-thick/2x';

const upscaler = new Upscaler({
model: x2,
warmupSizes: [{ patchSize: 64 }],
});
Defined in upscaler.ts:77

Parameters

  • opts:
    • model?: - Defaults to @upscalerjs/default-model
        - **path**: `string`  - Path to a model.json file.
      - **modelType?**: [`ModelType`](https://github.com/thekevinscott/UpscalerJS/tree/main/packages/core/src/index.ts#L20) - The type of the model. Can be 'graph' or 'layer'. Defaults to 'layer'
      - **scale?**: `number` - The scale of the model. For super resolution models, should match the scale at which the model was trained.
      - **preprocess?**: [`PreProcess`](https://github.com/thekevinscott/UpscalerJS/tree/main/packages/core/src/index.ts#L22) - A function that processes the input image before feeding to the model. For example, you can use this function if you need to regularize your input.
      - **postprocess?**: [`PostProcess`](https://github.com/thekevinscott/UpscalerJS/tree/main/packages/core/src/index.ts#L23) - A function that processes the input image after being run through model inference. For example, you may need to convert floats to 0-255 integers.
      - **inputRange?**: [`Range`](https://github.com/thekevinscott/UpscalerJS/tree/main/packages/core/src/index.ts#L16) - Two numbers denoting the range in which the model expects number to be in the range of. Defaults to [0, 255].
      - **outputRange?**: [`Range`](https://github.com/thekevinscott/UpscalerJS/tree/main/packages/core/src/index.ts#L16) - Two numbers denoting the range in which the model is expected to output its predictions. Numbers can still fall outside of this range, but
      UpscalerJS will use the range to clip the values appropriately. Defaults to [0, 255].
    • warmupSizes?: WarmupSizes

Returns

Upscaler - an instance of an UpscalerJS class.