Skip to main content

Node.js Custom Models Guide

Demonstration of loading a custom model in Node.js.

Open in CodeSandbox.

Code

If we wish to serve our models from a different point on our file system, or we've brought our own custom model to use in Node.js, we can specify that easily.

note

We'll be using the 2x model from esrgan-slim for this example.

We can specify the model definition with:

const Upscaler = require('upscaler/node')
const upscaler = new Upscaler({
model: {
scale: 2,
path: tf.io.fileSystem('/path/to/model.json'),
}
})

For more information on the model option's attributes, see the section on custom model definitions.