项目简介
本项目聚焦于构建并部署基于Arm Cortex-M55和Ethos-U55 NPU的机器学习应用示例,主要在FVP模拟环境中开展。项目包含多种对象检测和图像分类示例,运用TensorFlow Lite模型进行推理。
项目的主要特性和功能
- 对象检测示例
- Person Detection:借助Google提供的TensorFlow Lite模型实现人物检测,支持在Cortex-M55上不通过Vela运行,或在Ethos-U55 NPU上通过Vela运行。
- Yolo Fastest Object Detection:使用Yolo Fastest模型进行对象检测,可在Ethos-U55 NPU上运行。
- Yolo Fastest XL Object Detection:采用Yolo Fastest XL模型进行对象检测,支持在Ethos-U55 NPU上运行。
- 模型优化
- 利用HIMAX配置文件生成Vela优化模型。
- 支持在Cortex-M55和Ethos-U55 NPU上运行优化后的模型。
- 环境支持
- 推荐使用Ubuntu 20.04 LTS环境进行开发和测试。
- 提供详细的工具链安装和配置步骤,涵盖Corstone SSE - 300 FVP、GNU Arm Embedded Toolchain和Arm ML Embedded Evaluation Kit。
安装使用步骤
1. 环境准备
确保已安装以下工具和依赖:
bash
sudo apt-get update
sudo apt-get install cmake curl xterm python3 python3.8-venv
2. 安装Corstone SSE - 300 FVP
下载并安装Corstone SSE - 300 FVP:
bash
wget https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/MPS3/FVP_Corstone_SSE-300_Ethos-U55_11.14_24.tgz
mkdir temp
tar -C temp -xvzf FVP_Corstone_SSE-300_Ethos-U55_11.14_24.tgz
temp/FVP_Corstone_SSE-300_Ethos-U55.sh --i-agree-to-the-contained-eula --no-interactive -d CS300FVP
3. 安装GNU Arm Embedded Toolchain
下载并安装GNU Arm Embedded Toolchain:
bash
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
tar -xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
export PATH="${PATH}:/[location of your GCC_ARM_NONE_EABI_TOOLCHAIN_ROOT]/gcc-arm-none-eabi/bin"
4. 安装Arm ML Embedded Evaluation Kit
下载并安装Arm ML Embedded Evaluation Kit:
bash
wget https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+archive/refs/tags/22.02.tar.gz
mkdir ml-embedded-evaluation-kit
tar -C ml-embedded-evaluation-kit -xvzf 22.02.tar.gz
cp -r download_dependencies.py ./ml-embedded-evaluation-kit/
cd ml-embedded-evaluation-kit/
rm -rf ./dependencies
python3 ./download_dependencies.py
./build_default.py --npu-config-name ethos-u55-64
5. 构建和运行示例
5.1 Person Detection示例
不通过Vela运行:
bash
cd ml-embedded-evaluation-kit
mkdir build_img_person_detect && cd build_img_person_detect
cmake ../ -DUSE_CASE_BUILD=img_person_detect -DETHOS_U_NPU_ENABLED=OFF
make -j4
通过Vela运行:
bash
cd ml-embedded-evaluation-kit
mkdir build_img_person_detect_npu && cd build_img_person_detect_npu
cmake ../ -DUSE_CASE_BUILD=img_person_detect -DETHOS_U_NPU_ENABLED=ON
make -j4
5.2 Yolo Fastest Object Detection示例
bash
cd ml-embedded-evaluation-kit
mkdir build_img_yolofastest_relu6_256_himax_npu && cd build_img_yolofastest_relu6_256_himax_npu
cmake ../ -DUSE_CASE_BUILD=img_yolofastest_relu6_256_himax -DETHOS_U_NPU_ENABLED=ON
make -j4
5.3 Yolo Fastest XL Object Detection示例
bash
cd ml-embedded-evaluation-kit
mkdir build_img_yolofastest_xl_relu6_256_himax_npu && cd build_img_yolofastest_xl_relu6_256_himax_npu
cmake ../ -DUSE_CASE_BUILD=img_yolofastest_xl_relu6_256_himax -DETHOS_U_NPU_ENABLED=ON
make -j4
6. 运行推理
根据构建的示例,使用以下命令在FVP上运行推理:
bash
CS300FVP/models/Linux64_GCC-6.4/FVP_Corstone_SSE-300_Ethos-U55 -C ethosu.num_macs=64 ml-embedded-evaluation-kit/build_img_person_detect_npu/bin/ethos-u-img_person_detect.axf
确保ethosu.num_macs
与Vela模型配置匹配,否则推理将失败。通过以上步骤,可在FVP模拟环境中构建和运行基于Arm Cortex - M55和Ethos - U55 NPU的机器学习应用。
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】