diff --git a/README.md b/README.md index 47d502acbfb722b0487bb6eb4b2451ed375b2a94..48f776c255497bd93810f8efe32e3eaf1919f4cc 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,8 @@ Lockzhiner Vision Module 拥有丰富的 IO 接口,其接口图片如下图所 * [凌智视觉模块条码检测与识别部署指南](./example/special/bar_code_recognition) * [凌智视觉模块人脸检测部署指南](example/vision/face_detection) * [凌智视觉模块人脸识别部署指南](example/vision/face_recognition) +* [凌智视觉模块猫狗识别部署指南](example/special/cat_and_dog_classification) +* [凌智视觉模块花卉识别部署指南](example/special/flower_classfication/) ## 🐛 Bug反馈 diff --git a/example/special/cat_and_dog_classification/README.md b/example/special/cat_and_dog_classification/README.md new file mode 100644 index 0000000000000000000000000000000000000000..79e003e27e51fa3ae60660d1e7229d089b44d235 --- /dev/null +++ b/example/special/cat_and_dog_classification/README.md @@ -0,0 +1,50 @@ +

凌智视觉模块猫狗分类识别部署指南

+ +发布版本:V0.0.0 + +日期:2024-11-13 + +文件密级:□绝密 □秘密 □内部资料 ■公开 + +--- + +**免责声明** + +本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。 + +由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。 + +**读者对象** + +本教程适用于以下工程师: + +- 技术支持工程师 +- 软件开发工程师 + +**修订记录** + +| **日期** | **版本** | **作者** | **修改说明** | +| :--------- | -------- | -------- | ------------ | +| 2024/11/13 | 0.0.0 | 钟海滨 | 初始版本 | + +## 1 简介 + +猫狗分类是计算机视觉入门的常见任务,我们基于 [凌智视觉模块分类模型部署指南](../../vision/classification) 训练了凌智视觉模块专用的模型,该模型能够实现对猫狗分类识别。 + +## 2 运行前的准备 + +- 请确保你已经下载了 [凌智视觉模块猫狗分类识别模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.2/LZ-Dog-and-Cat-classfication.rknn) + +## 3 在凌智视觉模块上部署猫狗分类识别案例 + +下载模型后,请参考以下教程使用 Python 在凌智视觉模块上部署分类模型例程: + +- [凌智视觉模块猫狗分类识别 Python 部署指南](./python) + +## 4 模型性能指标 + +以下测试数据为模型执行 Predict 函数运行 1000 次耗时的平均时间 + +| 分类模型 | FPS(帧/s) | 精度(%) | +|:-------:|:----:|:----:| +|LZ-Flower-Classfication|35|| diff --git a/example/special/cat_and_dog_classification/python/README.md b/example/special/cat_and_dog_classification/python/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b788cca34a0cd5670e2ee3a09dca9d5d92cb72a5 --- /dev/null +++ b/example/special/cat_and_dog_classification/python/README.md @@ -0,0 +1,108 @@ +

凌智视觉模块猫狗分类识别 Python 部署指南

+ +发布版本:V0.0.0 + +日期:2024-11-13 + +文件密级:□绝密 □秘密 □内部资料 ■公开 + +--- + +**免责声明** + +本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。 + +由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。 + +**读者对象** + +本教程适用于以下工程师: + +- 技术支持工程师 +- 软件开发工程师 + +**修订记录** + +| **日期** | **版本** | **作者** | **修改说明** | +| :--------- | -------- | -------- | ------------ | +| 2024/11/13 | 0.0.0 | 钟海滨 | 初始版本 | + +## 1 简介 + +接下来让我们基于 Python 来部署猫狗分类识别案例,在开始本章节前: + +- 请确保你已经参考 [凌智视觉模块猫狗分类识别部署指南](../README.md) 正确下载了模型。 +- 请确保你已经参考 [凌智视觉模块摄像头部署指南](../../../periphery/capture/README.md) 正确下载了凌智视觉模块图片传输助手。 +- 请确保你已经按照 [开发环境搭建指南](../../../../docs/introductory_tutorial/python_development_environment.md) 正确配置了开发环境。 + +## 2 Python API 文档 + +同[分类模型 Python 部署 API 文档](../../../vision/classification/python/README.md) + +## 3 项目介绍 + +为了方便大家入手,我们做了一个简易的猫狗分类识别例程。该程序可以使用摄像头进行端到端推理,并可视化推理结果到凌智视觉模块图片传输助手。 + +```python +from lockzhiner_vision_module.cv2 import VideoCapture +from lockzhiner_vision_module.vision import PaddleClas, visualize +from lockzhiner_vision_module.edit import Edit +import sys + +if __name__ == "__main__": + args = sys.argv + if len(args) != 2: + print("Need model path. Example: python test_dog_and_cat_classfication.py LZ-Dog-and-Cat-Classfication.rknn") + exit(1) + + edit = Edit() + edit.start_and_accept_connection() + + model = PaddleClas() + if model.initialize(args[1]) is False: + print("Failed to initialize PaddleClas") + exit(1) + + video_capture = VideoCapture() + if video_capture.open(0) is False: + print("Failed to open capture") + exit(1) + + while True: + ret, mat = video_capture.read() + if ret is False: + continue + + result = model.predict(mat) + print(f"The label_id is {result.label_id} and the score is {result.score}") + + vis_mat = visualize(mat, result) + edit.print(vis_mat) +``` + +## 4 上传并测试 Python 程序 + +参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。 + +![](../../../../docs/introductory_tutorial/images/connect_device_using_ssh/ssh_success.png) + +请使用 Electerm Sftp 依次上传以下两个文件: + +- 进入存放 **test_dog_and_cat_classfication.py** 脚本文件的目录,将 **test_dog_and_cat_classfication.py** 上传到 Lockzhiner Vision Module +- 进入存放 **LZ-Dog-and-Cat-Classfication.rknn** 模型存放的目录(模型存放在训练模型后下载的 output 文件夹内),将 **LZ-Dog-and-Cat-Classfication.rknn** 上传到 Lockzhiner Vision Module + +![](images/stfp.png) + +请使用 Electerm Ssh 并在命令行中执行以下命令: + +```bash +python test_dog_and_cat_classfication.py LZ-Dog-and-Cat-Classfication.rknn +``` + +运行程序后,使用凌智视觉模块图片传输助手连接设备,屏幕上开始打印标签索引和置信度,凌智视觉模块图片传输助手出现可视化的结果 + +![alt text](images/cat.png) + + + + diff --git a/example/special/cat_and_dog_classification/python/images/cat.png b/example/special/cat_and_dog_classification/python/images/cat.png new file mode 100644 index 0000000000000000000000000000000000000000..d39bebd46a9083bd30b881b4510e27977aabf5b6 Binary files /dev/null and b/example/special/cat_and_dog_classification/python/images/cat.png differ diff --git a/example/special/cat_and_dog_classification/python/images/stfp.png b/example/special/cat_and_dog_classification/python/images/stfp.png new file mode 100644 index 0000000000000000000000000000000000000000..ed0aa465776c65c295de9c8e051ba65573ef89a9 Binary files /dev/null and b/example/special/cat_and_dog_classification/python/images/stfp.png differ diff --git a/example/special/cat_and_dog_classification/python/test_dog_and_cat_classfication.py b/example/special/cat_and_dog_classification/python/test_dog_and_cat_classfication.py new file mode 100644 index 0000000000000000000000000000000000000000..ac43bf881122aa59979188844f7951803850a5e4 --- /dev/null +++ b/example/special/cat_and_dog_classification/python/test_dog_and_cat_classfication.py @@ -0,0 +1,36 @@ +from lockzhiner_vision_module.cv2 import VideoCapture +from lockzhiner_vision_module.vision import PaddleClas, visualize +from lockzhiner_vision_module.edit import Edit +import sys + +if __name__ == "__main__": + args = sys.argv + if len(args) != 2: + print( + "Need model path. Example: python test_flower_classfication.py LZ-DigitHandRecog.rknn" + ) + exit(1) + + edit = Edit() + edit.start_and_accept_connection() + + model = PaddleClas() + if model.initialize(args[1]) is False: + print("Failed to initialize PaddleClas") + exit(1) + + video_capture = VideoCapture() + if video_capture.open(0) is False: + print("Failed to open capture") + exit(1) + + while True: + ret, mat = video_capture.read() + if ret is False: + continue + + result = model.predict(mat) + print(f"The label_id is {result.label_id} and the score is {result.score}") + + vis_mat = visualize(mat, result) + edit.print(vis_mat) diff --git a/example/special/flower_classfication/README.md b/example/special/flower_classfication/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0a875177c804b5fe25aa5022dcc837b92a63e565 --- /dev/null +++ b/example/special/flower_classfication/README.md @@ -0,0 +1,50 @@ +

凌智视觉模块花卉分类识别部署指南

+ +发布版本:V0.0.0 + +日期:2024-11-13 + +文件密级:□绝密 □秘密 □内部资料 ■公开 + +--- + +**免责声明** + +本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。 + +由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。 + +**读者对象** + +本教程适用于以下工程师: + +- 技术支持工程师 +- 软件开发工程师 + +**修订记录** + +| **日期** | **版本** | **作者** | **修改说明** | +| :--------- | -------- | -------- | ------------ | +| 2024/11/13 | 0.0.0 | 钟海滨 | 初始版本 | + +## 1 简介 + +花卉的种类繁多,为了应对花卉种类繁多带来的分类挑战,我们基于 [凌智视觉模块分类模型部署指南](../../vision/classification) 训练了凌智视觉模块专用的模型,该模型能够实现对五种常见花卉的精确分类,包括向日葵、蒲公英、雏菊、玫瑰和郁金香。 + +## 2 运行前的准备 + +- 请确保你已经下载了 [凌智视觉模块花卉分类识别模型](https://gitee.com/LockzhinerAI/LockzhinerVisionModule/releases/download/v0.0.2/LZ-Flower-Classfication.rknn) + +## 3 在凌智视觉模块上部署花卉分类识别案例 + +下载模型后,请参考以下教程使用 Python 在凌智视觉模块上部署分类模型例程: + +- [凌智视觉模块花卉分类识别 Python 部署指南](./python) + +## 4 模型性能指标 + +以下测试数据为模型执行 Predict 函数运行 1000 次耗时的平均时间 + +| 分类模型 | FPS(帧/s) | 精度(%) | +|:-------:|:----:|:----:| +|LZ-Flower-Classfication|35|| diff --git a/example/special/flower_classfication/python/README.md b/example/special/flower_classfication/python/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6c853b30d7c553e9dfa61a5e9e27dc80b8da7ad2 --- /dev/null +++ b/example/special/flower_classfication/python/README.md @@ -0,0 +1,108 @@ +

凌智视觉模块花卉分类识别 Python 部署指南

+ +发布版本:V0.0.0 + +日期:2024-11-13 + +文件密级:□绝密 □秘密 □内部资料 ■公开 + +--- + +**免责声明** + +本文档按**现状**提供,福州凌睿智捷电子有限公司(以下简称**本公司**)不对本文档中的任何陈述、信息和内容的准确性、可靠性、完整性、适销性、适用性及非侵权性提供任何明示或暗示的声明或保证。本文档仅作为使用指导的参考。 + +由于产品版本升级或其他原因,本文档可能在未经任何通知的情况下不定期更新或修改。 + +**读者对象** + +本教程适用于以下工程师: + +- 技术支持工程师 +- 软件开发工程师 + +**修订记录** + +| **日期** | **版本** | **作者** | **修改说明** | +| :--------- | -------- | -------- | ------------ | +| 2024/11/13 | 0.0.0 | 钟海滨 | 初始版本 | + +## 1 简介 + +接下来让我们基于 Python 来部署花卉分类识别案例,在开始本章节前: + +- 请确保你已经参考 [凌智视觉模块花卉分类识别部署指南](../README.md) 正确下载了模型。 +- 请确保你已经参考 [凌智视觉模块摄像头部署指南](../../../periphery/capture/README.md) 正确下载了凌智视觉模块图片传输助手。 +- 请确保你已经按照 [开发环境搭建指南](../../../../docs/introductory_tutorial/python_development_environment.md) 正确配置了开发环境。 + +## 2 Python API 文档 + +同[分类模型 Python 部署 API 文档](../../../vision/classification/python/README.md) + +## 3 项目介绍 + +为了方便大家入手,我们做了一个简易的花卉分类识别例程。该程序可以使用摄像头进行端到端推理,并可视化推理结果到凌智视觉模块图片传输助手。 + +```python +from lockzhiner_vision_module.cv2 import VideoCapture +from lockzhiner_vision_module.vision import PaddleClas, visualize +from lockzhiner_vision_module.edit import Edit +import sys + +if __name__ == "__main__": + args = sys.argv + if len(args) != 2: + print("Need model path. Example: python test_flower-classfication.py LZ-Flower-Classfication.rknn") + exit(1) + + edit = Edit() + edit.start_and_accept_connection() + + model = PaddleClas() + if model.initialize(args[1]) is False: + print("Failed to initialize PaddleClas") + exit(1) + + video_capture = VideoCapture() + if video_capture.open(0) is False: + print("Failed to open capture") + exit(1) + + while True: + ret, mat = video_capture.read() + if ret is False: + continue + + result = model.predict(mat) + print(f"The label_id is {result.label_id} and the score is {result.score}") + + vis_mat = visualize(mat, result) + edit.print(vis_mat) +``` + +## 4 上传并测试 Python 程序 + +参考 [连接设备指南](../../../../docs/introductory_tutorial/connect_device_using_ssh.md) 正确连接 Lockzhiner Vision Module 设备。 + +![](../../../../docs/introductory_tutorial/images/connect_device_using_ssh/ssh_success.png) + +请使用 Electerm Sftp 依次上传以下两个文件: + +- 进入存放 **test_flower-classfication.py** 脚本文件的目录,将 **test_flower-classfication.py** 上传到 Lockzhiner Vision Module +- 进入存放 **LZ-Flower-Classfication.rknn** 模型存放的目录(模型存放在训练模型后下载的 output 文件夹内),将 **LZ-Flower-Classfication.rknn** 上传到 Lockzhiner Vision Module + +![](images/stfp.png) + +请使用 Electerm Ssh 并在命令行中执行以下命令: + +```bash +python test_flower_classfication.py LZ-DigitHandRecog.rknn +``` + +运行程序后,使用凌智视觉模块图片传输助手连接设备,屏幕上开始打印标签索引和置信度,凌智视觉模块图片传输助手出现可视化的结果 + +![alt text](images/tulips.png) + + + + diff --git a/example/special/flower_classfication/python/images/daisy.png b/example/special/flower_classfication/python/images/daisy.png new file mode 100644 index 0000000000000000000000000000000000000000..5af34de99568b5dc6cb5716f5c6e9f2b708bfb2d Binary files /dev/null and b/example/special/flower_classfication/python/images/daisy.png differ diff --git a/example/special/flower_classfication/python/images/dandelion.png b/example/special/flower_classfication/python/images/dandelion.png new file mode 100644 index 0000000000000000000000000000000000000000..cc8daf50f38a16a8aa9af1f7586caa7a34735826 Binary files /dev/null and b/example/special/flower_classfication/python/images/dandelion.png differ diff --git a/example/special/flower_classfication/python/images/roses.png b/example/special/flower_classfication/python/images/roses.png new file mode 100644 index 0000000000000000000000000000000000000000..490425ed8a84d055ef1d6e9d5f05179ca5fed5b6 Binary files /dev/null and b/example/special/flower_classfication/python/images/roses.png differ diff --git a/example/special/flower_classfication/python/images/stfp.png b/example/special/flower_classfication/python/images/stfp.png new file mode 100644 index 0000000000000000000000000000000000000000..02d7cc03282dd76568b3b8ebe8a5138890a58d46 Binary files /dev/null and b/example/special/flower_classfication/python/images/stfp.png differ diff --git a/example/special/flower_classfication/python/images/sunflower.png b/example/special/flower_classfication/python/images/sunflower.png new file mode 100644 index 0000000000000000000000000000000000000000..28338efd74af4ed09eb9a9141ccfd230bd91cf8d Binary files /dev/null and b/example/special/flower_classfication/python/images/sunflower.png differ diff --git a/example/special/flower_classfication/python/images/tulips.png b/example/special/flower_classfication/python/images/tulips.png new file mode 100644 index 0000000000000000000000000000000000000000..6ba24f31ec95a3f62ac63340b7be7423ff28913c Binary files /dev/null and b/example/special/flower_classfication/python/images/tulips.png differ diff --git a/example/special/flower_classfication/python/test_flower-classfication.py b/example/special/flower_classfication/python/test_flower-classfication.py new file mode 100644 index 0000000000000000000000000000000000000000..ac43bf881122aa59979188844f7951803850a5e4 --- /dev/null +++ b/example/special/flower_classfication/python/test_flower-classfication.py @@ -0,0 +1,36 @@ +from lockzhiner_vision_module.cv2 import VideoCapture +from lockzhiner_vision_module.vision import PaddleClas, visualize +from lockzhiner_vision_module.edit import Edit +import sys + +if __name__ == "__main__": + args = sys.argv + if len(args) != 2: + print( + "Need model path. Example: python test_flower_classfication.py LZ-DigitHandRecog.rknn" + ) + exit(1) + + edit = Edit() + edit.start_and_accept_connection() + + model = PaddleClas() + if model.initialize(args[1]) is False: + print("Failed to initialize PaddleClas") + exit(1) + + video_capture = VideoCapture() + if video_capture.open(0) is False: + print("Failed to open capture") + exit(1) + + while True: + ret, mat = video_capture.read() + if ret is False: + continue + + result = model.predict(mat) + print(f"The label_id is {result.label_id} and the score is {result.score}") + + vis_mat = visualize(mat, result) + edit.print(vis_mat)