Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Predictor

This class can load Waifu2X json weights and do the prediction job.

Hierarchy

  • Predictor

Index

Constructors

constructor

  • new Predictor(modelUrl: string, blockSize?: number): Predictor
  • Construct a new Predictor for Waifu2X prediction.

    Parameters

    • modelUrl: string

      Json url path of Waifu2X weights.

    • blockSize: number = 32

      The size of a single block when dividing an image into multiple blocks for processing

    Returns Predictor

Methods

destroy

  • destroy(): void
  • Memory used by tf.Tensor in the tf.layers.Layer instance can not be free automatically, call this if the Predictor instance won't be used;

    Returns void

listenToModelDownloadProgress

  • listenToModelDownloadProgress(callback: (ratio: number) => void): void
  • Set a listener which will be called when the model download progress changed.

    Parameters

    • callback: (ratio: number) => void
        • (ratio: number): void
        • Parameters

          • ratio: number

          Returns void

    Returns void

listenToModelPredictProgress

  • listenToModelPredictProgress(callback: (ratio: number) => void): void
  • Set a listener which will be called when the model predict progress changed.

    Parameters

    • callback: (ratio: number) => void
        • (ratio: number): void
        • Parameters

          • ratio: number

          Returns void

    Returns void

predict

  • predict(image: ImageBitmap, isNoise: boolean): Promise<ImageBitmap>
  • Apply Waifu2X to the input image.

    Parameters

    • image: ImageBitmap

      The Image coding as ImageBitMap with RGB color space as the input of the Waifu2X task.

    • isNoise: boolean

      To decrease noise or do super resolution job.

    Returns Promise<ImageBitmap>

Generated using TypeDoc