提交 8492c717 编写于 作者: Z zhiboniu 提交者: zhiboniu

self model train of attribute and reid

上级 efc82c93
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
| 任务 | 算法 | 精度 | 预测速度(ms) |下载链接 | | 任务 | 算法 | 精度 | 预测速度(ms) |下载链接 |
|:---------------------|:---------:|:------:|:------:| :---------------------------------------------------------------------------------: | |:---------------------|:---------:|:------:|:------:| :---------------------------------------------------------------------------------: |
| 行人检测/跟踪 | PP-YOLOE | mAP: 56.3 <br> MOTA: 72.0 | 检测: 28ms <br> 跟踪:33.1ms | [下载链接](https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_l_36e_pipeline.zip) | | 行人属性高精度模型 | PP-HGNet_small | mA: 95.4 | 单人 1.54ms | [下载链接](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.tar) |
| 行人属性分析 | StrongBaseline | mA: 94.86 | 单人 2ms | [下载链接](https://bj.bcebos.com/v1/paddledet/models/pipeline/strongbaseline_r50_30e_pa100k.zip) | | 行人属性快速版模型 | PP-LCNet_x1_0 | mA: 94.5 | 单人 0.54ms | [下载链接](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.tar) |
| 行人属性平衡模型 | PP-HGNet_tiny | mA: 95.2 | 单人 1.14ms | [下载链接](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPHGNet_tiny_person_attribute_952_infer.tar) |
1. 检测/跟踪模型精度为[MOT17](https://motchallenge.net/)[CrowdHuman](http://www.crowdhuman.org/)[HIEVE](http://humaninevents.org/)和部分业务数据融合训练测试得到 1. 行人属性分析精度为[PA100k](https://github.com/xh-liu/HydraPlus-Net#pa-100k-dataset)[RAPv2](http://www.rapdataset.com/rapv2.html)[PETA](http://mmlab.ie.cuhk.edu.hk/projects/PETA.html)和部分业务数据融合训练测试得到
2. 行人属性分析精度为[PA100k](https://github.com/xh-liu/HydraPlus-Net#pa-100k-dataset)[RAPv2](http://www.rapdataset.com/rapv2.html)[PETA](http://mmlab.ie.cuhk.edu.hk/projects/PETA.html)和部分业务数据融合训练测试得到 2. 预测速度为V100 机器上使用TensorRT FP16时的速度, 速度包含数据预处理、模型预测、后处理全流程
3. 预测速度为T4 机器上使用TensorRT FP16时的速度, 速度包含数据预处理、模型预测、后处理全流程
## 使用方法 ## 使用方法
...@@ -70,7 +70,7 @@ python deploy/pphuman/pipeline.py --config deploy/pphuman/config/infer_cfg_pphum ...@@ -70,7 +70,7 @@ python deploy/pphuman/pipeline.py --config deploy/pphuman/config/infer_cfg_pphum
- 穿靴:是、否 - 穿靴:是、否
``` ```
4. 属性识别模型方案为[StrongBaseline](https://arxiv.org/pdf/2107.03576.pdf),模型结构为基于ResNet50的多分类网络结构,引入Weighted BCE loss和EMA提升模型效果。 4. 属性识别模型方案为[StrongBaseline](https://arxiv.org/pdf/2107.03576.pdf),模型结构为基于PP-HGNet、PP-LCNet的多分类网络结构,引入Weighted BCE loss提升模型效果。
## 参考文献 ## 参考文献
``` ```
......
...@@ -6,12 +6,12 @@ Pedestrian attribute recognition has been widely used in the intelligent communi ...@@ -6,12 +6,12 @@ Pedestrian attribute recognition has been widely used in the intelligent communi
| Task | Algorithm | Precision | Inference Speed(ms) | Download Link | | Task | Algorithm | Precision | Inference Speed(ms) | Download Link |
|:---------------------|:---------:|:------:|:------:| :---------------------------------------------------------------------------------: | |:---------------------|:---------:|:------:|:------:| :---------------------------------------------------------------------------------: |
| Pedestrian Detection/ Tracking | PP-YOLOE | mAP: 56.3 <br> MOTA: 72.0 | Detection: 28ms <br> Tracking:33.1ms | [Download Link](https://bj.bcebos.com/v1/paddledet/models/pipeline/mot_ppyoloe_l_36e_pipeline.zip) | | High-Precision Model | PP-HGNet_small | mA: 95.4 | per person 1.54ms | [Download](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.tar) |
| Pedestrian Attribute Analysis | StrongBaseline | ma: 94.86 | Per Person 2ms | [Download Link](https://bj.bcebos.com/v1/paddledet/models/pipeline/strongbaseline_r50_30e_pa100k.tar) | | Fast Model | PP-LCNet_x1_0 | mA: 94.5 | per person 0.54ms | [Download](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.tar) |
| Balanced Model | PP-HGNet_tiny | mA: 95.2 | per person 1.14ms | [Download](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPHGNet_tiny_person_attribute_952_infer.tar) |
1. The precision of detection/ tracking models is obtained by training and testing on the dataset consist of [MOT17](https://motchallenge.net/)[CrowdHuman](http://www.crowdhuman.org/)[HIEVE](http://humaninevents.org/) and some business data. 1. The precision of pedestiran attribute analysis is obtained by training and testing on the dataset consist of [PA100k](https://github.com/xh-liu/HydraPlus-Net#pa-100k-dataset)[RAPv2](http://www.rapdataset.com/rapv2.html)[PETA](http://mmlab.ie.cuhk.edu.hk/projects/PETA.html) and some business data.
2. The precision of pedestiran attribute analysis is obtained by training and testing on the dataset consist of [PA100k](https://github.com/xh-liu/HydraPlus-Net#pa-100k-dataset)[RAPv2](http://www.rapdataset.com/rapv2.html)[PETA](http://mmlab.ie.cuhk.edu.hk/projects/PETA.html) and some business data. 2. The inference speed is V100, the speed of using TensorRT FP16.
3. The inference speed is T4, the speed of using TensorRT FP16.
## Instruction ## Instruction
...@@ -70,7 +70,7 @@ Data Source and Copyright:Skyinfor Technology. Thanks for the provision of act ...@@ -70,7 +70,7 @@ Data Source and Copyright:Skyinfor Technology. Thanks for the provision of act
- Boots: Yes; No - Boots: Yes; No
``` ```
4. The model adopted in the attribute recognition is [StrongBaseline](https://arxiv.org/pdf/2107.03576.pdf), where the structure is the multi-class network structure based on ResNet50, and Weighted BCE loss and EMA are introduced for effect optimization. 4. The model adopted in the attribute recognition is [StrongBaseline](https://arxiv.org/pdf/2107.03576.pdf), where the structure is the multi-class network structure based on PP-HGNet、PP-LCNet, and Weighted BCE loss is introduced for effect optimization.
## Reference ## Reference
``` ```
......
...@@ -48,7 +48,7 @@ python3 deploy/pphuman/pipeline.py ...@@ -48,7 +48,7 @@ python3 deploy/pphuman/pipeline.py
id聚类、重新分配id id聚类、重新分配id
``` ```
2. 模型方案为[reid-centroids](https://github.com/mikwieczorek/centroids-reid), Backbone为ResNet50, 主要特色为利用相同id的多个特征提升相似度效果 2. 模型方案为[reid-strong-baseline](https://github.com/michuanhaohao/reid-strong-baseline), Backbone为ResNet50, 主要特色为模型结构简单
本跨镜跟踪中所用REID模型在上述基础上,整合多个开源数据集并压缩模型特征到128维以提升泛化性能。大幅提升了在实际应用中的泛化效果。 本跨镜跟踪中所用REID模型在上述基础上,整合多个开源数据集并压缩模型特征到128维以提升泛化性能。大幅提升了在实际应用中的泛化效果。
### 其他建议 ### 其他建议
...@@ -71,11 +71,21 @@ python3 deploy/pphuman/pipeline.py ...@@ -71,11 +71,21 @@ python3 deploy/pphuman/pipeline.py
## 参考文献 ## 参考文献
``` ```
@article{Wieczorek2021OnTU, @InProceedings{Luo_2019_CVPR_Workshops,
title={On the Unreasonable Effectiveness of Centroids in Image Retrieval}, author = {Luo, Hao and Gu, Youzhi and Liao, Xingyu and Lai, Shenqi and Jiang, Wei},
author={Mikolaj Wieczorek and Barbara Rychalska and Jacek Dabrowski}, title = {Bag of Tricks and a Strong Baseline for Deep Person Re-Identification},
journal={ArXiv}, booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
year={2021}, month = {June},
volume={abs/2104.13643} year = {2019}
}
@ARTICLE{Luo_2019_Strong_TMM,
author={H. {Luo} and W. {Jiang} and Y. {Gu} and F. {Liu} and X. {Liao} and S. {Lai} and J. {Gu}},
journal={IEEE Transactions on Multimedia},
title={A Strong Baseline and Batch Normalization Neck for Deep Person Re-identification},
year={2019},
pages={1-1},
doi={10.1109/TMM.2019.2958756},
ISSN={1941-0077},
} }
``` ```
...@@ -49,7 +49,7 @@ capture the target in the original image according to bbox——│ ...@@ -49,7 +49,7 @@ capture the target in the original image according to bbox——│
make the IDs cluster together and rearrange them make the IDs cluster together and rearrange them
``` ```
2. The model solution is [reid-centroids](https://github.com/mikwieczorek/centroids-reid), with ResNet50 as the backbone. It is worth noting that the solution employs different features of the same ID to enhance the similarity. 2. The model solution is [reid-strong-baseline](https://github.com/michuanhaohao/reid-strong-baseline), with ResNet50 as the backbone.
Under the above circumstances, the REID model used in MTMCT integrates open-source datasets and compresses model features to 128-dimensional features to optimize the generalization. In this way, the actual generalization result becomes much better. Under the above circumstances, the REID model used in MTMCT integrates open-source datasets and compresses model features to 128-dimensional features to optimize the generalization. In this way, the actual generalization result becomes much better.
...@@ -74,11 +74,21 @@ Under the above circumstances, the REID model used in MTMCT integrates open-sour ...@@ -74,11 +74,21 @@ Under the above circumstances, the REID model used in MTMCT integrates open-sour
## Reference ## Reference
``` ```
@article{Wieczorek2021OnTU, @InProceedings{Luo_2019_CVPR_Workshops,
title={On the Unreasonable Effectiveness of Centroids in Image Retrieval}, author = {Luo, Hao and Gu, Youzhi and Liao, Xingyu and Lai, Shenqi and Jiang, Wei},
author={Mikolaj Wieczorek and Barbara Rychalska and Jacek Dabrowski}, title = {Bag of Tricks and a Strong Baseline for Deep Person Re-Identification},
journal={ArXiv}, booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
year={2021}, month = {June},
volume={abs/2104.13643} year = {2019}
}
@ARTICLE{Luo_2019_Strong_TMM,
author={H. {Luo} and W. {Jiang} and Y. {Gu} and F. {Liu} and X. {Liao} and S. {Lai} and J. {Gu}},
journal={IEEE Transactions on Multimedia},
title={A Strong Baseline and Batch Normalization Neck for Deep Person Re-identification},
year={2019},
pages={1-1},
doi={10.1109/TMM.2019.2958756},
ISSN={1941-0077},
} }
``` ```
...@@ -2,6 +2,134 @@ ...@@ -2,6 +2,134 @@
## 数据准备 ## 数据准备
### 数据格式
格式采用PA100K的属性标注格式,共有26位属性。
这26位属性的名称、位置、种类数量见下表。
| Attribute | index | length |
|:----------|:----------|:----------|
| 'Female' | [0] | 1 |
| 'AgeOver60', 'Age18-60', 'AgeLess18' | [1, 2, 3] | 3 |
| 'Front','Side','Back' | [4, 5, 6] | 3 |
| 'Hat','Glasses' | [7, 8] | 2 |
| 'HandBag','ShoulderBag','Backpack','HoldObjectsInFront' | [9,10,11,12] | 4 |
| 'ShortSleeve','LongSleeve','UpperStride','UpperLogo','UpperPlaid','UpperSplice' | [13,14,15,16,17,18] | 6 |
| 'LowerStripe','LowerPattern','LongCoat','Trousers','Shorts','Skirt&Dress' | [19,20,21,22,23,24] | 6 |
| 'boots' | [25] | 1 |
举例:
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
第一组,位置[0]数值是0,表示'female'
第二组,位置[1,2,3]数值分别是 0、1、0, 表示'Age18-60'
其他组依次类推
### 数据标注
理解了上面`属性标注`格式的含义后,就可以进行数据标注的工作。其本质是:每张单人图建立一组26个长度的标注项,分别与26个位置的属性值对应。
举例:
对于一张原始图片,
1) 使用检测框,标注图片中每一个人的位置。
2) 每一个检测框(对应每一个人),包含一组26位的属性值数组,数组的每一位以0或1表示。对应上述26个属性。例如,如果图片是'Female',则数组第一位为0,如果满足'Age18-60',则位置[1,2,3]对应的数值是[0,1,0], 或者满足'AgeOver60',则相应数值为[1,0,0].
标注完成后利用检测框将每一个人截取成单人图,其图片与26位属性标注建立对应关系。也可先截成单人图再进行标注,效果相同。
## 模型优化 ## 模型优化
## 新增属性 数据标注完成后,就可以拿来做模型的训练,完成自定义模型的优化工作。
其主要有两步工作需要完成:1)将数据与标注数据整理成训练格式。2)修改配置文件开始训练。
### 训练数据格式
训练数据包括训练使用的图片和一个训练列表train.txt,其具体位置在训练配置中指定,其放置方式示例如下:
```
Attribute/
|-- data 训练图片文件夹
| |-- 00001.jpg
| |-- 00002.jpg
| `-- 0000x.jpg
`-- train.txt 训练数据列表
```
train.txt文件内为所有训练图片名称(相对于根路径的文件路径)+ 26个标注值
其每一行表示一个人的图片和标注结果。其格式为:
```
00001.jpg 0,0,1,0,....
```
注意:图片与标注值之间是以Tab[\t]符号隔开, 标注值之间是以逗号[,]隔开。该格式不能错,否则解析失败。
### 修改配置开始训练
该任务的训练功能集成在[PaddleClas](https://github.com/PaddlePaddle/PaddleClas)套件中。
需要在配置文件[PPLCNet_x1_0.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/PULC/person_attribute/PPLCNet_x1_0.yaml)中,修改的配置项如下:
```
image_root: "dataset/attribute/data/" 指定训练图片所在根路径
cls_label_path: "dataset/attribute/trainval.txt" 指定训练列表文件位置
```
注意:
1. 这里image_root路径+train.txt中图片相对路径,对应图片存放的完整路径。
如果有修改属性数量,则还需修改内容配置项:
```
class_num: 26 #属性种类数量
```
然后运行以下命令开始训练。
```
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/person_attribute/PPLCNet_x1_0.yaml
```
### 模型导出
使用下述命令将训练好的模型导出为预测部署模型。
```
python3 tools/export_model.py \
-c ./ppcls/configs/PULC/person_attribute/PPLCNet_x1_0.yaml \
-o Global.pretrained_model=output/DistillationModel/best_model_student \
-o Global.save_inference_dir=deploy/models/PPLCNet_x1_0_person_attribute_infer
```
导出模型后,然后将PP-Human中提供的部署模型[PPLCNet_x1_0](https://bj.bcebos.com/v1/paddledet/models/pipeline/PPLCNet_x1_0_person_attribute_945_infer.tar)中的infer_cfg.yml文件拷贝到导出的模型文件夹'PPLCNet_x1_0_person_attribute_infer'中。
使用时在PP-Human中的配置文件infer_cfg_pphuman.yml中修改
```
ATTR:
model_dir: [YOUR_DEPLOY_MODEL_DIR]/PPLCNet_x1_0_person_attribute_infer/
enable: True
```
然后可以使用。
## 属性增减
上述是以26个属性为例的标注、训练过程。
如果需要增加、减少属性数量,则只需修改1)标注、2)训练中train.txt所使用的属性数量和名称。
删减属性,例如,如果不需要年龄属性,则位置[1,2,3]的数值可以去掉。只需在train.txt中标注的26个数字中全部删除第1-3位数值即可,同时标注数据时也不再需要标注这3位属性值。
同理进行增加属性,在标注数据时在26位后继续增加新的属性标注数值,在train.txt文件的标注数值中也增加新的属性数值。注意属性类型在train.txt中属性数值列表中的位置的对应关系需要时固定的,例如第1-3位表示年龄,所有图片都要使用1-3位置表示年龄,不再赘述。
# 跨镜跟踪任务二次开发
## 数据准备
### 数据格式
跨镜跟踪使用行人REID技术实现,其训练方式采用多分类模型训练,使用时取分类softmax头部前的特征作为检索特征向量。
因此其格式与多分类任务相同。每一个行人分配一个专属id,不同行人id不同,同一行人在不同图片中的id相同。
例如图片0001.jpg、0003.jpg是同一个人,0002.jpg、0004.jpg是不同的其他行人。则标注id为:
```
0001.jpg 00001
0002.jpg 00002
0003.jpg 00001
0004.jpg 00003
...
```
依次类推。
### 数据标注
理解了上面`属性标注`格式的含义后,就可以进行数据标注的工作。其本质是:每张单人图建立一个标注项,对应该行人分配的id。
举例:
对于一张原始图片,
1) 使用检测框,标注图片中每一个人的位置。
2) 每一个检测框(对应每一个人),包含一个int类型的id属性。例如,上述举例中的0001.jpg中的人,对应id:1.
标注完成后利用检测框将每一个人截取成单人图,其图片与id属性标注建立对应关系。也可先截成单人图再进行标注,效果相同。
## 模型优化
数据标注完成后,就可以拿来做模型的训练,完成自定义模型的优化工作。
其主要有两步工作需要完成:1)将数据与标注数据整理成训练格式。2)修改配置文件开始训练。
### 训练数据格式
训练数据包括训练使用的图片和一个训练列表bounding_box_train.txt,其具体位置在训练配置中指定,其放置方式示例如下:
```
REID/
|-- data 训练图片文件夹
| |-- 00001.jpg
| |-- 00002.jpg
| `-- 0000x.jpg
`-- bounding_box_train.txt 训练数据列表
```
bounding_box_train.txt文件内为所有训练图片名称(相对于根路径的文件路径)+ 1个id标注值
其每一行表示一个人的图片和id标注结果。其格式为:
```
0001.jpg 00001
0002.jpg 00002
0003.jpg 00001
0004.jpg 00003
```
注意:图片与标注值之间是以Tab[\t]符号隔开。该格式不能错,否则解析失败。
### 修改配置开始训练
该任务的训练功能集成在[PaddleClas](https://github.com/PaddlePaddle/PaddleClas)套件中。
需要在配置文件[softmax_triplet_with_center.yaml](https://github.com/PaddlePaddle/PaddleClas/blob/develop/ppcls/configs/reid/strong_baseline/softmax_triplet_with_center.yaml)中,修改的配置项如下:
```
image_root: "./dataset/" 训练图片根路径
cls_label_path: "bounding_box_train" 训练文件列表
```
```
class_num: &class_num 751 #行人id总数量
```
注意:
1. 这里image_root路径+bounding_box_train.txt中图片相对路径,对应图片存放的完整路径。
然后运行以下命令开始训练。
```
export CUDA_VISIBLE_DEVICES=0,1,2,3
python3 -m paddle.distributed.launch \
--gpus="0,1,2,3" \
tools/train.py \
-c ./ppcls/configs/reid/strong_baseline/softmax_triplet_with_center.yaml
```
### 模型导出
使用下述命令将训练好的模型导出为预测部署模型。
```
python3 tools/export_model.py \
-c ./ppcls/configs/reid/strong_baseline/softmax_triplet_with_center.yaml \
-o Global.pretrained_model=output/strong_baseline/best_model \
-o Global.save_inference_dir=deploy/models/strong_baseline_inference
```
导出模型后,然后将PP-Human中提供的部署模型[REID模型](https://bj.bcebos.com/v1/paddledet/models/pipeline/reid_model.zip)中的infer_cfg.yml文件拷贝到新导出的模型文件夹'strong_baseline_inference'中。
使用时在PP-Human中的配置文件infer_cfg_pphuman.yml中修改
```
REID:
model_dir: [YOUR_DEPLOY_MODEL_DIR]/strong_baseline_inference/
enable: True
```
然后可以使用。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册