提交 bdf0fdc1 编写于 作者: F FlyingQianMM 提交者: GitHub

add models and documents for vehicle and pedestrian detection (#3559)

* add modes and documents for vehicle and pedestrian detection

* remove needless output images

* add class names

* add Configure for training

* fix table in READ.md

* compress the images in the demo/output

* change the score_threshold for vehicle inference

* change Yolo v3 to YOLOv3
上级 0a2e0a6d
{
"images": [],
"annotations": [],
"categories": [
{
"supercategory": "component",
"id": 1,
"name": "pedestrian"
}
]
}
architecture: YOLOv3
train_feed: YoloTrainFeed
eval_feed: YoloEvalFeed
test_feed: YoloTestFeed
use_gpu: true
max_iters: 200000
log_smooth_window: 20
save_dir: output
snapshot_iter: 5000
metric: COCO
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar
weights: https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar
num_classes: 1
YOLOv3:
backbone: DarkNet
yolo_head: YOLOv3Head
DarkNet:
norm_type: sync_bn
norm_decay: 0.
depth: 53
YOLOv3Head:
anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
anchors: [[10, 13], [16, 30], [33, 23],
[30, 61], [62, 45], [59, 119],
[116, 90], [156, 198], [373, 326]]
norm_decay: 0.
ignore_thresh: 0.7
label_smooth: true
nms:
background_label: -1
keep_top_k: 100
nms_threshold: 0.45
nms_top_k: 1000
normalized: false
score_threshold: 0.01
LearningRate:
base_lr: 0.001
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones:
- 150000
- 180000
- !LinearWarmup
start_factor: 0.
steps: 4000
OptimizerBuilder:
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0005
type: L2
YoloTrainFeed:
batch_size: 8
dataset:
dataset_dir: dataset/pedestrian
annotation: annotations/instances_train2017.json
image_dir: train2017
num_workers: 8
bufsize: 128
use_process: true
YoloEvalFeed:
batch_size: 8
image_shape: [3, 608, 608]
dataset:
dataset_dir: dataset/pedestrian
annotation: annotations/instances_val2017.json
image_dir: val2017
YoloTestFeed:
batch_size: 1
image_shape: [3, 608, 608]
dataset:
annotation: contrib/PedestrianDetection/pedestrian.json
# PaddleDetection applied for specific scenarios
We provide some models implemented by PaddlePaddle to detect objects in specific scenarios, users can download the models and use them in these scenarios.
| Task | Algorithm | Box AP | Download |
|:---------------------|:---------:|:------:| :-------------------------------------------------------------------------------------: |
| Vehicle Detection | YOLOv3 | 54.5 | [model](https://paddlemodels.bj.bcebos.com/object_detection/vehicle_yolov3_darknet.tar) |
| Pedestrian Detection | YOLOv3 | 51.8 | [model](https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar) |
## Vehicle Detection
One of major applications of vehichle detection is traffic monitoring. In this scenary, vehicles to be detected are mostly captured by the cameras mounted on top of traffic light columns.
### 1. Network
The network for detecting vehicles is YOLOv3, the backbone of which is Dacknet53.
### 2. Configuration for training
PaddleDetection provides users with a configuration file [yolov3_darnet.yml](https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml) to train YOLOv3 on the COCO dataset, compared with this file, we modify some parameters as followed to conduct the training for vehicle detection:
* max_iters: 120000
* num_classes: 6
* anchors: [[8, 9], [10, 23], [19, 15], [23, 33], [40, 25], [54, 50], [101, 80], [139, 145], [253, 224]]
* label_smooth: false
* nms/nms_top_k: 400
* nms/score_threshold: 0.005
* milestones: [60000, 80000]
* dataset_dir: dataset/vehicle
### 3. Accuracy
The accuracy of the model trained and evaluated on our private data is shown as followed:
AP at IoU=.50:.05:.95 is 0.545.
AP at IoU=.50 is 0.764.
### 4. Inference
Users can employ the model to conduct the inference:
```
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
python -u tools/infer.py -c contrib/VehicleDetection/vehicle_yolov3_darknet.yml \
-o weights=https://paddlemodels.bj.bcebos.com/object_detection/vehicle_yolov3_darknet.tar \
--infer_dir contrib/VehicleDetection/demo \
--draw_threshold 0.2 \
--output_dir contrib/VehicleDetection/demo/output
```
Some inference results are visualized below:
![](VehicleDetection/demo/output/001.jpeg)
![](VehicleDetection/demo/output/005.png)
## Pedestrian Detection
The main applications of pedetestrian detection include intelligent monitoring. In this scenary, photos of pedetestrians are taken by surveillance cameras in public areas, then pedestrian detection are conducted on these photos.
### 1. Network
The network for detecting vehicles is YOLOv3, the backbone of which is Dacknet53.
### 2. Configuration for training
PaddleDetection provides users with a configuration file [yolov3_darnet.yml](https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml) to train YOLOv3 on the COCO dataset, compared with this file, we modify some parameters as followed to conduct the training for pedestrian detection:
* max_iters: 200000
* num_classes: 1
* snapshot_iter: 5000
* milestones: [150000, 180000]
* dataset_dir: dataset/pedestrian
### 3. Accuracy
The accuracy of the model trained and evaluted on our private data is shown as followed:
AP at IoU=.50:.05:.95 is 0.518.
AP at IoU=.50 is 0.792.
### 4. Inference
Users can employ the model to conduct the inference:
```
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
python -u tools/infer.py -c contrib/PedestrianDetection/pedestrian_yolov3_darknet.yml \
-o weights=https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar \
--infer_dir contrib/PedestrianDetection/demo \
--draw_threshold 0.3 \
--output_dir contrib/PedestrianDetection/demo/output
```
Some inference results are visualized below:
![](PedestrianDetection/demo/output/001.png)
![](PedestrianDetection/demo/output/004.png)
# PaddleDetection 特色垂类检测模型
我们提供了针对不同场景的基于PaddlePaddle的检测模型,用户可以下载模型进行使用。
| 任务 | 算法 | 精度(Box AP) | 下载 |
|:---------------------|:---------:|:------:| :---------------------------------------------------------------------------------: |
| 车辆检测 | YOLOv3 | 54.5 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/vehicle_yolov3_darknet.tar) |
| 行人检测 | YOLOv3 | 51.8 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar) |
## 车辆检测(Vehicle Detection)
车辆检测的主要应用之一是交通监控。在这样的监控场景中,待检测的车辆多为道路红绿灯柱上的摄像头拍摄所得。
### 1. 模型结构
Backbone为Dacknet53的YOLOv3。
### 2. 训练参数配置
PaddleDetection提供了使用COCO数据集对YOLOv3进行训练的参数配置文件[yolov3_darnet.yml](https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml),与之相比,在进行车辆检测的模型训练时,我们对以下参数进行了修改:
* max_iters: 120000
* num_classes: 6
* anchors: [[8, 9], [10, 23], [19, 15], [23, 33], [40, 25], [54, 50], [101, 80], [139, 145], [253, 224]]
* label_smooth: false
* nms/nms_top_k: 400
* nms/score_threshold: 0.005
* milestones: [60000, 80000]
* dataset_dir: dataset/vehicle
### 3. 精度指标
模型在我们内部数据上的精度指标为:
IOU=.50:.05:.95时的AP为 0.545。
IOU=.5时的AP为 0.764。
### 4. 预测
用户可以使用我们训练好的模型进行车辆检测:
```
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
python -u tools/infer.py -c contrib/VehicleDetection/vehicle_yolov3_darknet.yml \
-o weights=https://paddlemodels.bj.bcebos.com/object_detection/vehicle_yolov3_darknet.tar \
--infer_dir contrib/VehicleDetection/demo \
--draw_threshold 0.2 \
--output_dir contrib/VehicleDetection/demo/output
```
预测结果示例:
![](VehicleDetection/demo/output/001.jpeg)
![](VehicleDetection/demo/output/005.png)
## 行人检测(Pedestrian Detection)
行人检测的主要应用有智能监控。在监控场景中,大多是从公共区域的监控摄像头视角拍摄行人,获取图像后再进行行人检测。
### 1. 模型结构
Backbone为Dacknet53的YOLOv3。
### 2. 训练参数配置
PaddleDetection提供了使用COCO数据集对YOLOv3进行训练的参数配置文件[yolov3_darnet.yml](https://github.com/PaddlePaddle/models/blob/develop/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml),与之相比,在进行行人检测的模型训练时,我们对以下参数进行了修改:
* max_iters: 200000
* num_classes: 1
* snapshot_iter: 5000
* milestones: [150000, 180000]
* dataset_dir: dataset/pedestrian
### 2. 精度指标
模型在我们针对监控场景的内部数据上精度指标为:
IOU=.5时的AP为 0.792。
IOU=.5-.95时的AP为 0.518。
### 3. 预测
用户可以使用我们训练好的模型进行行人检测:
```
export CUDA_VISIBLE_DEVICES=0
export PYTHONPATH=$PYTHONPATH:.
python -u tools/infer.py -c contrib/PedestrianDetection/pedestrian_yolov3_darknet.yml \
-o weights=https://paddlemodels.bj.bcebos.com/object_detection/pedestrian_yolov3_darknet.tar \
--infer_dir contrib/PedestrianDetection/demo \
--draw_threshold 0.3 \
--output_dir contrib/PedestrianDetection/demo/output
```
预测结果示例:
![](PedestrianDetection/demo/output/001.png)
![](PedestrianDetection/demo/output/004.png)
{
"images": [],
"annotations": [],
"categories": [
{
"supercategory": "component",
"id": 1,
"name": "car"
},
{
"supercategory": "component",
"id": 2,
"name": "truck"
},
{
"supercategory": "component",
"id": 3,
"name": "bus"
},
{
"supercategory": "component",
"id": 4,
"name": "motorbike"
},
{
"supercategory": "component",
"id": 5,
"name": "tricycle"
},
{
"supercategory": "component",
"id": 6,
"name": "carplate"
}
]
}
architecture: YOLOv3
train_feed: YoloTrainFeed
eval_feed: YoloEvalFeed
test_feed: YoloTestFeed
use_gpu: true
max_iters: 120000
log_smooth_window: 20
save_dir: output
snapshot_iter: 2000
metric: COCO
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar
weights: https://paddlemodels.bj.bcebos.com/object_detection/vehicle_yolov3_darknet.tar
num_classes: 6
YOLOv3:
backbone: DarkNet
yolo_head: YOLOv3Head
DarkNet:
norm_type: sync_bn
norm_decay: 0.
depth: 53
YOLOv3Head:
anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
anchors: [[8, 9], [10, 23], [19, 15],
[23, 33], [40, 25], [54, 50],
[101, 80], [139, 145], [253, 224]]
norm_decay: 0.
ignore_thresh: 0.7
label_smooth: false
nms:
background_label: -1
keep_top_k: 100
nms_threshold: 0.45
nms_top_k: 400
normalized: false
score_threshold: 0.005
LearningRate:
base_lr: 0.001
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones:
- 60000
- 80000
- !LinearWarmup
start_factor: 0.
steps: 4000
OptimizerBuilder:
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0005
type: L2
YoloTrainFeed:
batch_size: 8
dataset:
dataset_dir: dataset/vehicle
annotation: annotations/instances_train2017.json
image_dir: train2017
num_workers: 8
bufsize: 128
use_process: true
YoloEvalFeed:
batch_size: 8
image_shape: [3, 608, 608]
dataset:
dataset_dir: dataset/vehicle
annotation: annotations/instances_val2017.json
image_dir: val2017
YoloTestFeed:
batch_size: 1
image_shape: [3, 608, 608]
dataset:
annotation: contrib/VehicleDetection/vehicle.json
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册