GetModelAttributes
以 JSON 格式返回当前加载的具名模型的元数据。
格式
GetModelAttributes ( 模型名称 )
参数
模型名称 - 要解析的模型的名称。该值必须与先前加载的模型的名称相匹配。
返回的数据类型
文本
原始版本
19.3.1
说明
在使用 GetModelAttributes 之前,必须先使用配置机器学习模型脚本步骤加载 Core ML 模型。
下面是与图像一起使用的 TestModel 模型返回的值示例。
{
    "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"
}
                                            JSON 对象返回的属性取决于模型中的内容。一般而言,JSON 对象的顶层包含以下 JSON 对象。
| JSON 元素 | 
                                                         说明  | 
                                                
|---|---|
APIVers
                                                     | 
                                                    
                                                         此 JSON 对象的结构版本的数值。如果此 JSON 对象的结构在后续版本中有更改,此版本号也会更改。  | 
                                                
configuration
                                                     | 
                                                    
                                                         可能只包含  
  | 
                                                
modelDescription
                                                     | 
                                                    
                                                         可能包含: 
  | 
                                                
modelName
                                                     | 
                                                    
                                                         指定用于加载模型的配置机器学习模型脚本  | 
                                                
注释
- 仅 iOS、iPadOS 和 macOS 上支持此功能。
 
示例 1
此脚本加载模型并将其属性显示为如上所示的格式化 JSON 数据。
配置机器学习模型 [ 操作:视觉 ; 名称:"TestModel" ; 从:表::模式容器字段 ]
设置变量 [ $modelAttributes ; 值:
    JSONFormatElements ( GetModelAttributes ( "TestModel" ) ) ]
显示自定义对话框 [ $modelAttributes ]
                                            示例 2
对于加载的模型 TestModel,如果模型的第一个输入描述包含 sizeRange 键,则返回 1。
Let ( [
    modelAttributes = GetModelAttributes ( "TestModel" ) ;
    firstInput = "modelDescription.inputDescriptions.[0]" ;
    inputKeys = JSONListKeys ( $modelAttributes ; firstInput ) ;
    keyCount = PatternCount ( inputKeys ; "sizeRange" )
] ; 
    If ( keyCount > 0 ; 1 ; 0 )
)