Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
53014d34
P
PaddleOCR
项目概览
s920243400
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
53014d34
编写于
8月 26, 2021
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fpgm to ocr_det ci
上级
4561fbf1
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
68 addition
and
14 deletion
+68
-14
deploy/slim/prune/sensitivity_anal.py
deploy/slim/prune/sensitivity_anal.py
+10
-9
tests/ocr_det_params.txt
tests/ocr_det_params.txt
+4
-4
tests/ocr_det_params_prune.txt
tests/ocr_det_params_prune.txt
+52
-0
tests/prepare.sh
tests/prepare.sh
+2
-1
未找到文件。
deploy/slim/prune/sensitivity_anal.py
浏览文件 @
53014d34
...
@@ -75,7 +75,7 @@ def main(config, device, logger, vdl_writer):
...
@@ -75,7 +75,7 @@ def main(config, device, logger, vdl_writer):
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
flops
=
paddle
.
flops
(
model
,
[
1
,
3
,
640
,
640
])
flops
=
paddle
.
flops
(
model
,
[
1
,
3
,
640
,
640
])
logger
.
info
(
f
"FLOPs before pruning:
{
flops
}
"
)
logger
.
info
(
"FLOPs before pruning: {}"
.
format
(
flops
)
)
from
paddleslim.dygraph
import
FPGMFilterPruner
from
paddleslim.dygraph
import
FPGMFilterPruner
model
.
train
()
model
.
train
()
...
@@ -106,8 +106,8 @@ def main(config, device, logger, vdl_writer):
...
@@ -106,8 +106,8 @@ def main(config, device, logger, vdl_writer):
def
eval_fn
():
def
eval_fn
():
metric
=
program
.
eval
(
model
,
valid_dataloader
,
post_process_class
,
metric
=
program
.
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
)
eval_class
,
False
)
logger
.
info
(
f
"metric['hmean']:
{
metric
[
'hmean'
]
}
"
)
logger
.
info
(
"metric['hmean']: {}"
.
format
(
metric
[
'hmean'
])
)
return
metric
[
'hmean'
]
return
metric
[
'hmean'
]
params_sensitive
=
pruner
.
sensitive
(
params_sensitive
=
pruner
.
sensitive
(
...
@@ -123,16 +123,17 @@ def main(config, device, logger, vdl_writer):
...
@@ -123,16 +123,17 @@ def main(config, device, logger, vdl_writer):
# calculate pruned params's ratio
# calculate pruned params's ratio
params_sensitive
=
pruner
.
_get_ratios_by_loss
(
params_sensitive
,
loss
=
0.02
)
params_sensitive
=
pruner
.
_get_ratios_by_loss
(
params_sensitive
,
loss
=
0.02
)
for
key
in
params_sensitive
.
keys
():
for
key
in
params_sensitive
.
keys
():
logger
.
info
(
f
"
{
key
}
,
{
params_sensitive
[
key
]
}
"
)
logger
.
info
(
"{}, {}"
.
format
(
key
,
params_sensitive
[
key
]))
#params_sensitive = {}
#for param in model.parameters():
# if 'transpose' not in param.name and 'linear' not in param.name:
# params_sensitive[param.name] = 0.1
plan
=
pruner
.
prune_vars
(
params_sensitive
,
[
0
])
plan
=
pruner
.
prune_vars
(
params_sensitive
,
[
0
])
for
param
in
model
.
parameters
():
if
(
"weights"
in
param
.
name
and
"conv"
in
param
.
name
)
or
(
"w_0"
in
param
.
name
and
"conv2d"
in
param
.
name
):
logger
.
info
(
f
"
{
param
.
name
}
:
{
param
.
shape
}
"
)
flops
=
paddle
.
flops
(
model
,
[
1
,
3
,
640
,
640
])
flops
=
paddle
.
flops
(
model
,
[
1
,
3
,
640
,
640
])
logger
.
info
(
f
"FLOPs after pruning:
{
flops
}
"
)
logger
.
info
(
"FLOPs after pruning: {}"
.
format
(
flops
)
)
# start train
# start train
...
...
tests/ocr_det_params.txt
浏览文件 @
53014d34
===========================train_params===========================
===========================train_params===========================
model_name:ocr_det
model_name:ocr_det
python:python3.7
python:python3.7
gpu_list:
0|0,1
gpu_list:
3
Global.use_gpu:True|True
Global.use_gpu:True|True
Global.auto_cast:null
Global.auto_cast:null
Global.epoch_num:lite_train_infer=
2
|whole_train_infer=300
Global.epoch_num:lite_train_infer=
1
|whole_train_infer=300
Global.save_model_dir:./output/
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_infer=2|whole_train_infer=4
Train.loader.batch_size_per_card:lite_train_infer=2|whole_train_infer=4
Global.pretrained_model:null
Global.pretrained_model:null
...
@@ -15,7 +15,7 @@ null:null
...
@@ -15,7 +15,7 @@ null:null
trainer:norm_train|pact_train
trainer:norm_train|pact_train
norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
pact_train:deploy/slim/quantization/quant.py -c configs/det/det_mv3_db.yml -o
pact_train:deploy/slim/quantization/quant.py -c configs/det/det_mv3_db.yml -o
fpgm_train:
null
fpgm_train:
deploy/slim/prune/sensitivity_anal.py -c configs/det/det_mv3_db.yml -o
distill_train:null
distill_train:null
null:null
null:null
null:null
null:null
...
@@ -29,7 +29,7 @@ Global.save_inference_dir:./output/
...
@@ -29,7 +29,7 @@ Global.save_inference_dir:./output/
Global.pretrained_model:
Global.pretrained_model:
norm_export:tools/export_model.py -c configs/det/det_mv3_db.yml -o
norm_export:tools/export_model.py -c configs/det/det_mv3_db.yml -o
quant_export:deploy/slim/quantization/export_model.py -c configs/det/det_mv3_db.yml -o
quant_export:deploy/slim/quantization/export_model.py -c configs/det/det_mv3_db.yml -o
fpgm_export:deploy/slim/prune/export_prune_model.py
fpgm_export:deploy/slim/prune/export_prune_model.py
-c configs/det/det_mv3_db.yml -o
distill_export:null
distill_export:null
export1:null
export1:null
export2:null
export2:null
...
...
tests/ocr_det_params_prune.txt
0 → 100644
浏览文件 @
53014d34
===========================train_params===========================
model_name:ocr_det
python:python3.7
gpu_list:3
Global.use_gpu:True
Global.auto_cast:null
Global.epoch_num:lite_train_infer=1|whole_train_infer=300
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_infer=2|whole_train_infer=4
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/
null:null
##
trainer:fpgm_train
norm_train:null
pact_train:null
fpgm_train:deploy/slim/prune/sensitivity_anal.py -c configs/det/det_mv3_db.yml -o
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c configs/det/det_mv3_db.yml -o
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.pretrained_model:
norm_export:tools/export_model.py -c configs/det/det_mv3_db.yml -o
quant_export:deploy/slim/quantization/export_model.py -c configs/det/det_mv3_db.yml -o
fpgm_export:deploy/slim/prune/export_prune_model.py -c configs/det/det_mv3_db.yml -o
distill_export:null
export1:null
export2:null
##
infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer/
infer_export:null
infer_quant:False
inference:tools/infer/predict_det.py
--use_gpu:True|False
--enable_mkldnn:True|False
--cpu_threads:1|6
--rec_batch_num:1
--use_tensorrt:False|True
--precision:fp32|fp16|int8
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
--save_log_path:null
--benchmark:True
null:null
tests/prepare.sh
浏览文件 @
53014d34
...
@@ -38,6 +38,7 @@ if [ ${MODE} = "lite_train_infer" ];then
...
@@ -38,6 +38,7 @@ if [ ${MODE} = "lite_train_infer" ];then
rm
-rf
./train_data/ic15_data
rm
-rf
./train_data/ic15_data
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
# todo change to bcebos
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
# todo change to bcebos
wget
-nc
-P
./deploy/slim/prune https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/sen.pickle
cd
./train_data/
&&
tar
xf icdar2015_lite.tar
&&
tar
xf ic15_data.tar
cd
./train_data/
&&
tar
xf icdar2015_lite.tar
&&
tar
xf ic15_data.tar
ln
-s
./icdar2015_lite ./icdar2015
ln
-s
./icdar2015_lite ./icdar2015
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录