Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
a3c154fa
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
接近 2 年 前同步成功
通知
116
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a3c154fa
编写于
6月 13, 2022
作者:
W
weishengyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add car_config
上级
6432a7c4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
866 addition
and
48 deletion
+866
-48
docs/images/PULC/docs/car_exists_data_demo.jpeg
docs/images/PULC/docs/car_exists_data_demo.jpeg
+0
-0
docs/zh_CN/PULC/PULC_car_exists.md
docs/zh_CN/PULC/PULC_car_exists.md
+45
-48
ppcls/configs/PULC/car_exists/MobileNetV3_small_x0_35.yaml
ppcls/configs/PULC/car_exists/MobileNetV3_small_x0_35.yaml
+139
-0
ppcls/configs/PULC/car_exists/PPLCNet_x1_0.yaml
ppcls/configs/PULC/car_exists/PPLCNet_x1_0.yaml
+152
-0
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_distillation.yaml
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_distillation.yaml
+169
-0
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_search.yaml
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_search.yaml
+152
-0
ppcls/configs/PULC/car_exists/SwinTransformer_tiny_patch4_window7_224.yaml
...C/car_exists/SwinTransformer_tiny_patch4_window7_224.yaml
+169
-0
ppcls/configs/PULC/car_exists/search.yaml
ppcls/configs/PULC/car_exists/search.yaml
+40
-0
未找到文件。
docs/images/PULC/docs/car_exists_data_demo.jpeg
0 → 100644
浏览文件 @
a3c154fa
157.1 KB
docs/zh_CN/PULC/PULC_car_exists.md
浏览文件 @
a3c154fa
...
...
@@ -41,19 +41,19 @@
该案例提供了用户使用 PaddleClas 的超轻量图像分类方案(PULC,Practical Ultra Lightweight Classification)快速构建轻量级、高精度、可落地的有人/无人的分类模型。该模型可以广泛应用于如监控场景、人员进出管控场景、海量数据过滤场景等。
下表列出了判断图片中是否有
人
的二分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。
下表列出了判断图片中是否有
车
的二分类模型的相关指标,前两行展现了使用 SwinTranformer_tiny 和 MobileNetV3_small_x0_35 作为 backbone 训练得到的模型的相关指标,第三行至第六行依次展现了替换 backbone 为 PPLCNet_x1_0、使用 SSLD 预训练模型、使用 SSLD 预训练模型 + EDA 策略、使用 SSLD 预训练模型 + EDA 策略 + SKL-UGI 知识蒸馏策略训练得到的模型的相关指标。
| 模型 | Tpr(%) | 延时(ms) | 存储(M) | 策略 |
|-------|-----------|----------|---------------|---------------|
| SwinTranformer_tiny | 9
5.69
| 95.30 | 107 | 使用 ImageNet 预训练模型 |
| MobileNetV3_small_x0_35 |
68.25
| 2.85 | 1.6 | 使用 ImageNet 预训练模型 |
| PPLCNet_x1_0 | 8
9.57
| 2.12 | 6.5 | 使用 ImageNet 预训练模型 |
| PPLCNet_x1_0 | 9
2.10
| 2.12 | 6.5 | 使用 SSLD 预训练模型 |
| PPLCNet_x1_0 | 9
3.43
| 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略|
|
<b>
PPLCNet_x1_0
<b>
|
<b>
95.
60
<b>
|
<b>
2.12
<b>
|
<b>
6.5
<b>
| 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略|
| 模型 | Tpr(%)
@Fpr0.01
| 延时(ms) | 存储(M) | 策略 |
|-------|-----------
-----
|----------|---------------|---------------|
| SwinTranformer_tiny | 9
7.71
| 95.30 | 107 | 使用 ImageNet 预训练模型 |
| MobileNetV3_small_x0_35 |
81.23
| 2.85 | 1.6 | 使用 ImageNet 预训练模型 |
| PPLCNet_x1_0 | 8
1.23
| 2.12 | 6.5 | 使用 ImageNet 预训练模型 |
| PPLCNet_x1_0 | 9
5.48
| 2.12 | 6.5 | 使用 SSLD 预训练模型 |
| PPLCNet_x1_0 | 9
5.48
| 2.12 | 6.5 | 使用 SSLD 预训练模型+EDA 策略|
|
<b>
PPLCNet_x1_0
<b>
|
<b>
95.
72
<b>
|
<b>
2.12
<b>
|
<b>
6.5
<b>
| 使用 SSLD 预训练模型+EDA 策略+SKL-UGI 知识蒸馏策略|
从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backboone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是会导致精度大幅下降。将 backbone 替换为速度更快的 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 20 多个百分点,与此同时速度依旧可以快 20% 以上。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 2.6 个百分点,进一步地,
当融合EDA策略后,精度可以再提升 1.3 个百分点,最后,在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 2.2
个百分点。此时,PPLCNet_x1_0 达到了 SwinTranformer_tiny 模型的精度,但是速度快 40 多倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。
从表中可以看出,backbone 为 SwinTranformer_tiny 时精度较高,但是推理速度较慢。将 backboone 替换为轻量级模型 MobileNetV3_small_x0_35 后,速度可以大幅提升,但是会导致精度大幅下降。将 backbone 替换为速度更快的 PPLCNet_x1_0 时,精度较 MobileNetV3_small_x0_35 高 20 多个百分点,与此同时速度依旧可以快 20% 以上。在此基础上,使用 SSLD 预训练模型后,在不改变推理速度的前提下,精度可以提升约 2.6 个百分点,进一步地,
在使用 SKL-UGI 知识蒸馏后,精度可以继续提升 0.24
个百分点。此时,PPLCNet_x1_0 达到了 SwinTranformer_tiny 模型的精度,但是速度快 40 多倍。关于 PULC 的训练方法和推理部署方法将在下面详细介绍。
**备注:**
...
...
@@ -81,13 +81,13 @@ pip3 install paddlepaddle paddleclas
*
使用命令行快速预测
```
bash
paddleclas
--model_name
=
car_exists
--infer_imgs
=
deploy/images/PULC/
person_exists/objects365_01780782.jp
g
paddleclas
--model_name
=
car_exists
--infer_imgs
=
deploy/images/PULC/
car_exists/objects365_00001507.jpe
g
```
结果如下:
```
>>> result
class_ids: [
0], scores: [0.9955421453341842], label_names: ['nobody'], filename: deploy/images/PULC/person_exists/objects365_01780782.jp
g
class_ids: [
1], scores: [0.9740616], label_names: ['contains_vehicle'], filename: deploy/images/PULC/car_exists/objects365_00001507.jpe
g
Predict complete!
```
...
...
@@ -98,7 +98,7 @@ Predict complete!
```
python
import
paddleclas
model
=
paddleclas
.
PaddleClas
(
model_name
=
"car_exists"
)
result
=
model
.
predict
(
input_data
=
"deploy/images/PULC/
person_exists/objects365_01780782.jp
g"
)
result
=
model
.
predict
(
input_data
=
"deploy/images/PULC/
car_exists/objects365_00001507.jpe
g"
)
print
(
next
(
result
))
```
...
...
@@ -106,7 +106,7 @@ print(next(result))
```
>>> result
[{'class_ids': [
0], 'scores': [0.9955421453341842], 'label_names': ['nobody'], 'filename': 'PaddleClas/deploy/images/PULC/person_exists/objects365_01780782.jp
g'}]
[{'class_ids': [
1], 'scores': [0.9740616], 'label_names': ['contains_vehicle'], 'filename': 'deploy/images/PULC/car_exists/objects365_00001507.jpe
g'}]
```
<a
name=
"3"
></a>
...
...
@@ -135,13 +135,15 @@ print(next(result))
在公开数据集的基础上经过后处理即可得到本案例需要的数据,具体处理方法如下:
-
训练集合,本案例处理了 Objects365 数据训练集的标注文件,如果某张图含有“
人”的标签,且这个框的面积在整张图中的比例大于 10%,即认为该张图中含有车,如果某张图中没有“车”的标签,则认为该张图中不含有车。经过处理后,得到 92964 条可用数据,其中有人的数据有 39813 条,无人的数据 53151
条。
-
训练集合,本案例处理了 Objects365 数据训练集的标注文件,如果某张图含有“
car”的标签,且这个框的面积在整张图中的比例大于 10%,即认为该张图中含有车,如果某张图中没有任何与交通工具,例如car、bus等相关的的标签,则认为该张图中不含有车。经过处理后,得到 108629 条可用数据,其中有车的数据有 27422 条,无车的数据 81207
条。
-
验证集合,从 Object365 数据中随机抽取一小部分数据,使用在 MS-COCO 上训练得到的较好的模型预测这些数据,将预测结果和数据的标注文件取交集,将交集的结果按照得到训练集的方法筛选出验证集合。经过处理后,得到 27820 条可用数据。其中有人的数据有 2255 条,无人的数据有 25565 条。
-
验证集合,处理方法与训练集相同,数据来源与 Objects365 数据集的验证集。为了测试结果准确,验证集经过人工校正,去除了一些可能存在标注错误的图像。
*
注:由于objects365的标签并不是完全互斥的,例如F1赛车可能是 "F1 Formula",也可能被标称"car"。为了减轻干扰,我们仅保留"car"标签作为有车,而将不含任何交通工具的图作为无车。
处理后的数据集部分数据可视化如下:


此处提供了经过上述方法处理好的数据,可以直接下载得到。
...
...
@@ -156,23 +158,18 @@ cd path_to_PaddleClas
```
shell
cd
dataset
wget https://paddleclas.bj.bcebos.com/data/PULC/
person
_exists.tar
tar
-xf
person
_exists.tar
wget https://paddleclas.bj.bcebos.com/data/PULC/
car
_exists.tar
tar
-xf
car
_exists.tar
cd
../
```
执行上述命令后,
`dataset/`
下存在
`
person
_exists`
目录,该目录中具有以下数据:
执行上述命令后,
`dataset/`
下存在
`
car
_exists`
目录,该目录中具有以下数据:
```
├── train
│ ├── 000000000009.jpg
│ ├── 000000000025.jpg
...
├── val
│ ├── objects365_01780637.jpg
│ ├── objects365_01780640.jpg
...
├── objects365_car
│ ├── objects365_00000039.jpg
│ ├── objects365_00000099.jpg
├── ImageNet_val
│ ├── ILSVRC2012_val_00000001.JPEG
│ ├── ILSVRC2012_val_00000002.JPEG
...
...
@@ -205,14 +202,14 @@ 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
_exists/PPLCNet_x1_0.yaml
-c
./ppcls/configs/PULC/
car
_exists/PPLCNet_x1_0.yaml
```
验证集的最佳指标在
`0.9
4-0.95
`
之间(数据集较小,容易造成波动)。
验证集的最佳指标在
`0.9
5-0.96
`
之间(数据集较小,容易造成波动)。
**备注:**
*
此时使用的指标为Tpr,该指标描述了在假正类率(Fpr)小于某一个指标时的真正类率(Tpr),是产业中二分类问题常用的指标之一。在本案例中,Fpr 为
千分之一
。关于 Fpr 和 Tpr 的更多介绍,可以参考
[
这里
](
https://baike.baidu.com/item/AUC/19282953
)
。
*
此时使用的指标为Tpr,该指标描述了在假正类率(Fpr)小于某一个指标时的真正类率(Tpr),是产业中二分类问题常用的指标之一。在本案例中,Fpr 为
1/100
。关于 Fpr 和 Tpr 的更多介绍,可以参考
[
这里
](
https://baike.baidu.com/item/AUC/19282953
)
。
*
在eval时,会打印出来当前最佳的 TprAtFpr 指标,具体地,其会打印当前的
`Fpr`
、
`Tpr`
值,以及当前的
`threshold`
值,
`Tpr`
值反映了在当前
`Fpr`
值下的召回率,该值越高,代表模型越好。
`threshold`
表示当前最佳
`Fpr`
所对应的分类阈值,可用于后续模型部署落地等。
...
...
@@ -224,7 +221,7 @@ python3 -m paddle.distributed.launch \
```
bash
python3 tools/eval.py
\
-c
./ppcls/configs/PULC/
person
_exists/PPLCNet_x1_0.yaml
\
-c
./ppcls/configs/PULC/
car
_exists/PPLCNet_x1_0.yaml
\
-o
Global.pretrained_model
=
"output/PPLCNet_x1_0/best_model"
```
...
...
@@ -238,21 +235,21 @@ python3 tools/eval.py \
```
python
python3
tools
/
infer
.
py
\
-
c
.
/
ppcls
/
configs
/
PULC
/
person
_exists
/
PPLCNet_x1_0
.
yaml
\
-
c
.
/
ppcls
/
configs
/
PULC
/
car
_exists
/
PPLCNet_x1_0
.
yaml
\
-
o
Global
.
pretrained_model
=
output
/
PPLCNet_x1_0
/
best_model
\
```
输出结果如下:
```
[{'class_ids': [
0], 'scores': [0.9878496769815683], 'label_names': ['nobody'], 'file_name': './dataset/person_exists/val/objects365_01780637.jp
g'}]
[{'class_ids': [
1], 'scores': [0.9740616], 'label_names': ['contains_vehicle'], 'filename': 'deploy/images/PULC/car_exists/objects365_00001507.jpe
g'}]
```
**备注:**
*
这里
`-o Global.pretrained_model="output/PPLCNet_x1_0/best_model"`
指定了当前最佳权重所在的路径,如果指定其他权重,只需替换对应的路径即可。
*
默认是对
`deploy/images/PULC/
person_exists/objects365_02035329.jp
g`
进行预测,此处也可以通过增加字段
`-o Infer.infer_imgs=xxx`
对其他图片预测。
*
默认是对
`deploy/images/PULC/
car_exists/objects365_00001507.jpe
g`
进行预测,此处也可以通过增加字段
`-o Infer.infer_imgs=xxx`
对其他图片预测。
*
二分类默认的阈值为0.5, 如果需要指定阈值,可以重写
`Infer.PostProcess.threshold`
,如
`-o Infer.PostProcess.threshold=0.9794`
,该值需要根据实际场景来确定,此处的
`0.9794`
是在该场景中的
`val`
数据集在千分之一 Fpr 下得到的最佳 Tpr 所得到的。
...
...
@@ -278,7 +275,7 @@ 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
_exists/PPLCNet/PPLCNet_x1_0.yaml
\
-c
./ppcls/configs/PULC/
car
_exists/PPLCNet/PPLCNet_x1_0.yaml
\
-o
Arch.name
=
ResNet101_vd
```
...
...
@@ -295,7 +292,7 @@ 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
_exists/PPLCNet_x1_0_distillation.yaml
\
-c
./ppcls/configs/PULC/
car
_exists/PPLCNet_x1_0_distillation.yaml
\
-o
Arch.models.0.Teacher.pretrained
=
output/ResNet101_vd/best_model
```
...
...
@@ -330,14 +327,14 @@ Paddle Inference 是飞桨的原生推理库, 作用于服务器端和云端
```
bash
python3 tools/export_model.py
\
-c
./ppcls/configs/PULC/
person
_exists/PPLCNet_x1_0.yaml
\
-c
./ppcls/configs/PULC/
car
_exists/PPLCNet_x1_0.yaml
\
-o
Global.pretrained_model
=
output/DistillationModel/best_model_student
\
-o
Global.save_inference_dir
=
deploy/models/PPLCNet_x1_0_
person
_exists_infer
-o
Global.save_inference_dir
=
deploy/models/PPLCNet_x1_0_
car
_exists_infer
```
执行完该脚本后会在
`deploy/models/`
下生成
`PPLCNet_x1_0_
person
_exists_infer`
文件夹,
`models`
文件夹下应有如下文件结构:
执行完该脚本后会在
`deploy/models/`
下生成
`PPLCNet_x1_0_
car
_exists_infer`
文件夹,
`models`
文件夹下应有如下文件结构:
```
├── PPLCNet_x1_0_
person
_exists_infer
├── PPLCNet_x1_0_
car
_exists_infer
│ ├── inference.pdiparams
│ ├── inference.pdiparams.info
│ └── inference.pdmodel
...
...
@@ -354,13 +351,13 @@ python3 tools/export_model.py \
```
cd deploy/models
# 下载 inference 模型并解压
wget https://paddleclas.bj.bcebos.com/models/PULC/
person_exists_infer.tar && tar -xf person
_exists_infer.tar
wget https://paddleclas.bj.bcebos.com/models/PULC/
car_exists_infer.tar && tar -xf car
_exists_infer.tar
```
解压完毕后,
`models`
文件夹下应有如下文件结构:
```
├──
person
_exists_infer
├──
car
_exists_infer
│ ├── inference.pdiparams
│ ├── inference.pdiparams.info
│ └── inference.pdmodel
...
...
@@ -381,13 +378,13 @@ wget https://paddleclas.bj.bcebos.com/models/PULC/person_exists_infer.tar && tar
cd ../
```
运行下面的命令,对图像
`./images/PULC/
person_exists/objects365_02035329.jp
g`
进行有人/无人分类。
运行下面的命令,对图像
`./images/PULC/
car_exists/objects365_00001507.jpe
g`
进行有人/无人分类。
```
shell
# 使用下面的命令使用 GPU 进行预测
python3.7 python/predict_cls.py
-c
configs/PULC/
person_exists/inference_person
_exists.yaml
python3.7 python/predict_cls.py
-c
configs/PULC/
car_exists/inference_car
_exists.yaml
# 使用下面的命令使用 CPU 进行预测
python3.7 python/predict_cls.py
-c
configs/PULC/
person_exists/inference_person
_exists.yaml
-o
Global.use_gpu
=
False
python3.7 python/predict_cls.py
-c
configs/PULC/
car_exists/inference_car
_exists.yaml
-o
Global.use_gpu
=
False
```
输出结果如下。
...
...
@@ -407,7 +404,7 @@ objects365_02035329.jpg: class id(s): [1], score(s): [1.00], label_name(s): ['so
```
shell
# 使用下面的命令使用 GPU 进行预测,如果希望使用 CPU 预测,可以在命令后面添加 -o Global.use_gpu=False
python3.7 python/predict_cls.py
-c
configs/PULC/
person_exists/inference_person_exists.yaml
-o
Global.infer_imgs
=
"./images/PULC/person
_exists/"
python3.7 python/predict_cls.py
-c
configs/PULC/
car_exists/inference_car_exists.yaml
-o
Global.infer_imgs
=
"./images/PULC/car
_exists/"
```
终端中会输出该文件夹内所有图像的分类结果,如下所示。
...
...
@@ -417,7 +414,7 @@ objects365_01780782.jpg: class id(s): [0], score(s): [1.00], label_name(s): ['no
objects365_02035329.jpg: class id(s): [1], score(s): [1.00], label_name(s): ['someone']
```
其中,
`
someone`
表示该图里存在人,
`nobody`
表示该图里不存在人
。
其中,
`
contains_car`
表示该图里存在车,
`nocar`
表示该图里不存在车
。
<a
name=
"6.3"
></a>
...
...
ppcls/configs/PULC/car_exists/MobileNetV3_small_x0_35.yaml
0 → 100644
浏览文件 @
a3c154fa
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
1
eval_during_train
:
True
eval_interval
:
1
start_eval_epoch
:
10
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
use_dali
:
False
# model architecture
Arch
:
name
:
MobileNetV3_small_x0_35
class_num
:
2
pretrained
:
True
use_sync_bn
:
True
# loss function config for traing/eval process
Loss
:
Train
:
-
CELoss
:
weight
:
1.0
epsilon
:
0.1
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.05
warmup_epoch
:
5
regularizer
:
name
:
'
L2'
coeff
:
0.00001
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/train_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
224
-
RandFlipImage
:
flip_code
:
1
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
512
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
8
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/val_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
deploy/images/PULC/car_exists/objects365_00001507.jpeg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
ThreshOutput
threshold
:
0.5
label_0
:
nobody
label_1
:
someone
Metric
:
Train
:
-
TopkAcc
:
topk
:
[
1
,
2
]
Eval
:
-
TprAtFpr
:
max_fpr
:
0.01
-
TopkAcc
:
topk
:
[
1
,
2
]
ppcls/configs/PULC/car_exists/PPLCNet_x1_0.yaml
0 → 100644
浏览文件 @
a3c154fa
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
1
eval_during_train
:
True
eval_interval
:
1
start_eval_epoch
:
10
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
use_dali
:
False
# model architecture
Arch
:
name
:
PPLCNet_x1_0
class_num
:
2
pretrained
:
True
use_ssld
:
True
use_sync_bn
:
True
# loss function config for traing/eval process
Loss
:
Train
:
-
CELoss
:
weight
:
1.0
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.0125
warmup_epoch
:
5
regularizer
:
name
:
'
L2'
coeff
:
0.00004
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/train_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
192
-
RandFlipImage
:
flip_code
:
1
-
TimmAutoAugment
:
prob
:
0.5
config_str
:
rand-m9-mstd0.5-inc1
interpolation
:
bicubic
img_size
:
192
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
RandomErasing
:
EPSILON
:
0.5
sl
:
0.02
sh
:
1.0/3.0
r1
:
0.3
attempt
:
10
use_log_aspect
:
True
mode
:
pixel
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
8
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists
cls_label_path
:
./dataset/car_exists/val_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
deploy/images/PULC/car_exists/objects365_00001507.jpeg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
ThreshOutput
threshold
:
0.9
label_0
:
nobody
label_1
:
someone
Metric
:
Train
:
-
TopkAcc
:
topk
:
[
1
,
2
]
Eval
:
-
TprAtFpr
:
max_fpr
:
0.01
-
TopkAcc
:
topk
:
[
1
,
2
]
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_distillation.yaml
0 → 100644
浏览文件 @
a3c154fa
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output
device
:
gpu
save_interval
:
1
eval_during_train
:
True
start_eval_epoch
:
1
eval_interval
:
1
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
use_dali
:
False
# model architecture
Arch
:
name
:
"
DistillationModel"
class_num
:
&class_num
2
# if not null, its lengths should be same as models
pretrained_list
:
# if not null, its lengths should be same as models
freeze_params_list
:
-
True
-
False
use_sync_bn
:
True
models
:
-
Teacher
:
name
:
ResNet101_vd
class_num
:
*class_num
-
Student
:
name
:
PPLCNet_x1_0
class_num
:
*class_num
pretrained
:
True
use_ssld
:
True
infer_model_name
:
"
Student"
# loss function config for traing/eval process
Loss
:
Train
:
-
DistillationDMLLoss
:
weight
:
1.0
model_name_pairs
:
-
[
"
Student"
,
"
Teacher"
]
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.01
warmup_epoch
:
5
regularizer
:
name
:
'
L2'
coeff
:
0.00004
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/train_list_for_distill.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
192
-
RandFlipImage
:
flip_code
:
1
-
TimmAutoAugment
:
prob
:
0.0
config_str
:
rand-m9-mstd0.5-inc1
interpolation
:
bicubic
img_size
:
192
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
RandomErasing
:
EPSILON
:
0.1
sl
:
0.02
sh
:
1.0/3.0
r1
:
0.3
attempt
:
10
use_log_aspect
:
True
mode
:
pixel
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
16
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/val_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
deploy/images/PULC/car_exists/objects365_00001507.jpeg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
ThreshOutput
threshold
:
0.5
label_0
:
nobody
label_1
:
someone
Metric
:
Train
:
-
DistillationTopkAcc
:
model_key
:
"
Student"
topk
:
[
1
,
2
]
Eval
:
-
TprAtFpr
:
max_fpr
:
0.01
-
TopkAcc
:
topk
:
[
1
,
2
]
ppcls/configs/PULC/car_exists/PPLCNet_x1_0_search.yaml
0 → 100644
浏览文件 @
a3c154fa
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
1
eval_during_train
:
True
eval_interval
:
1
start_eval_epoch
:
10
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
use_dali
:
False
# model architecture
Arch
:
name
:
PPLCNet_x1_0
class_num
:
2
pretrained
:
True
use_ssld
:
True
use_sync_bn
:
True
# loss function config for traing/eval process
Loss
:
Train
:
-
CELoss
:
weight
:
1.0
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
Momentum
momentum
:
0.9
lr
:
name
:
Cosine
learning_rate
:
0.01
warmup_epoch
:
5
regularizer
:
name
:
'
L2'
coeff
:
0.00004
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/train_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
224
-
RandFlipImage
:
flip_code
:
1
-
TimmAutoAugment
:
prob
:
0.0
config_str
:
rand-m9-mstd0.5-inc1
interpolation
:
bicubic
img_size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
RandomErasing
:
EPSILON
:
0.0
sl
:
0.02
sh
:
1.0/3.0
r1
:
0.3
attempt
:
10
use_log_aspect
:
True
mode
:
pixel
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
8
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/val_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
4
use_shared_memory
:
True
Infer
:
infer_imgs
:
deploy/images/PULC/car_exists/objects365_00001507.jpeg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
ThreshOutput
threshold
:
0.5
label_0
:
nobody
label_1
:
someone
Metric
:
Train
:
-
TopkAcc
:
topk
:
[
1
,
2
]
Eval
:
-
TprAtFpr
:
max_fpr
:
0.01
-
TopkAcc
:
topk
:
[
1
,
2
]
ppcls/configs/PULC/car_exists/SwinTransformer_tiny_patch4_window7_224.yaml
0 → 100644
浏览文件 @
a3c154fa
# global configs
Global
:
checkpoints
:
null
pretrained_model
:
null
output_dir
:
./output/
device
:
gpu
save_interval
:
1
eval_during_train
:
True
eval_interval
:
1
start_eval_epoch
:
10
epochs
:
20
print_batch_step
:
10
use_visualdl
:
False
# used for static mode and model export
image_shape
:
[
3
,
224
,
224
]
save_inference_dir
:
./inference
# training model under @to_static
to_static
:
False
use_dali
:
False
# mixed precision training
AMP
:
scale_loss
:
128.0
use_dynamic_loss_scaling
:
True
# O1: mixed fp16
level
:
O1
# model architecture
Arch
:
name
:
SwinTransformer_tiny_patch4_window7_224
class_num
:
2
pretrained
:
True
# loss function config for traing/eval process
Loss
:
Train
:
-
CELoss
:
weight
:
1.0
epsilon
:
0.1
Eval
:
-
CELoss
:
weight
:
1.0
Optimizer
:
name
:
AdamW
beta1
:
0.9
beta2
:
0.999
epsilon
:
1e-8
weight_decay
:
0.05
no_weight_decay_name
:
absolute_pos_embed relative_position_bias_table .bias norm
one_dim_param_no_weight_decay
:
True
lr
:
name
:
Cosine
learning_rate
:
1e-4
eta_min
:
2e-6
warmup_epoch
:
5
warmup_start_lr
:
2e-7
# data loader for train and eval
DataLoader
:
Train
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/train_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
RandCropImage
:
size
:
224
interpolation
:
bicubic
backend
:
pil
-
RandFlipImage
:
flip_code
:
1
-
TimmAutoAugment
:
config_str
:
rand-m9-mstd0.5-inc1
interpolation
:
bicubic
img_size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
RandomErasing
:
EPSILON
:
0.25
sl
:
0.02
sh
:
1.0/3.0
r1
:
0.3
attempt
:
10
use_log_aspect
:
True
mode
:
pixel
batch_transform_ops
:
-
OpSampler
:
MixupOperator
:
alpha
:
0.8
prob
:
0.5
CutmixOperator
:
alpha
:
1.0
prob
:
0.5
sampler
:
name
:
DistributedBatchSampler
batch_size
:
128
drop_last
:
False
shuffle
:
True
loader
:
num_workers
:
8
use_shared_memory
:
True
Eval
:
dataset
:
name
:
ImageNetDataset
image_root
:
./dataset/car_exists/
cls_label_path
:
./dataset/car_exists/val_list.txt
transform_ops
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
sampler
:
name
:
DistributedBatchSampler
batch_size
:
64
drop_last
:
False
shuffle
:
False
loader
:
num_workers
:
8
use_shared_memory
:
True
Infer
:
infer_imgs
:
deploy/images/PULC/car_exists/objects365_00001507.jpeg
batch_size
:
10
transforms
:
-
DecodeImage
:
to_rgb
:
True
channel_first
:
False
-
ResizeImage
:
resize_short
:
256
-
CropImage
:
size
:
224
-
NormalizeImage
:
scale
:
1.0/255.0
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
PostProcess
:
name
:
ThreshOutput
threshold
:
0.5
label_0
:
nobody
label_1
:
someone
Metric
:
Train
:
-
TopkAcc
:
topk
:
[
1
,
2
]
Eval
:
-
TprAtFpr
:
max_fpr
:
0.01
-
TopkAcc
:
topk
:
[
1
,
2
]
ppcls/configs/PULC/car_exists/search.yaml
0 → 100644
浏览文件 @
a3c154fa
base_config_file
:
ppcls/configs/PULC/person_exists/PPLCNet_x1_0_search.yaml
distill_config_file
:
ppcls/configs/PULC/person_exists/PPLCNet_x1_0_distillation.yaml
gpus
:
0,1,2,3
output_dir
:
output/search_person_cls
search_times
:
1
search_dict
:
-
search_key
:
lrs
replace_config
:
-
Optimizer.lr.learning_rate
search_values
:
[
0.0075
,
0.01
,
0.0125
]
-
search_key
:
resolutions
replace_config
:
-
DataLoader.Train.dataset.transform_ops.1.RandCropImage.size
-
DataLoader.Train.dataset.transform_ops.3.TimmAutoAugment.img_size
search_values
:
[
176
,
192
,
224
]
-
search_key
:
ra_probs
replace_config
:
-
DataLoader.Train.dataset.transform_ops.3.TimmAutoAugment.prob
search_values
:
[
0.0
,
0.1
,
0.5
]
-
search_key
:
re_probs
replace_config
:
-
DataLoader.Train.dataset.transform_ops.5.RandomErasing.EPSILON
search_values
:
[
0.0
,
0.1
,
0.5
]
-
search_key
:
lr_mult_list
replace_config
:
-
Arch.lr_mult_list
search_values
:
-
[
0.0
,
0.2
,
0.4
,
0.6
,
0.8
,
1.0
]
-
[
0.0
,
0.4
,
0.4
,
0.8
,
0.8
,
1.0
]
-
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
1.0
]
teacher
:
rm_keys
:
-
Arch.lr_mult_list
search_values
:
-
ResNet101_vd
-
ResNet50_vd
final_replace
:
Arch.lr_mult_list
:
Arch.models.1.Student.lr_mult_list
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录