| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 22-Oct-2025 | - | 35 | 32 | ||
| entry/ | 22-Oct-2025 | - | 1,309 | 1,189 | ||
| hvigor/ | 22-Oct-2025 | - | 39 | 37 | ||
| screenshots/ | 22-Oct-2025 | - | ||||
| .gitignore | D | 22-Oct-2025 | 133 | 12 | 12 | |
| README_zh.md | D | 22-Oct-2025 | 3.5 KiB | 86 | 56 | |
| build-profile.json5 | D | 22-Oct-2025 | 1.2 KiB | 52 | 51 | |
| hvigorfile.ts | D | 22-Oct-2025 | 234 | 7 | 5 | |
| hvigorw | D | 22-Oct-2025 | 2.1 KiB | 62 | 28 | |
| hvigorw.bat | D | 22-Oct-2025 | 2 KiB | 72 | 56 | |
| oh-package.json5 | D | 22-Oct-2025 | 899 | 30 | 28 | |
| ohosTest.md | D | 22-Oct-2025 | 612 | 9 | 7 |
README_zh.md
1# **基于**Native**接口的MindSpore Lite应用开发** 2 3### 介绍 4 5本文基于MindSpore Lite提供的[Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md),实现“图像分类”示例程序,来演示端侧部署的流程。 6 71. 选择图像分类模型。 82. 将模型转换成MindSpore Lite模型格式。 93. 使用MindSpore Lite推理模型,显示出可能的分类结果。 10 11### 效果预览 12 13| 主页 | 14| -------------------------------------------------- | 15| <img src="screenshots/MindSporeLiteCDemoPic.png"/> | 16 17#### 使用说明 18 191. 在主界面,可以点击photo按钮,进入相册选择图片界面; 202. 在相册界面,选择图片,点击确定按钮; 213. 自动进行选择图片的图像分类模型推理,部分推理结果显示在主界面。 22 23### 工程目录 24 25``` 26entry 27├── src/main 28│ ├── etc 29| | └── pages 30| | └── Index.ets // 首页,获取图片及预处理 31│ ├── cpp 32| | └── mslite_napi.cpp // 推理函数 33| | └── CMakeLists.txt // 编译脚本 34| | └── types 35| | └── libentry 36| | └── Index.t.ts // 将C++动态库封装成JS模块 37│ ├── resources // 资源文件 38| | └── rawfile 39| | └── mobilenetv2.ms // 存放的模型文件 40``` 41 42### 具体实现 43 44* 本示例程序中使用的终端图像分类模型文件为mobilenetv2.ms,放置在entry\src\main\resources\rawfile工程目录下。 45 46 注:开发者可按需手工下载[MindSpore Model Zoo中图像分类模型](https://download.mindspore.cn/model_zoo/official/lite/mobilenetv2_openimage_lite/1.5/mobilenetv2.ms)。 47 48* 调用[@ohos.file.picker](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md) (图片文件选择)、[@ohos.multimedia.image](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-image-kit/js-apis-image.md) (图片处理效果)、[@ohos.file.fs](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md) (基础文件操作) 等API实现相册图片获取及图片处理。完整代码请参见Index.ets。 49 50* 调用[MindSpore Lite Native API](https://docs.openharmony.cn/pages/v4.1/zh-cn/application-dev/reference/apis-mindspore-lite-kit/_mind_spore.md)实现推理。完整代码请参见mslite_napi.cpp。 51 52* 编写CMake脚本。链接MindSpore Lite动态库,完整代码请参见CMakeLists.txt。 53 54* 使用N-API将C++动态库封装成JS模块。在 entry/src/main/cpp/types/libentry/index.d.ts,定义JS接口`runDemo()` 。 55 56* 调用推理函数并处理结果。完整代码请参见Index.ets 57 58### 相关权限 59 60ohos.permission.READ_IMAGEVIDEO 61 62### 依赖 63 64无。 65 66### 约束与限制 67 681.本示例仅支持标准系统上运行,测试设备:RK3568; 69 702.本示例为Stage模型,已适配API version 11版本SDK; 71 723.本示例需要使用DevEco Studio 4.1 Release及以上版本才可编译运行。 73 74### 下载 75 76如需单独下载本工程,执行如下命令: 77 78``` 79git init 80git config core.sparsecheckout true 81echo code/BasicFeature/ApplicationModels/MindSporeLiteCDemo/ > .git/info/sparse-checkout 82git remote add origin https://gitee.com/openharmony/applications_app_samples.git 83git pull origin master 84``` 85 86