# sample-yolov3detection-python **Repository Path**: yushanjin/sample-yolov3detection-python ## Basic Information - **Project Name**: sample-yolov3detection-python - **Description**: 参考https://gitee.com/Atlas200DK/sample-fasterrcnndetection-python和https://bbs.huaweicloud.com/blogs/171906 实现推理的python工程 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-08-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # sample-yolov3detection-python ## 介绍 参考: https://gitee.com/Atlas200DK/sample-fasterrcnndetection-python 和 https://bbs.huaweicloud.com/blogs/171906 实现推理的python工程 ## 使用说明 1. 下载工程需要的模型文件 链接: https://pan.baidu.com/s/1xpZFGus-oTrUDajk1X2LrA 提取码: w74e 2. Atlas 200 DK 上的配置及操作,参考:https://gitee.com/Atlas200DK/sample-fasterrcnndetection-python 3. 支持mp4及rtsp视频流推理 ## 代码目录结构 ![输入图片说明](https://images.gitee.com/uploads/images/2020/0827/172039_da4a51e1_6552000.png "屏幕截图.png") ## 开发板上执行推理: rtsp视频流输入:python main.py rtsp://admin:xxxxx@10.0.x.x:554 view_1 或者 mp4文件视频流输入:python main.py /home/person_and_car.mp4 view_2 ### 测试结果如下: | 视频类型 | 视频来源 | 分辨率(宽*高) | 仅预处理耗时 | 仅推理耗时 | 整个推理过程耗时(包含预处理以及后处理)| | --- | --- | --- | --- | --- | --- | | 视频文件(.mp4) | person_and_car.mp4 | 640*480 | 10ms左右 | 30ms左右 | 180~190ms | | 视频文件(.mp4) | person.mp4 1 | 1920*1080 | 20ms左右 | 25~30ms左右 | 300~400ms | | 视频文件(.mp4) | shopping_hall.mp4 | 1280*720 | 16ms左右 | 27ms左右 | 230~250ms | | 实时视频流(rtsp) | 海康摄像头 | 1920*1080 | 20~30ms | 25~30ms左右 | 320~380ms | 截取一部分打印: Preprocess cost time: 20.4229354858ms Inference cost time: 31.4059257507ms Postprocess-compute detection result of cost time: 102.829933167ms Postprocess-package data of cost time: 159.300088882ms Postprocess-send data to presenter server of cost time: 90.8269882202ms The whole Inference cost time: 405.614852905ms 优化前代码,请参考old分支 ### 将整个推理过程细化为以下5步,优化: 1、预处理 2、推理 3、后处理-计算检测框 4、后处理-打包数据(图片及检测框数据) 5、后处理-发送数据 计算检测框优化:yolov3模型默认检测80种物体,如果计算检测框只检测一种或者两种物体(utils.py文件的get_result函数) 打包及发送数据优化:yolov3模型输入是416\*416,但是此工程打包是基于原始像素图片及检测框进行打包的,修改为416\*416像素的图片及检测框直接打包 截取一部分打印: Preprocess cost time: 23.0159759521ms Inference cost time: 31.0800075531ms Postprocess-compute detection result of cost time: 19.8609828949ms Postprocess-package data of cost time: 16.3068771362ms Postprocess-send data to presenter server of cost time: 0.19097328186ms The whole Inference cost time: 92.0169353485ms 需要进一步研究:预处理耗时20ms(有点长了)