Class: AIServerZoo

AIServerZoo(serverUrl)

This class is responsible for loading models for inference on an AIServer.
Use loadModel() to instantiate and configure a model for use.
Use various utility functions to get AIServer information using REST API and manage models.

Constructor

new AIServerZoo(serverUrl)

Note: do not call this constructor, instead use the `connect` function of the dg_sdk class to create an AIServerZoo instance.
Parameters:
Name Type Description
serverUrl string The URL of the AI server. Will always be 'ws:://something:port'
Source:
Example

Usage:

let zoo = dg.connect('ws://localhost:8779');
let model = await zoo.loadModel('someModel', { inputCropPercentage: 0.5, saveModelImage: true, outputMaxDetectionsPerClass: 7 } );

Methods

(async) getModelInfo(modelName) → {Promise.<(Object|null)>}

Gets the default model parameters for a specified model.
Parameters:
Name Type Description
modelName string The name of the model to retrieve information for.
Source:
Returns:
A promise that resolves to the default model parameters if found, or null if not found.
Type
Promise.<(Object|null)>

(async) getModelLabels(name) → {Promise.<Object>}

Fetches the labels of a specific model by its name.
Parameters:
Name Type Description
name string The name of the model to retrieve labels for.
Source:
Returns:
A promise that resolves to the model's label dictionary.
Type
Promise.<Object>

(async) listModels() → {Promise.<Object>}

Lists all available models on the AI server as a collection of objects (model names) whose values are the model parameters for that model.
Source:
Returns:
A promise that resolves to an object containing the model names as keys and their parameters as values.
Type
Promise.<Object>
Example
let models = await zoo.listModels();
let modelNames = Object.keys(models);

(async) loadModel(modelName, optionsopt) → {Promise.<AIServerModel>}

Loads a model from the AIServer with specific options. The model instance can be created with a callback function, which will be called for every predict result instead of returning a promise. The max_q_len parameter can be set to be able to control the maximum length of the internal inference queue.
Parameters:
Name Type Attributes Default Description
modelName string The name of the model to load.
options Object <optional>
{} Additional options to pass to the AIServerModel class. These options will be set on the model instance.
Properties
Name Type Attributes Default Description
callback function <optional>
null The callback function to call for each predict result.
max_q_len number <optional>
10 The maximum length of internal inference queue for the AIServerModel class.
Source:
Returns:
The loaded model instance.
Type
Promise.<AIServerModel>
Example
let model = await zoo.loadModel('someModel', { inputCropPercentage: 0.5, callback: someFunction } ); 

(async) shutdown() → {Promise.<void>}

Sends a request to shut down the server.
Source:
Returns:
A promise that resolves when the server has been shut down.
Type
Promise.<void>

(async) sleep(ms) → {Promise.<Response>}

Sends a request to make the server sleep for a specified amount of time. Useful for pinging the server.
Parameters:
Name Type Description
ms number The amount of time in milliseconds for the server to sleep.
Source:
Returns:
A promise that resolves to the server's response.
Type
Promise.<Response>

(async) systemInfo() → {Promise.<Object>}

Fetches the system information from the AI server.
Source:
Returns:
Contains devices object and software version string.
Type
Promise.<Object>

(async) traceManage(data) → {Promise.<Object>}

Sends trace management data to the server.
Parameters:
Name Type Description
data Object The trace management data in JSON format. MUST USE THIS FORMAT: https://degirum.atlassian.net/wiki/spaces/SD/pages/1586298881/AI+Server+Protocol+Description
Source:
Returns:
A promise that resolves to the server's response.
Type
Promise.<Object>

(async) zooManage(data) → {Promise.<Object>}

Sends a model zoo management request to the server. Currently, it works with the 'rescan' string in the request JSON.
Parameters:
Name Type Description
data Object The model zoo management data in JSON format.
Source:
Returns:
A promise that resolves to the server's response.
Type
Promise.<Object>