GetModelAttributes

Returns metadata in JSON format about a named model that's currently loaded.

Format 

GetModelAttributes ( modelName )

Parameters 

modelName - the name of the model to evaluate. This value must match the name of a previously loaded model.

Data type returned 

text

Originated in version 

19.3.1

Description 

You must first use the Configure Machine Learning Model script step to load a Core ML model before using GetModelAttributes.

The following is an example of what's returned for a model named TestModel that works with images.

Copy
{
    "APIVers": 1,
    "configuration"
    {
        "computeUnits" : "All"
    },
    "modelDescription"
    {
        "classLabels"
        [
            "British Shorthair",
            "tabby, tabby cat",
            . . .
            "Siberian Husky",
            "beagle"
        ],
        "inputDescriptions"
        [
            {
                "featureName" : "image",
                "isOptional" : 0,
                "pixelFormat" : 1111970369,
                "pixelsHigh" : 299,
                "pixelsWide" : 299,
                "sizeRange"
                {
                    "heightMax" : 9223372036854775808,
                    "heightMin" : 299,
                    "widthMax" : 9223372036854775808,
                    "widthMin" : 299
                },
                "type" : "image"
            }
        ],
        "metadata"
        {
            "author" : "Tenete Jantelli",
            "creatorDefined"
            {
                "com.apple.coreml.model.preview.type" : "imageClassifier",
                "com.apple.createml.app.tag" : "47",
                "com.apple.createml.app.version" : "2.0",
                "com.apple.createml.version" : "10.15.5"
            },
            "description" : "Dog and cat classifier",
            "license" : "",
            "version" : "1.0"
        },
        "outputDescriptions"
        [
            {
                "featureName" : "classLabel",
                "isOptional" : 0,
                "type" : "unknown"
            },
            {
                "featureName" : "classLabelProbs",
                "isOptional" : 0,
                "type" : "unknown"
            }
        ]
    },
    "modelName" : "TestModel"
}

The attributes returned in the JSON object depend on what is in the model. In general, the top level of the JSON object contains the following JSON objects.

JSON element

Description

APIVers

Numeric value for the version of this JSON object's structure. If the structure of this JSON object changes in a subsequent release, this number will change.

configuration

May contain only the computeUnits key, which has one of the following values specifying the processing units the model uses during evaluation:

  • "CPU only"

  • "CPU and GPU"

  • "All"

modelDescription

May contain:

  • classLabels – An array of the names of what an image model can recognize.

  • inputDescription – An array of objects, each describing an input the model expects for a feature. For models that process images, there is usually only one input and may contain keys like these:

    • featureName – For image models, the value is typically "image." Note that these values correspond to the named parameters passed into the ComputeModel function.

    • isOptional – Indicates whether this feature is optional.

    • type – For image models, the value is typically "image." For general models, values can be "Int64," "Double," or "String."

    • Other attributes that describe the constraints of an input image.

  • metadata object – An object containing author, description, license, version, and custom metadata defined by the model creator.

  • outputDescription – An array of objects, each describing an output the model provides for a feature. This array is similar to inputDescription but typically provides less information.

  • paramDescriptions – An array of objects, each providing the name and scope of the model's parameters.

  • trainingInputDescriptions – Whether the model can be updated with additional training and information about the model's parameters.

modelName

Name that the Configure Machine Learning Model script step used to load the model.

Notes 

  • This function is supported only on iOS, iPadOS, and macOS.

Example 1 

This script loads a model and displays its attributes as the formatted JSON data shown above.

Copy
Configure Machine Learning Model [ Operation: Vision ; Name: "TestModel" ; From: Table::ModelContainerField ]
Set Variable [ $modelAttributes ; Value: 
    JSONFormatElements ( GetModelAttributes ( "TestModel" ) ) ]
Show Custom Dialog [ $modelAttributes ]

Example 2 

For a loaded model named TestModel, returns 1 if the model's first input description contains a sizeRange key.

Copy
Let ( [
    modelAttributes = GetModelAttributes ( "TestModel" ) ;
    firstInput = "modelDescription.inputDescriptions.[0]" ;
    inputKeys = JSONListKeys ( modelAttributes ; firstInput ) ;
    keyCount = PatternCount ( inputKeys ; "sizeRange" )
] ; 
    If ( keyCount > 0 ; 1 ; 0 )
)