本文介绍如何用PaddleDetection2.0快速实现行人检测。先说明其提供多种检测模型,行人检测可用YOLOv3,精度51.8,适用于智能监控。接着讲操作步骤,包括克隆仓库、安装依赖,还介绍了模型结构、训练参数配置(改类别数和数据集路径)、精度指标及预测方法与示例。
☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

【PaddleDetection2.0专项】快速实现行人检测
PaddleDetection2.0提供了针对不同场景的基于PaddlePaddle的检测模型,用户可以下载模型进行使用。
行人检测YOLOv351.8下载链接配置文件
行人检测(Pedestrian Detection)
行人检测的主要应用有智能监控。在监控场景中,大多是从公共区域的监控摄像头视角拍摄行人,获取图像后再进行行人检测。
克隆PaddleDetection仓库
In [1]
# gitee 国内下载比较快!git clone https://gitee.com/paddlepaddle/PaddleDetection.git -b release/2.0 # github# !git clone https://github.com/PaddlePaddle/PaddleDetection.git -b release/2.0
In [2]
%cd ~/PaddleDetection!pip install -r requirements.txt
1. 模型结构
Backbone为Dacknet53的YOLOv3。
2. 训练参数配置
PaddleDetection提供了使用COCO数据集对YOLOv3进行训练的参数配置文件yolov3_darknet53_270e_coco.yml,与之相比,在进行行人检测的模型训练时,我们对以下参数进行了修改:
num_classes: 1dataset_dir: dataset/pedestrian
具体如下所示:
num_classes: 1TrainDataset: !COCODataSet dataset_dir: dataset/pedestrian anno_path: annotations/instances_train2017.json image_dir: train2017 data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd']EvalDataset: !COCODataSet dataset_dir: dataset/pedestrian anno_path: annotations/instances_val2017.json image_dir: val2017TestDataset: !ImageFolder anno_path: configs/pedestrian/pedestrian.json
2. 精度指标
模型在我们针对监控场景的内部数据上精度指标为:
IOU=.5时的AP为 0.792。
IOU=.5-.95时的AP为 0.518。
3. 预测
用户可以使用我们训练好的模型进行行人检测:
export CUDA_VISIBLE_DEVICES=0python -u tools/infer.py -c configs/pedestrian/pedestrian_yolov3_darknet.yml -o weights=https://paddledet.bj.bcebos.com/models/pedestrian_yolov3_darknet.pdparams --infer_dir configs/pedestrian/demo --draw_threshold 0.3 --output_dir configs/pedestrian/demo/output
In [5]
%cd ~/PaddleDetection/!export CUDA_VISIBLE_DEVICES=0!python -u tools/infer.py -c configs/pedestrian/pedestrian_yolov3_darknet.yml -o weights=https://paddledet.bj.bcebos.com/models/pedestrian_yolov3_darknet.pdparams --infer_dir configs/pedestrian/demo --draw_threshold 0.3 --output_dir configs/pedestrian/demo/output
预测结果示例:
In [16]
import matplotlib.image as mpimgimport matplotlib.pyplot as pltimport ospath = '/home/aistudio/PaddleDetection/configs/pedestrian/demo/output'imgs = os.listdir(path)plt.figure(figsize=(160, 40))for i in range(len(imgs)): img_path = os.path.join(path, imgs[i]) img = mpimg.imread(img_path) plt.subplot(4, 1, i+1) plt.imshow(img)plt.show()
以上就是【PaddleDetection2.0专项】快速实现行人检测的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/58375.html
微信扫一扫
支付宝扫一扫