mobilenetv2
功能介绍
mobilenetv2图片分类算法示例使用图片作为输入,利用BPU进行算法推理,发布包含物体类别的算法msg。
mobilenetv2是使用ImageNet data数据集训练出来的caffe模型,模型来源: https://github.com/shicai/MobileNet-Caffe 。
支持的目标类型包括人、动物、水果、交通工具等共1000种类型。具体支持的类别详见RDK板端文件 /opt/tros/${TROS_DISTRO}
/lib/dnn_node_example/config/imagenet.list(已安装TogatherROS.Bot)。
代码仓库: https://github.com/D-Robotics/hobot_dnn
应用场景:mobilenetv2能够预测给定图片的类别,可实现数字识别、物体识别等功能,主要应用于文字识别、图像检索等领域。
食品类型识别案例: https://github.com/frotms/Chinese-and-Western-Food-Classification
支持平台
平台 | 运行方式 | 示例功能 |
---|---|---|
RDK X3, RDK X3 Module | Ubuntu 20.04 (Foxy), Ubuntu 22.04 (Humble) | · 启动MIPI/USB摄像头,并通过web展示推理渲染结果 · 使用本地回灌,渲染结果保存在本地 |
RDK X5, RDK X5 Module | Ubuntu 22.04 (Humble) | · 启动MIPI/USB摄像头,并通过web展示推理渲染结果 · 使用本地回灌,渲染结果保存在本地 |
RDK Ultra | Ubuntu 20.04 (Foxy) | · 启动MIPI/USB摄像头,并通过web展示推理渲染结果 · 使用本地回灌,渲染结果保存在本地 |
RDK S100 | Ubuntu 22.04 (Humble) | · 启动MIPI/USB摄像头,并通过web展示推理渲染结果 · 使用本地回灌,渲染结果保存在本地 |
X86 | Ubuntu 20.04 (Foxy) | · 使用本地回灌,渲染结果保存在本地 |
准备工作
RDK平台
-
RDK已烧录好Ubuntu 20.04/Ubuntu 22.04系统镜像。
-
RDK已成功安装tros.b。
-
RDK已安装MIPI或者USB摄像头,无摄像头的情况下通过回灌本地JPEG/PNG格式图片或者MP4、H.264和H.265的视频方式体验算法效果。
-
确认PC机能够通过网络访问RDK。
X86平台
-
X86环境已配置好Ubuntu 20.04系统镜像。
-
X86环境系统已成功安装tros.b。
使用介绍
RDK平台
mobilenetv2图片分类订阅sensor package发布的图片,经过推理后发布算法msg,通过websocket package实现在PC端浏览器上渲染显示发布的图片和对应的算法结果。
使用MIPI摄像头发布图片
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 配置MIPI摄像头
export CAM_TYPE=mipi
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example.launch.py dnn_example_config_file:=config/mobilenetv2workconfig.json dnn_example_image_width:=480 dnn_example_image_height:=272
使用USB摄像头发布图片
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 配置USB摄像头
export CAM_TYPE=usb
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example.launch.py dnn_example_config_file:=config/mobilenetv2workconfig.json dnn_example_image_width:=480 dnn_example_image_height:=272
使用本地图片回灌
mobilenetv2图片分类算法示例使用本地JPEG/PNG格式图片回灌,经过推理后将算法结果渲染后的图片存储在本地的运行路径下。
- Foxy
- Humble
# 配置tros.b环境
source /opt/tros/setup.bash
# 配置tros.b环境
source /opt/tros/humble/setup.bash
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/mobilenetv2workconfig.json dnn_example_image:=config/target_class.jpg
X86平台
使用本地图片回灌
mobilenetv2图片分类算法示例使用本地JPEG/PNG格式图片回灌,经过推理后将算法结果渲染后的图片存储在本地的运行路径下。
# 配置tros.b环境
source /opt/tros/setup.bash
# 启动launch文件
ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/mobilenetv2workconfig.json dnn_example_image:=config/target_class.jpg