Skip to main content
Version: 0.2.0

Interface: MobileModel

MobileModelModule.MobileModel

Methods

download

download(modelPath): Promise<string>

Download a model to the local file system and return the local file path as a model. If the model path is a file path already, it will return the same path as a result.

Parameters

NameTypeDescription
modelPathModelPathThe model path as require or uri (i.e., require).

Returns

Promise<string>

Defined in

MobileModelModule.ts:70


execute

execute<T>(modelPath, params): Promise<ModelResult<T>>

Run inference on a model.

const classificationModel = require('../models/mobilenet_v3_small.ptl');

// or

const classificationModel = require('https://example.com/models/mobilenet_v3_small.ptl');

const image: Image = await ImageUtils.fromURL('https://image.url');

const { result: {maxIdx} } = await MobileModel.execute(
classificationModel,
{
image,
}
);

const topClass = ImageClasses(scores);

Type parameters

Name
T

Parameters

NameTypeDescription
modelPathModelPathThe model path as require or uri (i.e., require).
paramsanyThe input parameters for the model.

Returns

Promise<ModelResult<T>>

Defined in

MobileModelModule.ts:113


preload

preload(modelPath): Promise<void>

Preload a model. If a model is not preloaded, it will be loaded during the first inference call. However, the first inference time will therefore take significantly longer. This function allows to preload a model ahead of time before running the first inference.

Parameters

NameTypeDescription
modelPathModelPathThe model path as require or uri (i.e., require).

Returns

Promise<void>

Defined in

MobileModelModule.ts:79


unload

unload(): Promise<void>

Unload all model. If any model were loaded previously, they will be discarded. This function allows to load a new version of a model without restarting the app.

Returns

Promise<void>

Defined in

MobileModelModule.ts:86