This is an old revision of the document!


Create a ModelHost Service

To make your AI run live, you'll need a few extra things.

The extra scripts in Python, and a binding file that tells ARDI how to connect live data to some of the parameters of your model.

Binding File

The binding file is a simple JSON file that describes what ARDI data points each of your AI inputs should be connected to, as well as an optional 'map' that describes how values should be translated from numbers to strings.

For example, our Bakery Demo includes a Browning and Rise predictor that predicts how well cupcakes will rise and how brown the top surface will be, based on the current product type and machine setup.

You can see the example here.

It takes several parameters, including…

Name
Flavour
Size
Mixin
Browning Zone.Temperature - Oven
Rising Zone.Temperature Oven

The attributes with periods (.) are already being sourced from ARDI. However, the attributes without them (such as Flavour, Size and Mixin) will use a constant value unless you specify where to find them in your ARDI server.

Example File

{
    "mixin": "Bakery.Mixin",
    "size": "Bakery.Size",
    "flavour": "Bakery.Flavour",
    "filling": "Bakery.Filling",
    "mixin_map": {
        "0": "None",
        "1": "Choc-Chip",
        "2": "White Choc-Chip",
        "3": "Berry"
    },
    "size_map": {
        "0": "Small",
        "1": "Medium",
        "2": "Large"
    },
    "flavour_map": {
        "0": "Vanilla",
        "1": "Chocolate",
        "2": "Strawberry",
        "3": "Lemon",
        "4": "Caramel"
    },
    "filling_map": {
        "0": "None",
        "1": "Choc Fudge",
        "2" :"Creme",
        "3": "Caramel"        
    }
}

Here's the complete binding file. It contains both the basic bindings (ie. “size” should be loaded from “Bakery.Size”) and mappings, so that a value of 0 for flavour will be translated into the text 'Vanilla'.

Installing Dependencies

If you want to run this service on a local machine, you might need to install some additional Python libraries. The names of these libraries are included in the 'morerequires.txt' file inside the 'extra scripts' download earlier.

Setting Port Number and Name

Running the Model

Decompress the extra files into the folder with your .keras and .json files.

Edit the model.py file and update the model name (search for '@mdl.part'). You might also want to change the port number the OPC-UA server runs on, which can be found in the opening line of the file (the default is '5555').

You can then run the 'model.py' script.

On a Linux terminal, write

python3 model.py

Or on Windows Command Prompt, write

c:\python314\python model.py

The model will be available via OPC-UA on port 5555 by default.