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

PaddleDetection2.0提供了针对不同场景的基于PaddlePaddle的检测模型,用户可以下载模型进行使用。
| 任务 | 算法 | 精度(Box AP) | 下载 | 配置文件 |
|---|---|---|---|---|
| 行人检测 | YOLOv3 | 51.8 | 下载链接 | 配置文件 |
行人检测的主要应用有智能监控。在监控场景中,大多是从公共区域的监控摄像头视角拍摄行人,获取图像后再进行行人检测。
# 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
%cd ~/PaddleDetection !pip install -r requirements.txt
Backbone为Dacknet53的YOLOv3。
PaddleDetection提供了使用COCO数据集对YOLOv3进行训练的参数配置文件yolov3_darknet53_270e_coco.yml,与之相比,在进行行人检测的模型训练时,我们对以下参数进行了修改:
具体如下所示:
num_classes: 1
TrainDataset:
!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: val2017
TestDataset:
!ImageFolder
anno_path: configs/pedestrian/pedestrian.json模型在我们针对监控场景的内部数据上精度指标为:
IOU=.5时的AP为 0.792。
IOU=.5-.95时的AP为 0.518。
用户可以使用我们训练好的模型进行行人检测:
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%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/outputimport matplotlib.image as mpimgimport matplotlib.pyplot as pltimport os
path = '/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()<Figure size 11520x2880 with 4 Axes>
以上就是【PaddleDetection2.0专项】快速实现行人检测的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号