编译模型(coreML.compiledModel)
函数
临时目录, 错误信息 = coreML.compiledModel(模型路径)
参数
-
模型路径 文本型
.mlpackage 或者 .mlmodel 路径
返回值
说明
不同的型号或 系统版本在设备上编译的 .mlmldelc 文件不一定通用
示例
local modelPath = "/var/mobile/Media/svip/res/yolo11m.mlmodel"
local modelcPath = "/var/mobile/Media/svip/res/yolo11m.mlmodelc"
if (not file.existe(modelcPath)) then -- 如果编译后的模型不存在,就进行编译
local tmpPath, err = coreML.compiledModel(modelPath) --编译模型
if (tmpPath) then
print("编译成功")
os.execute(string.format("mv %s %s",tmpPath,modelcPath)) --把编译后的 .mlmodelc 从临时路径 移动到目标路径
else
print("编译失败 err:"..err)
os.exit()
end
end