Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
3919b464
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
115
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看板
提交
3919b464
编写于
7月 09, 2020
作者:
S
shippingwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add static debug tool
上级
d7d5353b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
151 addition
and
6 deletion
+151
-6
configs/debug.yaml
configs/debug.yaml
+92
-0
ppcls/data/imaug/operators.py
ppcls/data/imaug/operators.py
+10
-3
ppcls/data/reader.py
ppcls/data/reader.py
+7
-1
tools/program.py
tools/program.py
+28
-2
tools/run_debug.sh
tools/run_debug.sh
+8
-0
tools/train.py
tools/train.py
+6
-0
未找到文件。
configs/debug.yaml
0 → 100644
浏览文件 @
3919b464
mode
:
'
train'
ARCHITECTURE
:
name
:
"
MobileNetV1"
pretrained_model
:
"
"
model_save_dir
:
"
./output/"
classes_num
:
1000
total_images
:
1281167
save_interval
:
1
validate
:
True
valid_interval
:
1
epochs
:
2
topk
:
5
image_shape
:
[
3
,
224
,
224
]
LEARNING_RATE
:
function
:
'
Piecewise'
params
:
lr
:
0.1
decay_epochs
:
[
30
,
60
,
90
]
gamma
:
0.1
OPTIMIZER
:
function
:
'
Momentum'
params
:
momentum
:
0.9
regularizer
:
function
:
'
L2'
factor
:
0.00003
TRAIN
:
batch_size
:
4
num_workers
:
4
file_list
:
"
./dataset/ILSVRC2012/val_list_debug.txt"
data_dir
:
"
./dataset/ILSVRC2012/"
shuffle_seed
:
0
transforms
:
-
DecodeImage
:
to_rgb
:
True
to_np
:
False
channel_first
:
False
-
RandCropImage
:
size
:
224
-
RandFlipImage
:
flip_code
:
1
-
NormalizeImage
:
scale
:
1./255.
mean
:
[
0.485
,
0.456
,
0.406
]
std
:
[
0.229
,
0.224
,
0.225
]
order
:
'
'
-
ToCHWImage
:
VALID
:
batch_size
:
64
num_workers
:
4
file_list
:
"
./dataset/ILSVRC2012/val_list.txt"
data_dir
:
"
./dataset/ILSVRC2012/"
shuffle_seed
:
0
transforms
:
-
DecodeImage
:
to_rgb
:
True
to_np
:
False
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
:
DEBUG
:
fake_input
:
'
1.jpg'
repeat_times
:
8
epoch_num
:
1
forward
:
True
backward
:
False
fetch_list
:
'
ALL'
disable_random
:
drop_out
:
random_preprocess
:
init_function
:
weights
:
1
bias
:
0
save_report
:
True
print_summary
:
True
ppcls/data/imaug/operators.py
浏览文件 @
3919b464
...
...
@@ -24,6 +24,7 @@ import math
import
random
import
cv2
import
numpy
as
np
import
os
from
.autoaugment
import
ImageNetPolicy
...
...
@@ -151,12 +152,16 @@ class RandCropImage(object):
i
=
random
.
randint
(
0
,
img_w
-
w
)
j
=
random
.
randint
(
0
,
img_h
-
h
)
img_adj
=
img
[
j
:
j
+
h
,
i
:
i
+
w
,
:]
img
=
img
[
j
:
j
+
h
,
i
:
i
+
w
,
:]
if
int
(
os
.
environ
.
get
(
'PADDLECLAS_DEBUG'
)):
img_adj
=
img
if
self
.
interpolation
is
None
:
return
cv2
.
resize
(
img
,
size
)
return
cv2
.
resize
(
img
_adj
,
size
)
else
:
return
cv2
.
resize
(
img
,
size
,
interpolation
=
self
.
interpolation
)
return
cv2
.
resize
(
img
_adj
,
size
,
interpolation
=
self
.
interpolation
)
class
RandFlipImage
(
object
):
...
...
@@ -173,6 +178,8 @@ class RandFlipImage(object):
self
.
flip_code
=
flip_code
def
__call__
(
self
,
img
):
if
int
(
os
.
environ
.
get
(
'PADDLECLAS_DEBUG'
)):
return
img
if
random
.
randint
(
0
,
1
)
==
1
:
return
cv2
.
flip
(
img
,
self
.
flip_code
)
else
:
...
...
ppcls/data/reader.py
浏览文件 @
3919b464
...
...
@@ -192,7 +192,9 @@ def partial_reader(params, full_lines, part_id=0, part_num=1, batch_size=1):
delimiter
=
params
.
get
(
'delimiter'
,
' '
)
for
line
in
full_lines
:
img_path
,
label
=
line
.
split
(
delimiter
)
img_path
=
os
.
path
.
join
(
params
[
'data_dir'
],
img_path
)
with
open
(
img_path
,
'rb'
)
as
f
:
img
=
f
.
read
()
yield
(
transform
(
img
,
ops
),
int
(
label
))
...
...
@@ -259,6 +261,8 @@ class Reader:
self
.
use_gpu
=
config
.
get
(
"use_gpu"
,
True
)
use_mix
=
config
.
get
(
'use_mix'
)
self
.
params
[
'mode'
]
=
mode
if
int
(
os
.
environ
.
get
(
'PADDLECLAS_DEBUG'
)):
self
.
params
[
'debug'
]
=
config
[
'DEBUG'
]
if
seed
is
not
None
:
self
.
params
[
'shuffle_seed'
]
=
seed
self
.
batch_ops
=
[]
...
...
@@ -278,6 +282,9 @@ class Reader:
def
wrapper
():
reader
=
mp_reader
(
self
.
params
,
batch_size
)
batch
=
[]
if
int
(
os
.
environ
.
get
(
'PADDLECLAS_DEBUG'
)):
fake_image_path
=
self
.
params
.
debug
.
fake_input
reader
=
partial_reader
(
self
.
params
,
[
fake_image_path
+
' 1'
]
*
self
.
params
.
debug
.
repeat_times
)
for
idx
,
sample
in
enumerate
(
reader
()):
img
,
label
=
sample
batch
.
append
((
img
,
label
))
...
...
@@ -288,6 +295,5 @@ class Reader:
return
wrapper
signal
.
signal
(
signal
.
SIGINT
,
term_mp
)
signal
.
signal
(
signal
.
SIGTERM
,
term_mp
)
tools/program.py
浏览文件 @
3919b464
...
...
@@ -369,6 +369,14 @@ def build(config, main_prog, startup_prog, is_train=True, is_distributed=True):
config
.
get
(
'ema_decay'
),
thres_steps
=
global_steps
)
ema
.
update
()
return
dataloader
,
fetchs
,
ema
if
int
(
os
.
environ
.
get
(
'PADDLECLAS_DEBUG'
)):
v
=
[]
for
var
in
main_prog
.
list_vars
():
#print(var.name)
if
'velocity'
not
in
var
.
name
and
'conv6_weights'
in
var
.
name
:
v
.
append
(
var
.
name
)
fetchs
[
'debug'
]
=
v
return
dataloader
,
fetchs
...
...
@@ -425,16 +433,32 @@ def run(dataloader,
Returns:
"""
fetch_list
=
[
f
[
0
]
for
f
in
fetchs
.
values
()]
metric_list
=
[
f
[
1
]
for
f
in
fetchs
.
values
()]
fetch_list
=
[]
metric_list
=
[]
debug_ops
=
0
for
k
,
v
in
fetchs
.
items
():
if
k
!=
'debug'
:
metric_list
.
append
(
v
[
1
])
fetch_list
.
append
(
v
[
0
])
else
:
debug_ops
=
debug_ops
+
len
(
v
)
fetch_list
=
fetch_list
+
v
for
m
in
metric_list
:
m
.
reset
()
batch_time
=
AverageMeter
(
'elapse'
,
'.3f'
)
tic
=
time
.
time
()
for
idx
,
batch
in
enumerate
(
dataloader
()):
metrics
=
exe
.
run
(
program
=
program
,
feed
=
batch
,
fetch_list
=
fetch_list
)
batch_time
.
update
(
time
.
time
()
-
tic
)
tic
=
time
.
time
()
logger
.
info
(
"DEBUG {:s} "
.
format
(
metrics
))
metrics
=
metrics
[:
-
debug_ops
]
for
i
,
m
in
enumerate
(
metrics
):
metric_list
[
i
].
update
(
np
.
mean
(
m
),
len
(
batch
[
0
]))
fetchs_str
=
''
.
join
([
str
(
m
.
value
)
+
' '
...
...
@@ -467,6 +491,8 @@ def run(dataloader,
logger
.
coloring
(
step_str
,
"PURPLE"
),
logger
.
coloring
(
fetchs_str
,
'OKGREEN'
)))
#sys.stdout.flush()
end_str
=
''
.
join
([
str
(
m
.
mean
)
+
' '
for
m
in
metric_list
]
+
[
batch_time
.
total
])
+
's'
if
mode
==
'eval'
:
...
...
tools/run_debug.sh
0 → 100644
浏览文件 @
3919b464
#!/usr/bin/env bash
export
PYTHONPATH
=
$PWD
:
$PYTHONPATH
python
-m
paddle.distributed.launch
\
--selected_gpus
=
"0"
\
tools/train.py
\
-c
./configs/debug.yaml
tools/train.py
浏览文件 @
3919b464
...
...
@@ -49,6 +49,12 @@ def parse_args():
action
=
'append'
,
default
=
[],
help
=
'config options to be overridden'
)
parser
.
add_argument
(
'-d'
,
'--debug'
,
default
=
False
,
help
=
'debug'
)
args
=
parser
.
parse_args
()
return
args
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录