【问题标题】:How can I write the CMakeLists.txt to add .mlmodel to xcode project如何编写 CMakeLists.txt 以将 .mlmodel 添加到 xcode 项目
【发布时间】:2019-12-17 10:28:16
【问题描述】:

我有一个detect_model.mlmodel,它是由我自己训练的。我想在 xcode 中使用它,但我不想手动将它添加到我的 xcode 项目中。我试图编写 CMakeLists.txt 来管理我的 xcode 项目。但是如何在 CMake 文件中写入以将 detect_model.mlmodel 添加到我的 xcode 项目中并生成 detect_model.h 头文件?

我尝试过使用set(mlmodel detect_model.mlmodel)add_library(dst ${mlmodel}),但是不正确。

预期的结果是我可以使用CMake将detect_model.mlmodel添加到xcode项目中并自动生成detect_model.h

【问题讨论】:

    标签: cmake coreml mlmodel


    【解决方案1】:

    您可能需要添加一个调用 coremlc 的自定义规则来生成 .h abd .m 文件和 .mlmodelc 文件夹。

    这就是你从终端执行的方式:

    mkdir output
    xcrun coremlc compile YourModel.mlmodel output
    xcrun coremlc generate Model.mlmodel output
    

    您还需要添加规则以将 .mlmodelc 文件夹复制到应用程序包中。

    【讨论】:

    • 太棒了!有效。谢谢你的帮助。此外,是否有工具可以对mlmodel的每一层进行时间剖析,我想知道哪个网络层花费的时间最多。 Apple coreml 工具没有这个功能。
    • 另外,《Core ML Survival Guide》确实是一本正经的书。它帮助我了解了很多关于 coreml 的知识。干得好!
    • @YiZhaoYanBo 你有你写的 XCode 来处理这个吗?
    猜你喜欢
    • 2021-01-25
    • 2012-08-24
    • 2020-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    • 1970-01-01
    • 2011-03-14
    相关资源
    最近更新 更多