Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
e9b81b41
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e9b81b41
编写于
4月 07, 2021
作者:
K
Kaipeng Deng
提交者:
GitHub
4月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add static notice (#2422)
* add static notice
上级
de808d9c
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
435 addition
and
172 deletion
+435
-172
static/slim/distillation/distill.py
static/slim/distillation/distill.py
+25
-11
static/slim/extensions/distill_pruned_model/distill_pruned_model.py
...m/extensions/distill_pruned_model/distill_pruned_model.py
+25
-11
static/slim/nas/train_nas.py
static/slim/nas/train_nas.py
+28
-14
static/slim/prune/eval.py
static/slim/prune/eval.py
+22
-9
static/slim/prune/export_model.py
static/slim/prune/export_model.py
+22
-8
static/slim/prune/prune.py
static/slim/prune/prune.py
+23
-10
static/slim/quantization/eval.py
static/slim/quantization/eval.py
+22
-9
static/slim/quantization/export_model.py
static/slim/quantization/export_model.py
+23
-9
static/slim/quantization/infer.py
static/slim/quantization/infer.py
+23
-9
static/slim/quantization/train.py
static/slim/quantization/train.py
+25
-10
static/tools/anchor_cluster.py
static/tools/anchor_cluster.py
+21
-7
static/tools/configure.py
static/tools/configure.py
+20
-2
static/tools/eval.py
static/tools/eval.py
+22
-9
static/tools/export_model.py
static/tools/export_model.py
+19
-5
static/tools/export_serving_model.py
static/tools/export_serving_model.py
+20
-6
static/tools/face_eval.py
static/tools/face_eval.py
+20
-7
static/tools/infer.py
static/tools/infer.py
+23
-10
static/tools/train.py
static/tools/train.py
+24
-11
static/tools/train_multi_machine.py
static/tools/train_multi_machine.py
+28
-15
未找到文件。
static/slim/distillation/distill.py
浏览文件 @
e9b81b41
...
...
@@ -22,24 +22,38 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
import
numpy
as
np
from
collections
import
OrderedDict
from
paddleslim.dist.single_distiller
import
merge
,
l2_loss
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_results
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_results
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
l2_distill
(
pairs
,
weight
):
...
...
static/slim/extensions/distill_pruned_model/distill_pruned_model.py
浏览文件 @
e9b81b41
...
...
@@ -23,6 +23,11 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
import
numpy
as
np
from
collections
import
OrderedDict
from
paddleslim.dist.single_distiller
import
merge
,
l2_loss
...
...
@@ -31,18 +36,27 @@ from paddleslim.analysis import flops
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_results
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_results
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
split_distill
(
split_output_names
,
weight
,
target_number
):
...
...
static/slim/nas/train_nas.py
浏览文件 @
e9b81b41
...
...
@@ -30,25 +30,39 @@ from collections import deque
import
paddle
from
paddle
import
fluid
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
,
register
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
from
paddleslim.analysis
import
flops
,
TableLatencyEvaluator
from
paddleslim.nas
import
SANAS
import
search_space
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
,
register
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
from
paddleslim.analysis
import
flops
,
TableLatencyEvaluator
from
paddleslim.nas
import
SANAS
import
search_space
@
register
class
Constraint
(
object
):
...
...
static/slim/prune/eval.py
浏览文件 @
e9b81b41
...
...
@@ -28,20 +28,33 @@ import paddle.fluid as fluid
from
paddleslim.prune
import
Pruner
from
paddleslim.analysis
import
flops
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
"""
...
...
static/slim/prune/export_model.py
浏览文件 @
e9b81b41
...
...
@@ -25,19 +25,33 @@ if parent_path not in sys.path:
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
from
paddleslim.prune
import
Pruner
from
paddleslim.analysis
import
flops
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
from
paddleslim.prune
import
Pruner
from
paddleslim.analysis
import
flops
def
main
():
cfg
=
load_config
(
FLAGS
.
config
)
...
...
static/slim/prune/prune.py
浏览文件 @
e9b81b41
...
...
@@ -32,21 +32,34 @@ from paddleslim.analysis import flops
import
paddle
from
paddle
import
fluid
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
env
=
os
.
environ
...
...
static/slim/quantization/eval.py
浏览文件 @
e9b81b41
...
...
@@ -26,20 +26,33 @@ if parent_path not in sys.path:
import
paddle
import
paddle.fluid
as
fluid
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
# import paddleslim
from
paddleslim.quant
import
quant_aware
,
convert
...
...
static/slim/quantization/export_model.py
浏览文件 @
e9b81b41
...
...
@@ -22,19 +22,33 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
import
paddle
from
paddle
import
fluid
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
from
paddleslim.quant
import
quant_aware
,
convert
...
...
static/slim/quantization/infer.py
浏览文件 @
e9b81b41
...
...
@@ -29,19 +29,33 @@ from PIL import Image
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.data.reader
import
create_reader
from
tools.infer
import
get_test_images
,
get_save_image_name
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.data.reader
import
create_reader
from
tools.infer
import
get_test_images
,
get_save_image_name
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
from
paddleslim.quant
import
quant_aware
,
convert
...
...
static/slim/quantization/train.py
浏览文件 @
e9b81b41
...
...
@@ -31,21 +31,36 @@ import shutil
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
from
paddleslim.quant
import
quant_aware
,
convert
from
pact
import
pact
,
get_optimizer
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
from
paddleslim.quant
import
quant_aware
,
convert
from
pact
import
pact
,
get_optimizer
def
save_checkpoint
(
exe
,
prog
,
path
,
train_prog
):
if
os
.
path
.
isdir
(
path
):
...
...
static/tools/anchor_cluster.py
浏览文件 @
e9b81b41
...
...
@@ -23,18 +23,32 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
from
scipy.cluster.vq
import
kmeans
import
random
import
numpy
as
np
from
tqdm
import
tqdm
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
class
BaseAnchorCluster
(
object
):
...
...
static/tools/configure.py
浏览文件 @
e9b81b41
...
...
@@ -23,10 +23,28 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
import
yaml
from
ppdet.core.workspace
import
get_registered_modules
,
load_config
,
dump_value
from
ppdet.utils.cli
import
ColorTTY
,
print_total_cfg
try
:
from
ppdet.core.workspace
import
get_registered_modules
,
load_config
,
dump_value
from
ppdet.utils.cli
import
ColorTTY
,
print_total_cfg
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
color_tty
=
ColorTTY
()
...
...
static/tools/eval.py
浏览文件 @
e9b81b41
...
...
@@ -25,20 +25,33 @@ if parent_path not in sys.path:
import
paddle
import
paddle.fluid
as
fluid
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_xpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_xpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.data.reader
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
"""
...
...
static/tools/export_model.py
浏览文件 @
e9b81b41
...
...
@@ -26,16 +26,30 @@ if parent_path not in sys.path:
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
check_py_func
,
enable_static_mode
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
save_infer_model
,
dump_infer_config
from
ppdet.utils.check
import
check_config
,
check_version
,
check_py_func
,
enable_static_mode
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
cfg
=
load_config
(
FLAGS
.
config
)
...
...
static/tools/export_serving_model.py
浏览文件 @
e9b81b41
...
...
@@ -22,20 +22,34 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
yaml
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
yaml
import
logging
from
ppdet.utils.export_utils
import
dump_infer_config
,
prune_feed_vars
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_config
,
check_version
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.export_utils
import
dump_infer_config
,
prune_feed_vars
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
save_serving_model
(
FLAGS
,
exe
,
feed_vars
,
test_fetches
,
infer_prog
):
cfg_name
=
os
.
path
.
basename
(
FLAGS
.
config
).
split
(
'.'
)[
0
]
...
...
static/tools/face_eval.py
浏览文件 @
e9b81b41
...
...
@@ -29,18 +29,31 @@ import numpy as np
import
cv2
from
collections
import
OrderedDict
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.widerface_eval_utils
import
get_shrink
,
bbox_vote
,
\
save_widerface_bboxes
,
save_fddb_bboxes
,
to_chw_bgr
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.widerface_eval_utils
import
get_shrink
,
bbox_vote
,
\
save_widerface_bboxes
,
save_fddb_bboxes
,
to_chw_bgr
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
face_img_process
(
image
,
mean
=
[
104.
,
117.
,
123.
],
...
...
static/tools/infer.py
浏览文件 @
e9b81b41
...
...
@@ -30,21 +30,34 @@ from PIL import Image, ImageOps
import
paddle
from
paddle
import
fluid
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.data.reader
import
create_reader
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.data.reader
import
create_reader
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
get_save_image_name
(
output_dir
,
image_path
):
"""
...
...
static/tools/train.py
浏览文件 @
e9b81b41
...
...
@@ -35,22 +35,35 @@ from paddle import fluid
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
from
paddle.fluid.optimizer
import
ExponentialMovingAverage
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_xpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_xpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
env
=
os
.
environ
...
...
static/tools/train_multi_machine.py
浏览文件 @
e9b81b41
...
...
@@ -22,6 +22,11 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if
parent_path
not
in
sys
.
path
:
sys
.
path
.
append
(
parent_path
)
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
import
time
import
numpy
as
np
import
random
...
...
@@ -35,24 +40,32 @@ from paddle import fluid
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
from
paddle.fluid.optimizer
import
ExponentialMovingAverage
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
from
paddle.fluid.incubate.fleet.collective
import
fleet
,
DistributedStrategy
# new line 1
from
paddle.fluid.incubate.fleet.base
import
role_maker
# new line 2
import
logging
FORMAT
=
'%(asctime)s-%(levelname)s: %(message)s'
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
FORMAT
)
logger
=
logging
.
getLogger
(
__name__
)
try
:
from
ppdet.experimental
import
mixed_precision_context
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.data.reader
import
create_reader
from
ppdet.utils
import
dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
,
enable_static_mode
import
ppdet.utils.checkpoint
as
checkpoint
except
ImportError
as
e
:
if
sys
.
argv
[
0
].
find
(
'static'
)
>=
0
:
logger
.
error
(
"Importing ppdet failed when running static model "
"with error: {}
\n
"
"please try:
\n
"
"
\t
1. run static model under PaddleDetection/static "
"directory
\n
"
"
\t
2. run 'pip uninstall ppdet' to uninstall ppdet "
"dynamic version firstly."
.
format
(
e
))
sys
.
exit
(
-
1
)
else
:
raise
e
def
main
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录