Aiserverzoo
AIServerZoo
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.
Kind: global class
- AIServerZoo
- new AIServerZoo(serverUrl)
- .loadModel(modelName, [options]) ⇒
Promise.<AIServerModel>
- .listModels() ⇒
Promise.<Object>
- .getModelInfo(modelName) ⇒
Promise.<(Object|null)>
- .systemInfo() ⇒
Promise.<Object>
- .getModelLabels(name) ⇒
Promise.<Object>
- .traceManage(data) ⇒
Promise.<Object>
- .zooManage(data) ⇒
Promise.<Object>
- .sleep(ms) ⇒
Promise.<Response>
- .shutdown() ⇒
Promise.<void>
new AIServerZoo(serverUrl)
Note: do not call this constructor, instead use the connect
function of the dg_sdk class to create an AIServerZoo instance.
Param | Type | Description |
---|---|---|
serverUrl | string |
The URL of the AI server. Will always be 'ws:://something:port' |
Example (Usage:)
let zoo = dg.connect('ws://localhost:8779');
let model = await zoo.loadModel('someModel', { inputCropPercentage: 0.5, saveModelImage: true, outputMaxDetectionsPerClass: 7 } );
aiServerZoo.loadModel(modelName, [options]) ⇒ 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.
Kind: instance method of AIServerZoo
Returns: Promise.<AIServerModel>
- The loaded model instance.
Param | Type | Default | Description |
---|---|---|---|
modelName | string |
The name of the model to load. | |
[options] | Object |
{} |
Additional options to pass to the AIServerModel class. These options will be set on the model instance. |
[options.callback] | function |
|
The callback function to call for each predict result. |
[options.max_q_len] | number |
10 |
The maximum length of internal inference queue for the AIServerModel class. |
Example
let model = await zoo.loadModel('someModel', { inputCropPercentage: 0.5, callback: someFunction } );
aiServerZoo.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.
Kind: instance method of AIServerZoo
Returns: Promise.<Object>
- A promise that resolves to an object containing the model names as keys and their parameters as values.
Example
aiServerZoo.getModelInfo(modelName) ⇒ Promise.<(Object|null)>
Gets the default model parameters for a specified model.
Kind: instance method of AIServerZoo
Returns: Promise.<(Object|null)>
- A promise that resolves to the default model parameters if found, or null if not found.
Param | Type | Description |
---|---|---|
modelName | string |
The name of the model to retrieve information for. |
aiServerZoo.systemInfo() ⇒ Promise.<Object>
Fetches the system information from the AI server.
Kind: instance method of AIServerZoo
Returns: Promise.<Object>
- Contains devices object and software version string.
aiServerZoo.getModelLabels(name) ⇒ Promise.<Object>
Fetches the labels of a specific model by its name.
Kind: instance method of AIServerZoo
Returns: Promise.<Object>
- A promise that resolves to the model's label dictionary.
Param | Type | Description |
---|---|---|
name | string |
The name of the model to retrieve labels for. |
aiServerZoo.traceManage(data) ⇒ Promise.<Object>
Sends trace management data to the server.
Kind: instance method of AIServerZoo
Returns: Promise.<Object>
- A promise that resolves to the server's response.
Param | 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 |
aiServerZoo.zooManage(data) ⇒ Promise.<Object>
Sends a model zoo management request to the server. Currently, it works with the 'rescan' string in the request JSON.
Kind: instance method of AIServerZoo
Returns: Promise.<Object>
- A promise that resolves to the server's response.
Param | Type | Description |
---|---|---|
data | Object |
The model zoo management data in JSON format. |
aiServerZoo.sleep(ms) ⇒ Promise.<Response>
Sends a request to make the server sleep for a specified amount of time. Useful for pinging the server.
Kind: instance method of AIServerZoo
Returns: Promise.<Response>
- A promise that resolves to the server's response.
Param | Type | Description |
---|---|---|
ms | number |
The amount of time in milliseconds for the server to sleep. |
aiServerZoo.shutdown() ⇒ Promise.<void>
Sends a request to shut down the server.
Kind: instance method of AIServerZoo
Returns: Promise.<void>
- A promise that resolves when the server has been shut down.