Xnor Model Bundles

What is a Model Bundle?

An Xnor Model Bundle (Xnor Bundle, or XB) is a dynamically-linkable shared object that combines a trained ML model with an inference engine optimized for AI tasks on a specific hardware target. Every model bundle comes packaged in multiple forms:

In the Xnor developer SDK, these can be found in the :file: lib/MODEL_NAME/ folder, where MODEL_NAME is the model’s friendly name (e.g. person-classifier). In individual bundles downloaded from AI2GO, these can be found in the root folder of the bundle .zip archive.

Getting an Xnor Bundle

Hundreds of Xnor Bundles across dozens of use cases are available at AI2GO. All Xnor Bundles come in a selection of sizes so that you can pick a model that works for your use case.

In addition, a few Xnor Bundles are included in the developer SDK for use with the sample applications. See Developer SDK Included Bundles for more details.

Using an Xnor Bundle

C library (libxnornet.so)

To use an Xnor Bundle as a C library, #include "xnornet.h" in your source code and link against any Xnor Bundle’s libxnornet.so when you build your application. An example of how to do this can be found in the samples/c folder within the SDK. See Xnor SDK Samples for more information.

Python library (xnornet-*.whl)

To use an Xnor Bundle as a Python library, you can install the .whl file using pip:

python3 -m pip install --user xnornet-*.whl

You can then import xnornet in any Python script to use the installed Xnor Bundle.

Switching Xnor Bundles

Since every Xnor Bundle implements the same APIs, corresponding libraries for different Xnor Bundles can be swapped at will.

  • C library: Replace the libxnornet.so file in your application’s build directory with one from another Xnor Bundle. If your application assumes a particular result type, you may need to change your source code and re-compile to take advantage of models that return different result types.

  • Python library: Install the wheel of the other Xnor Bundle. Since all Xnor Bundles use the xnornet package, to prevent pip from assuming the package is already installed, you should remove the existing xnornet package before installing a new one:

    python3 -m pip uninstall xnornet
    python3 -m pip install --user xnornet-*.whl
    

Developer SDK Included Bundles

The following model bundles are included with the Xnor developer SDK for use with the sample applications.

Person Classifier

A fast classifier that predicts whether an image contains a person.

  • Classes: person

  • Minimum effective image size 1: 100 x 100 pixels

  • Real-time devices 2: All supported ARM and x86-64 devices

Facial Expression Classifier

A small, fast model that classifies the emotion-associated expression of a human face. Model accuracy may degrade if the image is not cropped to or closely zoomed in on the subject.

  • Classes: happy, sad, anger, fear, disgust, neutral, surprise

  • Minimum effective image size 1: 100 x 100 pixels

  • Real-time devices 2: All supported ARM and x86-64 devices

Person, Pet, Vehicle Detector

A fast object detector that predicts bounding boxes for people, pets, and vehicles.

  • Classes: person, pet (cat, dog, horse), vehicle (car, motorcycle, bus, train, truck)

  • Minimum effective image size 1: 300 x 300 pixels

  • Real-time devices 2: All supported ARM and x86 devices.

Person Segmenter

A semantic segmentation model that predicts if each pixel in an image belongs to a person or not.

  • Classes: person

  • Minimum effective image size 1: 300 x 300 pixels

  • Real-time devices 2: High-end ARM and x86 devices (usable at slower than real time on all supported devices).

Footnotes

1(1,2,3,4)

“Minimum effective image size”:

  • Images smaller than this size will be up-scaled before being passed to the model, which may introduce artifacts and increase evaluation latency.

  • Images larger than this size will be down-scaled before being passed to the model, which may increase evaluation latency.

2(1,2,3,4)

“Real-time devices” are hardware targets where the model will run with deterministic, sub-second latency.