智慧交通:基于PP-Vehicle的交通监控分析系统

项目背景

交通是兴国之要、强国之基。随着城市的快速发展、车辆和行人数量的日益增多,强依赖人力管控的传统交通治理模式在交通拥堵治理、信号调控、秩序改善等典型场景上,都遇到效率低下、人员监管成本高、错误率高的种种挑战。

飞桨PaddleDetection针对城市轨道交通、道路交通及高速公路,提供围绕车、路、环境的智能感知与分析能力工具PP-Vehicle,助力用户快速实现车流监控、车辆跟踪定位、异常停留/违停检测、车牌识别、车辆颜色与型号识别等10余种任务,从而缓解交通拥堵、改善交通状况,发挥城市交通最大效能。

本项目基于PP-Vehicle演示智慧交通中最刚需的车流量监控、车辆违停检测以及车辆结构化(车牌、车型、颜色)分析三大场景。

技术方案

1. 车流量监控

根据车辆运动轨迹跟踪结果,与设定出入线运动方向的关系,确定当前目标是进或者出。以此进行计数累积。

2.车辆的违停判断

判断车辆的违停,需要的是两个信息:1)该区域是否禁止停车。2)车辆在该位置停留的时间是否超标。

  1. 该区域是否禁止停车。
    对于第一个问题。需要用户设置禁停区域,可以用时PP-Vehicle args中的–region_polygon进行设置。
  2. 车辆在该位置停留的时间是否超标。
    该功能需要实现对车辆进行跟踪,同时利用车辆位置信息与视频fps数据,判断车辆在一个位置停留的时间是否超出设定时间阈值。如果超出该时间阈值则认为车辆已停车超标。这其中用到的车辆跟踪功能已经在PP-Vehicle中有提供基于PP-YOLOE的跟踪方案。

3.车辆结构化–车牌识别

车牌识别功能的实现流程一般是: 检测车辆->检测车牌->识别车牌字符。

该流程中的车辆检测在上个功能需求分析中提到的车辆跟踪已经实现,因此该步骤主要聚焦于后两步的实现。即车牌检测+车牌字符识别。该问题属于字符检测与识别领域,我们利用PaddleOCR来实现。

  1. 车牌检测。
    车牌检测模型可以使用PP-OCRv3_det字符检测模型,为提高在车牌场景的检测效果,该模型可以在CCPD车牌数据集上进行fine-tune。

  2. 车牌字符识别。
    车牌字符识别模型可以使用PP-OCRv3_rec字符识别模型,为提高在车牌场景的识别效果,同样该模型可以在CCPD车牌数据集上进行fine-tune。

如此便解决了车辆的车牌识别问题。

由于车牌检测+识别是基于车辆检测的结果,因此从哪个车辆截图中识别到的车牌便可以直接与该车辆id进行关联。

如此,便可以实现完整的车辆违规停车识别功能了。

4.车辆结构化–车型与颜色识别

车辆属性的实现流程是车辆检测(跟踪)-> 每辆车属性判断。

数据采用VeRi数据集,可以判断10种车辆颜色及9种车型。模型采用高效轻量级骨干模型PP-LCNet,具有极高的性价比。

技术方案优化(可选)

上面的方案分析已经可以实现基本的功能。这里我们来探索该方案有没有进一步优化的空间。优化主要围绕:1)降低算力,提高速度。2)提高准确率。

  1. 降低算力,提高速度。流程的算力消耗主要是跑模型的消耗,但是减小模型势必引起准确度的下降。在不更改模型的基础上如果有效降低算力消耗呢。我们采用跳帧策略,即由于视频连续两帧之间差异非常小,因此模型预测结果也相近,完全可以省略这部分算力。尤其是车牌识别这种功能,其实只要一个跟踪id识别到一帧足够准确的就够了,因此我们采用每10帧做一次车牌识别的方式。跟踪模型为了保证足够高的精度,可以每2-3帧做一次车辆检测。如此一来,我们的算力便降低了N(2-10)倍。
  2. 提高准确率。提高准确率的措施,主要指车牌识别。由于车辆移动过程中车牌有大小、角度、模糊程度的变化,因此每次识别都有可能造成误检,使车牌识别结果反复变化。我们利用跟踪功能,对车辆一段时间内多次进行车牌识别,并整合历史识别信息投票选择得分最高的车牌结果。这样可以有效提高车牌准确度和稳定性。

动手实践

上面进行了完整、详细的实现分析,下面我们来看看如何用PP-Vehicle来实现上述功能。

首先,从PP-Vehicle页面下载需要用到的3个模型,分别是 跟踪模型、车牌检测模型、车牌识别模型。(此处已下载好了)

%cd work/ppvehicle_models/
# !wget https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_l_36e_ppvehicle.zip
# !wget https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_det_infer.tar.gz
# !wget https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_rec_infer.tar.gz
# !wget https://bj.bcebos.com/v1/paddledet/models/pipeline/vehicle_attribute_model.zip
/home/aistudio/work/ppvehicle_models

然后解压模型文件,并移动到ppvehicle模型文件夹中(此处已经准备完成)

# !unzip mot_ppyoloe_l_36e_ppvehicle.zip
# !tar -zxf ch_PP-OCRv3_det_infer.tar.gz
# !tar -zxf ch_PP-OCRv3_rec_infer.tar.gz
# !unzip vehicle_attribute_model.zip
# !mv mot_ppyoloe_l_36e_ppvehicle work/ppvehicle_models/
# !mv ch_PP-OCRv3_det_infer work/ppvehicle_models/
# !mv ch_PP-OCRv3_rec_infer work/ppvehicle_models/
# !mv vehicle_attribute_model work/ppvehicle_models/

如此,模型准备就绪。然后下载PaddleDetection

%cd ../
!git clone https://gitee.com/paddlepaddle/PaddleDetection -b develop
%cd PaddleDetection
正克隆到 'PaddleDetection'...
remote: Enumerating objects: 28790, done.[K
remote: Counting objects: 100% (9260/9260), done.[K
remote: Compressing objects: 100% (3849/3849), done.[K
remote: Total 28790 (delta 6995), reused 7381 (delta 5389), pack-reused 19530[K
接收对象中: 100% (28790/28790), 301.58 MiB | 8.62 MiB/s, 完成.
处理 delta 中: 100% (21544/21544), 完成.
检查连接... 完成。
/home/aistudio/work/PaddleDetection

安装python依赖模块:

!pip install -r requirements.txt
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: tqdm in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (4.27.0)
Requirement already satisfied: typeguard in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (2.13.3)
Requirement already satisfied: visualdl>=2.2.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (2.3.0)
Requirement already satisfied: opencv-python in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 4)) (4.1.1.26)
Requirement already satisfied: PyYAML in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 5)) (5.1.2)
Requirement already satisfied: shapely in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 6)) (1.8.4)
Requirement already satisfied: scipy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 7)) (1.3.0)
Requirement already satisfied: terminaltables in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 8)) (3.1.10)
Requirement already satisfied: Cython in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 9)) (0.29)
Requirement already satisfied: pycocotools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 10)) (2.0.4)
Requirement already satisfied: setuptools in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 11)) (41.4.0)
Requirement already satisfied: pyclipper in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 14)) (1.3.0.post3)
Requirement already satisfied: lap in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 17)) (0.4.0)
Requirement already satisfied: motmetrics in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 18)) (1.2.5)
Requirement already satisfied: sklearn in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 19)) (0.0)
Requirement already satisfied: filterpy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from -r requirements.txt (line 20)) (1.4.5)
Requirement already satisfied: Pillow>=7.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (8.2.0)
Requirement already satisfied: numpy in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (1.19.5)
Requirement already satisfied: matplotlib in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (2.2.3)
Requirement already satisfied: bce-python-sdk in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (0.8.53)
Requirement already satisfied: flask>=1.1.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (1.1.1)
Requirement already satisfied: requests in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (2.24.0)
Requirement already satisfied: protobuf>=3.11.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (3.20.0)
Requirement already satisfied: six>=1.14.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (1.16.0)
Requirement already satisfied: Flask-Babel>=1.0.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (1.0.0)
Requirement already satisfied: pandas in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from visualdl>=2.2.0->-r requirements.txt (line 3)) (1.1.5)
Requirement already satisfied: xmltodict>=0.12.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from motmetrics->-r requirements.txt (line 18)) (0.13.0)
Requirement already satisfied: scikit-learn in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from sklearn->-r requirements.txt (line 19)) (0.22.1)
Requirement already satisfied: Werkzeug>=0.15 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from flask>=1.1.1->visualdl>=2.2.0->-r requirements.txt (line 3)) (0.16.0)
Requirement already satisfied: Jinja2>=2.10.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from flask>=1.1.1->visualdl>=2.2.0->-r requirements.txt (line 3)) (3.0.0)
Requirement already satisfied: click>=5.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from flask>=1.1.1->visualdl>=2.2.0->-r requirements.txt (line 3)) (7.0)
Requirement already satisfied: itsdangerous>=0.24 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from flask>=1.1.1->visualdl>=2.2.0->-r requirements.txt (line 3)) (1.1.0)
Requirement already satisfied: pytz in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel>=1.0.0->visualdl>=2.2.0->-r requirements.txt (line 3)) (2019.3)
Requirement already satisfied: Babel>=2.3 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Flask-Babel>=1.0.0->visualdl>=2.2.0->-r requirements.txt (line 3)) (2.8.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl>=2.2.0->-r requirements.txt (line 3)) (1.1.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl>=2.2.0->-r requirements.txt (line 3)) (3.0.9)
Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl>=2.2.0->-r requirements.txt (line 3)) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from matplotlib->visualdl>=2.2.0->-r requirements.txt (line 3)) (2.8.2)
Requirement already satisfied: future>=0.6.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl>=2.2.0->-r requirements.txt (line 3)) (0.18.0)
Requirement already satisfied: pycryptodome>=3.8.0 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from bce-python-sdk->visualdl>=2.2.0->-r requirements.txt (line 3)) (3.9.9)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests->visualdl>=2.2.0->-r requirements.txt (line 3)) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests->visualdl>=2.2.0->-r requirements.txt (line 3)) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests->visualdl>=2.2.0->-r requirements.txt (line 3)) (1.25.6)
Requirement already satisfied: idna<3,>=2.5 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from requests->visualdl>=2.2.0->-r requirements.txt (line 3)) (2.8)
Requirement already satisfied: joblib>=0.11 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from scikit-learn->sklearn->-r requirements.txt (line 19)) (0.14.1)
Requirement already satisfied: MarkupSafe>=2.0.0rc2 in /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages (from Jinja2>=2.10.1->flask>=1.1.1->visualdl>=2.2.0->-r requirements.txt (line 3)) (2.0.1)[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m A new release of pip available: [0m[31;49m22.1.2[0m[39;49m -> [0m[32;49m22.2.2[0m
[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m To update, run: [0m[32;49mpip install --upgrade pip[0m

请点击此处查看本环境基本用法.

Please click here for more detailed instructions.

修改 deploy/pipeline/config/infer_cfg_ppvehicle.yml 文件中使用到的模型路径指向下载的模型位置。并打开VEHICLE_PLATE模块的 enable: True。如下:

MOT:model_dir: ../ppvehicle_models/mot_ppyoloe_s_36e_ppvehicle/   #跟踪模型路径tracker_config: deploy/pipeline/config/tracker_config.ymlbatch_size: 1enable: FalseVEHICLE_PLATE:det_model_dir: ../ppvehicle_models/ch_PP-OCRv3_det_infer/     #车牌检测模型路径det_limit_side_len: 736det_limit_type: "min"rec_model_dir: ../ppvehicle_models/ch_PP-OCRv3_rec_infer/     #车牌字符识别模型路径rec_image_shape: [3, 48, 320]rec_batch_num: 6word_dict_path: deploy/pipeline/ppvehicle/rec_word_dict.txtenable: True                                                  #开启车牌识别功能

此处把修改好文件直接替换过去。

%cp ../infer_cfg_ppvehicle.yml deploy/pipeline/config/infer_cfg_ppvehicle.yml

然后执行如下命令开始运行(cpu会比较慢,建议开启gpu运行,即更改–device=gpu):

!python deploy/pipeline/pipeline.py --config deploy/pipeline/config/examples/infer_cfg_illegal_parking.yml \--video_file=../car_test.mov \--device=gpu \--draw_center_traj \--illegal_parking_time=3 \--region_type=custom \--region_polygon 600 300 1300 300 1300 800 600 800
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/setuptools/depends.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative usesimport imp
deploy/pipeline/pipeline.py:24: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop workingfrom collections import Sequence, defaultdict
-----------  Running Arguments -----------
MOT:batch_size: 1enable: truemodel_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_l_36e_ppvehicle.ziptracker_config: deploy/pipeline/config/tracker_config.yml
VEHICLE_PLATE:det_limit_side_len: 736det_limit_type: maxdet_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_det_infer.tar.gzenable: truerec_batch_num: 6rec_image_shape:- 3- 48- 320rec_model_dir: https://bj.bcebos.com/v1/paddledet/models/pipeline/ch_PP-OCRv3_rec_infer.tar.gzword_dict_path: deploy/pipeline/ppvehicle/rec_word_dict.txt
crop_thresh: 0.5
visual: true
warmup_frame: 50------------------------------------------
Multi-Object Tracking enabled
Vehicle Plate Recognition enabled
MOT  model dir:  /home/aistudio/.cache/paddle/infer_weights/mot_ppyoloe_l_36e_ppvehicle
det_model_dir model dir:  /home/aistudio/.cache/paddle/infer_weights/ch_PP-OCRv3_det_infer
rec_model_dir model dir:  /home/aistudio/.cache/paddle/infer_weights/ch_PP-OCRv3_rec_infer
E0830 20:27:57.338886 16884 analysis_config.cc:95] Please compile with gpu to EnableGpu()
E0830 20:27:57.814378 16884 analysis_config.cc:95] Please compile with gpu to EnableGpu()
E0830 20:27:58.145838 16884 analysis_config.cc:95] Please compile with gpu to EnableGpu()
E0830 20:27:58.621416 16884 analysis_config.cc:95] Please compile with gpu to EnableGpu()
-----------  Model Configuration -----------
Model Arch: YOLO
Transform Order:
--transform op: Resize
--transform op: Permute
--------------------------------------------
E0830 20:27:59.044703 16884 analysis_config.cc:95] Please compile with gpu to EnableGpu()
video fps: 29, frame_count: 790
frame id:  0
Frame id: 1, Total count: 1
Frame id: 2, Total count: 1
Frame id: 3, Total count: 1
Frame id: 4, Total count: 1
Frame id: 5, Total count: 1
Frame id: 6, Total count: 1
Frame id: 7, Total count: 1
Frame id: 8, Total count: 1
Frame id: 9, Total count: 1
Frame id: 10, Total count: 1
frame id:  10
Frame id: 11, Total count: 1
Frame id: 12, Total count: 1
Frame id: 13, Total count: 1
Frame id: 14, Total count: 1
Frame id: 15, Total count: 1
Frame id: 16, Total count: 1
Frame id: 17, Total count: 1
Frame id: 18, Total count: 1
Frame id: 19, Total count: 1
Frame id: 20, Total count: 1
frame id:  20
Frame id: 21, Total count: 2
Frame id: 22, Total count: 2
Frame id: 23, Total count: 2
Frame id: 24, Total count: 2
Frame id: 25, Total count: 2
Frame id: 26, Total count: 2
Frame id: 27, Total count: 2
Frame id: 28, Total count: 2
Frame id: 29, Total count: 2
Frame id: 30, Total count: 2
frame id:  30
Frame id: 31, Total count: 2
Frame id: 32, Total count: 2

到这里,使用PP-Vehicle来做该功能就已经完成了。因为PP-Vehicle中已经包含了跟踪、车牌识别、违停判断的功能,因此该应用的实现变得非常简单。

可视化视频结果保存在output/car_test.mov.

另外,如果想要车辆属性信息,同样在 deploy/pipeline/config/infer_cfg_ppvehicle.yml 文件中修改 VEHICLE_ATTR项内容即可,一般只需要修改model_direnable: True即可。

VEHICLE_ATTR:model_dir: ../ppvehicle_models/vehicle_attribute_infer/batch_size: 8color_threshold: 0.5type_threshold: 0.5enable: True

然后同样执行上面一样的命令,结果便会一起保持属性结果。

模型训练

PP-Vehicle提供了检测、车牌、属性模型的二次开发文档。我们以属性为例来看看怎么进行二次开发。

1. 标注数据格式

车辆属性模型采用VeRi数据集的属性,共计10种车辆颜色及9种车型, 具体如下:

# 车辆颜色
- "yellow"
- "orange"
- "green"
- "gray"
- "red"
- "blue"
- "white"
- "golden"
- "brown"
- "black"# 车型
- "sedan"
- "suv"
- "van"
- "hatchback"
- "mpv"
- "pickup"
- "bus"
- "truck"
- "estate"

在标注文件中使用长度为19的序列来表示上述属性。

举例:

[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]

前10位中,位序号0的值为1,表示车辆颜色为"yellow"

后9位中,位序号11的值为1,表示车型为"suv"

假设,我们定义一种新的属性车辆朝向,其包含3个种类:forwardsidewardbackward, 因此我们在上述19位标志的后面增加3位分别对应上面的3个方向。

因此,现在新的属性定义变成了[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, (0, 0, 1)].(括号内为新增属性位,最后一位为1,表示朝向为backward)

2. 修改训练配置

需要修改训练的配置文件,训练配置修改包括2个地方:

1)训练属性种类

修改Arch下的class_num为21,对应上面最终属性总位数。

Arch:name: "PPLCNet_x1_0"pretrained: Trueuse_ssld: Trueclass_num: 21           #属性种类数量

2)训练数据路径

修改DataLoader中Train、Eval下的 image_rootcls_label_path。分别表示训练数据跟路径标注文件路径

需要注意的是标注文件train_list.txt中的图片路径是相对于image_root目录的相对路径。

DataLoader:Train:dataset:name: MultiLabelDatasetimage_root: "dataset/VeRi/"                     # the root path of training imagescls_label_path: "dataset/VeRi/train_list.txt"   # the location of the training list filelabel_ratio: Truetransform_ops:...Eval:dataset:name: MultiLabelDatasetimage_root: "dataset/VeRi/"                     # the root path of evaluation imagescls_label_path: "dataset/VeRi/val_list.txt"     # the location of the evaluation list filelabel_ratio: Truetransform_ops:...

3. 训练、评估和模型导出

上述准备工作完成后,可以执行以下命令进行训练:

export CUDA_VISIBLE_DEVICES=0,1,2,3
python3 -m paddle.distributed.launch \--gpus="0,1,2,3" \tools/train.py \-c ./ppcls/configs/PULC/vehicle_attribute/PPLCNet_x1_0.yaml

训练完成后可以执行以下命令进行性能评估:

export CUDA_VISIBLE_DEVICES=0,1,2,3
python3 -m paddle.distributed.launch \--gpus="0,1,2,3" \tools/eval.py \-c ./ppcls/configs/PULC/vehicle_attribute/PPLCNet_x1_0.yaml \-o Global.pretrained_model=./output/PPLCNet_x1_0/best_model

如果模型性能达到预期,可以使用以下命令导出模型,就可以在PP-Vehicle中使用了。

python3 tools/export_model.py \-c ./ppcls/configs/PULC/vehicle_attribute/PPLCNet_x1_0.yaml \-o Global.pretrained_model=output/PPLCNet_x1_0/best_model \-o Global.save_inference_dir=deploy/models/PPLCNet_x1_0_vehicle_attribute_model

4. 在PP-Vehicle中使用

在PP-Vehicle中使用时修改属性模型路径为刚导出的模型路径

python deploy/pipeline/pipeline.py --config deploy/pipeline/config/infer_cfg_ppvehicle.yml -o VEHICLE_ATTR.model_dir=[PATH_TO_YOUR_ATTR_MODEL]\--image_file=demo/car.jpg \--device=gpu

至此,基于PP-Vehicle实现的简单的交通监控分析系统就完成啦!

希望大家可以基于PP-Vehicle多多尝试,无论是社区安防、道路交通,还是简单的进出入口的车辆管理都可快速基于PP-Vehicle实现!

期待大家的应用案例!有任何问题也欢迎加入PaddleDetection交流群和我们沟通!

此文章为搬运
原项目链接

智慧交通:基于PP-Vehicle的交通监控分析系统相关推荐

  1. 京东如何建设基于云原生架构的监控 - 日志系统?

    在这个人人都谈"云原生"的时代,企业在建设内部相关系统时常常会优先考虑云原生架构.那么,云原生架构的系统与传统架构系统有什么不同?又该如何建设呢?本文我们邀请京东架构师韩超老师分享 ...

  2. 基于sentry的前端错误监控日志系统(部署sentry服务器/前端项目部署)-让前端最快的定位到生产问题

    基于sentry的前端错误监控日志系统(部署sentry服务器/前端项目部署)-让前端最快的定位到生产问题 背景 在这越来越发达的网络时代,web应用也是越来越复杂,尤其是前端的开发,也是越来越受重视 ...

  3. 基于大数据的网站日志分析系统

    本文没有任何代码,只有各个模块工作的大体机制和整体流程.算是一个科普文吧,我也对原理一知半解. 基于大数据的网站日志分析系统 1. 日志数据格式 1.1 访问日志 1.1.1 log_format 1 ...

  4. 基于Filebeat自动收集Kubernetes日志的分析系统

    基于Filebeat自动收集Kubernetes日志的分析系统 摘要:Docker容器产生的日志分散在不同的相互隔离的容器中, 并且容器具有即用即销的特点, 传统的解决方式是将日志文件挂载到宿主机上, ...

  5. 加油站视频监控分析系统

    加油站视频监控分析系统借助Python基于OpenCV的对现场画面中人员抽烟.打电话行为.明火和烟雾异常状态.人员离岗.灭火器未正确摆放.静电释放等异常行为和状态实时检测.计算机视觉技术是人工智能系统 ...

  6. 基于hadoop的电商销售预测分析系统HDFS+MapReduce+springboot或springcloud+Echarts

    基于hadoop的电商销售预测分析系统 使用分布式文件存储系统HDFS+mapreduce+springboot和springcloud+Echarts实现的简单的电商销售数据预测分析系统. 主要通过 ...

  7. Moodlens:一个基于表情符号的中文微博情感分析系统(A3, SIGKDD2012)

    Moodlens: an emoticon-based sentiment analysis system for chinese tweets Moodlens:一个基于表情符号的中文微博情感分析系 ...

  8. 基于API HOOK的软件行为分析系统

    基于API HOOK的软件行为分析系统 目录 软件安全课程设计 1 基于API HOOK的软件行为分析系统 1 一.课程设计题目 1 基于API HOOK的软件行为分析系统 1 二.课程编码:1306 ...

  9. 基于python的城市旅游数据采集分析系统

    温馨提示:文末有 CSDN 平台官方提供的学长 Wechat / QQ 名片 :) 1. 项目简介 本项目利用网络爬虫技术从某旅游网站爬取各城市的景点旅游数据,根据旅游网的数据综合分析每个城市的热度. ...

最新文章

  1. Java:取得当前日期一周之前/之后的日期,或者是一月之前/之后的日期
  2. java 下载文件文件名_java – 从http下载文件中检索文件名
  3. Java zset 应用_Java简单使用redis-zset实现排行榜
  4. 基于java SSM校园兼职平台系统设计和实现
  5. 想了解任务型对话机器人,我们先从自然语言理解聊起
  6. css position, display, float 内联元素、块级元素
  7. nginx获取代理服务ip及客户端真实ip
  8. php 判断客户端类型,怎么使用php判断客户端的类型
  9. 8进制的乘法计算、加法计算
  10. Drupal主题制作流程
  11. 微服务架构开发实战:什么是微服务的熔断机制和熔断的意义
  12. 1033,2052 是什么意思?
  13. node-js——将excel表格转换成json文件
  14. 【算法】红黑树插入数据(变色,左旋、右旋)(二)
  15. 2021年电商企业倒闭名单
  16. mongodb数据文件格式
  17. c语言设计生命游戏,C语言实现生命游戏.doc
  18. 生产计划erp管理系统
  19. 当面试官说刚入职工资不高时该怎么回答呢
  20. vue加js实现大转盘抽奖活动

热门文章

  1. 深入理解ROC曲线的定义以及绘制ROC曲线过程,其与模型性能的关系,以及AUC
  2. 《转载》工作5年左右的程序员如何在职业瓶颈期内快速提升自己的身价?提升后如何有效变现自己的高质量技能?...
  3. 【Spring】之 SpringAOP 切点指示符详解
  4. 新发的日常小实验——使用.NET Reactor对.NET程序进行加壳保护(反编译、加壳、混淆)
  5. 因买不到RTX 3090!他花19万搭了一个专业级机器学习工作站
  6. 我承认,项目经理没有这个分析方法,是真不行
  7. 我的一些视觉工具(1)之动作预测--逐行详解C3D代码(Pytorch)
  8. BIOS设置关机状态S4/S5 USB不带电
  9. web10.CSS3
  10. popup java_Web的桌面提醒(Popup)