# Zoo Manager Module

{% hint style="info" %}
This API Reference is based on PySDK 0.20.0.
{% endhint %}

## degirum.zoo\_manager.ZooManager

Class that manages a model zoo.

A *model zoo* in terminology of PySDK is a collection of AI models and simultaneously an ML inference engine type and location.

Depending on the deployment location, there are several types of model zoos supported by PySDK:

* **Local** model zoo: Deployed on the local file system of the PySDK installation host. Inferences are performed on the same host using AI accelerators installed on that host.
* AI **server** model zoo: Deployed on remote host with DeGirum AI server running on that host. Inferences are performed by DeGirum AI server on that remote host.
* **Cloud** Platform model zoo: Deployed on DeGirum Cloud Platform. Inferences are performed by DeGirum Cloud Platform servers.

The type of the model zoo is defined by the URL string which you pass as `zoo_url` parameter into the constructor.

Zoo manager provides the following functionality:

* List and search models available in the connected model zoo.
* Create AI model handling objects to perform AI inferences.
* Request various AI model parameters.

## \_\_init\_\_(inference\_host\_address, ...)

`degirum.zoo_manager.ZooManager.__init__(inference_host_address, zoo_url='', token='')`

Constructor.

Note

Typically, you never construct `ZooManager` objects yourself -- instead you call [degirum.connect](https://docs.degirum.com/pysdk/user-guide-pysdk/package#degirum.connect) function to create `ZooManager` instances for you.

For the description of arguments see [degirum.connect](https://docs.degirum.com/pysdk/user-guide-pysdk/package#degirum.connect)

## list\_models(\*args, ...) <a href="#degirum.zoo_manager.zoomanager.list_models" id="degirum.zoo_manager.zoomanager.list_models"></a>

`degirum.zoo_manager.ZooManager.list_models(*args, **kwargs)`

Get a list of names of AI models available in the connected model zoo which match specified filtering criteria.

Other Parameters:

| Name               | Type  | Description                                                                                                                                                                                                                                                                                                       |
| ------------------ | ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model_family`     | `str` | <p>Model family name filter.</p><ul><li>When you pass a string, it will be used as search substring in the model name. For example, <code>"yolo"</code>, <code>"mobilenet"</code>.</li><li>You may also pass <code>re.Pattern</code> object. In this case it will do regular expression pattern search.</li></ul> |
| `runtime`          | `str` | Runtime agent type -- string or list of strings of runtime agent types.                                                                                                                                                                                                                                           |
| `device`           | `str` | Target inference device -- string or list of strings of device names.                                                                                                                                                                                                                                             |
| `device_type`      | `str` | Target inference device(s) -- string or list of strings of full device type names in "RUNTIME/DEVICE" format.                                                                                                                                                                                                     |
| `precision`        | `str` | <p>Model calculation precision - string or list of strings of model precision labels.</p><p>Possible labels: <code>"quant"</code>, <code>"float"</code>.</p>                                                                                                                                                      |
| `pruned`           | `str` | <p>Model density -- string or list of strings of model density labels.</p><p>Possible labels: <code>"dense"</code>, <code>"pruned"</code>.</p>                                                                                                                                                                    |
| `postprocess_type` | `str` | <p>Model output postprocess type -- string or list of strings of postprocess type labels.</p><p>For example: <code>"Classification"</code>, <code>"Detection"</code>, <code>"Segmentation"</code>.</p>                                                                                                            |

Returns:

| Type                                       | Description                                                                                                                                                                                                           |
| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Union[List[str], Dict[str, ModelParams]]` | The list of model name strings matching specified filtering criteria. Use a string from that list as a parameter of [degirum.zoo\_manager.ZooManager.load\_model](#degirum.zoo_manager.ZooManager.load_model) method. |

Example

Find all models of `"yolo"` family capable to run either on CPU or on DeGirum Orca AI accelerator from all registered model zoos:

{% code overflow="wrap" %}

```
    yolo_model_list = zoo_manager.list_models("yolo", device=["cpu", "orca"])

```

{% endcode %}

## load\_model(model\_name, ...) <a href="#degirum.zoo_manager.zoomanager.load_model" id="degirum.zoo_manager.zoomanager.load_model"></a>

`degirum.zoo_manager.ZooManager.load_model(model_name, **kwargs)`

Create and return the model handling object for given model name.

Parameters:

| Name         | Type  | Description                                                                                                                                                                                                      | Default    |
| ------------ | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `model_name` | `str` | Model name string identifying the model to load. It should exactly match the model name as it is returned by [degirum.zoo\_manager.ZooManager.list\_models](#degirum.zoo_manager.ZooManager.list_models) method. | *required* |
| `**kwargs`   | `any` | you may pass arbitrary model properties to be assigned to the model object in a form of property=value                                                                                                           | `{}`       |

Returns:

| Type                                                                                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`Model`](https://docs.degirum.com/pysdk/user-guide-pysdk/model#degirum.model.Model) | <p>Model handling object. Using this object you perform AI inferences on this model and also configure various model properties, which define how to do input image preprocessing and inference result post-processing:</p><ul><li>Call <a href="../model#degirum.model.model.predict">degirum.model.Model.predict</a> method to perform AI inference of a single frame. Inference result object is returned.</li><li>For more efficient pipelined batch predictions call <a href="../model#degirum.model.model.predict_batch">degirum.model.Model.predict\_batch</a> or <a href="../model#degirum.model.model.predict_dir">degirum.model.Model.predict\_dir</a> methods to perform AI inference of multiple frames</li><li><p>Configure the following image pre-processing properties:</p><ul><li><a href="../model#degirum.model.Model.input_resize_method">degirum.model.Model.input\_resize\_method</a> -- to set input image resize method.</li><li><a href="../model#degirum.model.Model.input_pad_method">degirum.model.Model.input\_pad\_method</a> -- to set input image padding method.</li><li><a href="../model#degirum.model.Model.input_letterbox_fill_color">degirum.model.Model.input\_letterbox\_fill\_color</a> -- to set letterbox padding color.</li><li><a href="../model#degirum.model.Model.image_backend">degirum.model.Model.image\_backend</a> -- to select image processing library.</li></ul></li><li><p>Configure the following model post-processing properties:</p><ul><li><a href="../model#degirum.model.Model.output_confidence_threshold">degirum.model.Model.output\_confidence\_threshold</a> -- to set confidence threshold.</li><li><a href="../model#degirum.model.Model.output_nms_threshold">degirum.model.Model.output\_nms\_threshold</a> -- to set non-max suppression threshold.</li><li><a href="../model#degirum.model.Model.output_top_k">degirum.model.Model.output\_top\_k</a> -- to set top-K limit for classification models.</li><li><a href="../model#degirum.model.Model.output_pose_threshold">degirum.model.Model.output\_pose\_threshold</a> -- to set pose detection threshold for pose detection models.</li></ul></li><li><p>Configure the following overlay image generation properties:</p><ul><li><a href="../model#degirum.model.Model.overlay_color">degirum.model.Model.overlay\_color</a> -- to set color for inference results drawing on overlay image.</li><li><a href="../model#degirum.model.Model.overlay_line_width">degirum.model.Model.overlay\_line\_width</a> -- to set line width for inference results drawing on overlay image.</li><li><a href="../model#degirum.model.Model.overlay_show_labels">degirum.model.Model.overlay\_show\_labels</a> -- to set flag to enable/disable drawing class labels on overlay image.</li><li><a href="../model#degirum.model.Model.overlay_show_probabilities">degirum.model.Model.overlay\_show\_probabilities</a> -- to set flag to enable/disable drawing class probabilities on overlay image.</li><li><a href="../model#degirum.model.Model.overlay_alpha">degirum.model.Model.overlay\_alpha</a> -- to set alpha-blend weight for inference results drawing on overlay image.</li><li><a href="../model#degirum.model.Model.overlay_font_scale">degirum.model.Model.overlay\_font\_scale</a> -- to set font scale for inference results drawing on overlay image.</li></ul></li></ul><p><a href="../postprocessor#degirum.postprocessor._inferenceresults.inferenceresults">Inference result object</a> returned by <a href="../model#degirum.model.Model.predict">degirum.model.Model.predict</a> method allows you to access AI inference results:</p><ul><li>Use <a href="../postprocessor#degirum.postprocessor._inferenceresults.inferenceresults.image">InferenceResults.image</a> property to access original image.</li><li>Use <a href="../postprocessor#degirum.postprocessor._inferenceresults.inferenceresults.image_overlay">InferenceResults.image\_overlay </a>property to access image with inference results drawn on a top of it.</li><li>Use <a href="../postprocessor#degirum.postprocessor._inferenceresults.inferenceresults.results">InferenceResults.results</a> property to access the list of numeric inference results.</li></ul> |

## model\_info(model\_name) <a href="#degirum.zoo_manager.zoomanager.model_info" id="degirum.zoo_manager.zoomanager.model_info"></a>

`degirum.zoo_manager.ZooManager.model_info(model_name)`

Request model parameters for given model name.

Parameters:

| Name         | Type  | Description                                                                                                                                                                        | Default    |
| ------------ | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `model_name` | `str` | Model name string. It should exactly match the model name as it is returned by [degirum.zoo\_manager.ZooManager.list\_models](#degirum.zoo_manager.ZooManager.list_models) method. | *required* |

Returns:

| Type          | Description                                                                     |
| ------------- | ------------------------------------------------------------------------------- |
| `ModelParams` | Model parameter object which provides read-only access to all model parameters. |

{% hint style="info" %}
You cannot modify actual model parameters -- any changes of model parameter object returned by this method are not applied to the real model. Use properties of model handling objects returned by [degirum.zoo\_manager.ZooManager.load\_model](#degirum.zoo_manager.zoomanager.load_model) method to change parameters of that particular model instance on the fly.
{% endhint %}

## supported\_device\_types <a href="#degirum.zoo_manager.zoomanager.supported_device_types" id="degirum.zoo_manager.zoomanager.supported_device_types"></a>

`degirum.zoo_manager.ZooManager.supported_device_types()`

Get runtime/device type names, which are available in the inference system.

Returns:

| Type   | Description                                                                              |
| ------ | ---------------------------------------------------------------------------------------- |
| `list` | list of runtime/device type names; each element is a string in a format "RUNTIME/DEVICE" |

## system\_info(update=False) <a href="#degirum.zoo_manager.zoomanager.system_info" id="degirum.zoo_manager.zoomanager.system_info"></a>

`degirum.zoo_manager.ZooManager.system_info(update=False)`

Return host system information dictionary

Parameters:

| Name     | Type   | Description                                                | Default |
| -------- | ------ | ---------------------------------------------------------- | ------- |
| `update` | `bool` | force update system information, otherwise take from cache | `False` |

Returns:

| Type   | Description                                                                                                                                |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `dict` | host system information dictionary. Format: `{"Devices": {"<runtime>/<device>": {<device_info>}, ...}, ["Software Version": "<version>"]}` |
