Skip to main content
Version: 0.1

Interface: MobileModel

MobileModelModule.MobileModel

Methods

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:149


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:115


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:122