Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
579be0c1
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
579be0c1
编写于
6年前
作者:
Q
qingqing01
提交者:
GitHub
6年前
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add copyright and fix profile.py (#1292)
上级
4f422f02
release/1.8
XiaoguangHu01-patch-1
ZeyuChen-patch-1
dependabot/pip/PaddleRec/ctr/wide_deep/bleach-3.1.4
dependabot/pip/PaddleRec/ctr/wide_deep/notebook-5.7.8
dependabot/pip/PaddleRec/ncf/bleach-3.1.4
dependabot/pip/PaddleRec/ncf/notebook-5.7.8
dependabot/pip/PaddleRec/wide_deep/bleach-3.1.4
dependabot/pip/PaddleRec/wide_deep/notebook-5.7.8
dev-static
develop
dyning-patch-1
fix_bug
github/fork/0YuanZhang0/fix_author_info
github/fork/0YuanZhang0/upgrade_ade
github/fork/1024er/fix_vae_update
github/fork/123malin/matchnet
github/fork/123malin/w2v_shuffle_batch
github/fork/BeyondYourself/patch-3
github/fork/CandyCaneLane/deepfm_
github/fork/CandyCaneLane/xdeepfm
github/fork/DrRyanHuang/patch-1
github/fork/FDInSky/dyg_det
github/fork/FrostML/simnet
github/fork/GT-ZhangAcer/develop
github/fork/Haichao-Zhang/typo_fix
github/fork/JepsonWong/ptb_lm_dataloader1
github/fork/JepsonWong/seq2seq_dataloader
github/fork/JesseyXujin/cherry-pick-fix-load
github/fork/JesseyXujin/elmo
github/fork/JesseyXujin/elmo_new
github/fork/JesseyXujin/elmo_test
github/fork/JesseyXujin/senta1
github/fork/JesseyXujin/senta_readme_update
github/fork/JiabinYang/add-word2vec
github/fork/JiabinYang/test_word2vec
github/fork/JianzhouZhan/develop
github/fork/Joejiong/joe_model_1.8_update
github/fork/Joejiong/joe_model_1.8_update_1
github/fork/Joejiong/update_1.8
github/fork/LiuChaoXD/liuchao45-tsn
github/fork/LiuChiachi/seq2seq_attn_using_api2.0-beta
github/fork/LongXinchen/longxinchen2
github/fork/LutaoChu/develop
github/fork/MrChengmo/tdm_dev
github/fork/Renwb1991/my-cool-stuff
github/fork/RonaldJEN/develop
github/fork/Steffy-zxf/fix-argument-use-gpu
github/fork/Steffy-zxf/update-pcr-README
github/fork/SunAhong1993/develop
github/fork/SunGaofeng/v16loadfix
github/fork/Sunyingbin/release/1.8
github/fork/Xreki/amp/resnet50
github/fork/Xreki/benchmark/video
github/fork/Yancey1989/disable_debug
github/fork/Yancey1989/dygraph_dist_resnet
github/fork/Yancey1989/fast_imagenet_mp
github/fork/Yancey1989/visreader
github/fork/ccmeteorljh/develop
github/fork/ceci3/add_in
github/fork/ceci3/c_gan
github/fork/ceci3/develop
github/fork/ceci3/fix_cgan
github/fork/chajchaj/mobile0208
github/fork/chengweiv5/fix-gru4rec-doc
github/fork/chenwhql/dataloader_test_phase2
github/fork/chenwhql/dygraph/dataloader_test
github/fork/chenwhql/fix_reader_usage_error
github/fork/cjld/fix2
github/fork/cjt222/1.7_local
github/fork/cjt222/fix_bug_py2andpy3
github/fork/cuicheng01/update_inference_time
github/fork/cuicheng01/update_readme
github/fork/danleifeng/dygraph_fleet_dev
github/fork/edencfc/develop
github/fork/edencfc/patch-1
github/fork/frankwhzhang/delerec
github/fork/frankwhzhang/fix_bug
github/fork/frankwhzhang/update_16
github/fork/gavin1332/fleet
github/fork/gentelyang/develop
github/fork/greatyang/patch-1
github/fork/greatyang/patch-2
github/fork/guoshengCS/add-fluid-transformer-md
github/fork/guoshengCS/add-transformer-validation
github/fork/guoshengCS/cherry-pick-transformer-readme
github/fork/guoshengCS/fix-py3-transformer
github/fork/guoshengCS/paddle1.6-paddleMT
github/fork/guoshengCS/refine-transformer-align
github/fork/guru4elephant/refine_doc
github/fork/heavengate/pointrcnn_rpn_use_train_aug
github/fork/huangjun12/2.0-bmn
github/fork/jacquesqiao/add-ctr-dataset
github/fork/jacquesqiao/update-ctr-reader
github/fork/jerrywgz/add_FPN_for_fasterrcnn
github/fork/jerrywgz/fix_default_infer_path_in_RCNN
github/fork/jerrywgz/fix_resize
github/fork/ji-u/pipe_reader
github/fork/kahitomi/develop
github/fork/kangyuzhe666/develop
github/fork/kebinC/metric
github/fork/kgresearch/develop
github/fork/killf/killf_fix_bug
github/fork/kolinwei/patch-9
github/fork/lijiancheng0614/develop
github/fork/lishiyu93/release/1.7
github/fork/littletomatodonkey/develop
github/fork/lixingjian/develop
github/fork/milkfish1988/patch-2
github/fork/molly00ecla/develop
github/fork/mozpp/patch-1
github/fork/overlordmax/add_DSSM
github/fork/overlordmax/add_ESMM
github/fork/overlordmax/add_mmoe
github/fork/overlordmax/add_multi_task
github/fork/overlordmax/fix_mmoe
github/fork/overlordmax/listwise_05182140
github/fork/overlordmax/mmoe_0416
github/fork/overlordmax/mmoe_04162255
github/fork/overlordmax/mmoe_04172100
github/fork/overlordmax/mmoe_04172112
github/fork/overlordmax/mmoe_sb_0417
github/fork/overlordmax/ncf_04281221
github/fork/overlordmax/pr_04221554
github/fork/overlordmax/pr_06102355
github/fork/overlordmax/pr_5291452
github/fork/overlordmax/pr_5291503
github/fork/overlordmax/pr_5291515
github/fork/overlordmax/pr_5291527
github/fork/overlordmax/test_mmoe
github/fork/overlordmax/wide_deep_04221053
github/fork/overlordmax/wide_deep_04221148
github/fork/overlordmax/youtube_05130940
github/fork/phlrain/update_bert_new_save_load
github/fork/pkulzb/develop
github/fork/qingqing01/trt_infer
github/fork/qqraise/develop
github/fork/shippingwang/add_TALL
github/fork/shippingwang/add_TSN_SeResNeXt
github/fork/shippingwang/add_benchmark
github/fork/shippingwang/add_ce
github/fork/shippingwang/add_colortwist
github/fork/shippingwang/add_tsm_dy
github/fork/shippingwang/fix_bugs_3
github/fork/shippingwang/speedup
github/fork/shippingwang/upgrade_api_tsn
github/fork/slf12/float_to_int
github/fork/slf12/pact
github/fork/slf12/seq2seq_ocr
github/fork/sneaxiy/remove_gc_flags
github/fork/sneaxiy/remove_mem_opt_strategies
github/fork/sneaxiy/remove_paddle_reader_apis
github/fork/soldier828/develop
github/fork/songyouwei/typo-fix
github/fork/tachyon77/patch-1
github/fork/tachyon77/patch-2
github/fork/typhoonzero/add_resnext
github/fork/usafchn/hinas
github/fork/walloollaw/fix-hang-in-ppdet
github/fork/wanghaoshuang/enhence_auto_pruning
github/fork/wanghaoshuang/fix_prune_demo
github/fork/wanghaoshuang/fix_slim
github/fork/wanghaoshuang/fix_slim_demo
github/fork/wanghaoshuang/nb_slim
github/fork/wangsouc/add-deep-and-cross
github/fork/wangsouc/deepmf
github/fork/willthefrog/dali_multi_eval
github/fork/wopeizl/remove_profile
github/fork/wzzju/add_bn_fuse
github/fork/wzzju/test_dyquant
github/fork/wzzju/test_mlperf
github/fork/wzzju/test_mobilenet
github/fork/xinaiwunai/develop
github/fork/xixiaoyao/develop
github/fork/xuezhong/dureader_v2
github/fork/zhangting2020/fuse_bn_add_act
github/fork/zhengya01/HiNAS_models_ce
github/fork/zhengya01/ce1
github/fork/zhengya01/ce_dgu
github/fork/zhengya01/ce_human_pose_estimation
github/fork/zhengya01/ce_tagspace
github/fork/zhengya01/ce_transformer
github/fork/zhengya01/ce_video
github/fork/zhengya01/ce_word2vec
github/fork/zhengya01/dy_lac
github/fork/zhengya01/metric_learning_ce
github/fork/zhengya01/vc_ce
github/fork/zhiqiu/dev/resnet_amp
github/fork/zhiqiu/dev/test_addto
github/fork/zhumanyu/develop
github/fork/zjzhangd/fix_policy_gradient
github/fork/zzszmyf/develop
github/fork/zzszmyf/patch-1
godfanmiao-patch-1
godfanmiao-patch-2
godfanmiao-patch-3
grasswolfs-patch-1
imguozhen-patch-1
junjun315-patch-1
kolinwei-patch-1
lac_1
lac_2
lsq-branch
refine_reader
release/1.0
release/1.1
release/1.3
release/1.4
release/1.5
release/1.6
release/1.7
release/2.0-beta
release/2.2
release/2.3
release/2.4
revert-5689-release/2.3
revert-5695-PP-TinyPose
tipc
up_doc
update-couplet-readme
yxp1216
yxp1218
yxp1221
yxp1222
2.0.0-beta
v2.0.0-beta
v1.8.0
v1.7.0
v1.6
v1.5.1
v1.5
v1.4
v1.3
develop-align-v1.7.0
1 合并请求
!4047
add danet
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
166 addition
and
82 deletion
+166
-82
fluid/faster_rcnn/eval_coco_map.py
fluid/faster_rcnn/eval_coco_map.py
+17
-4
fluid/faster_rcnn/eval_helper.py
fluid/faster_rcnn/eval_helper.py
+14
-0
fluid/faster_rcnn/learning_rate.py
fluid/faster_rcnn/learning_rate.py
+14
-0
fluid/faster_rcnn/models/model_builder.py
fluid/faster_rcnn/models/model_builder.py
+14
-0
fluid/faster_rcnn/models/resnet.py
fluid/faster_rcnn/models/resnet.py
+14
-0
fluid/faster_rcnn/profile.py
fluid/faster_rcnn/profile.py
+68
-69
fluid/faster_rcnn/train.py
fluid/faster_rcnn/train.py
+21
-6
fluid/faster_rcnn/utility.py
fluid/faster_rcnn/utility.py
+4
-3
未找到文件。
fluid/faster_rcnn/eval_coco_map.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
time
import
numpy
as
np
import
argparse
import
functools
from
eval_helper
import
get_nmsed_box
from
eval_helper
import
get_dt_res
import
paddle
import
paddle.fluid
as
fluid
import
reader
from
utility
import
print_arguments
,
parse_args
# A special mAP metric for COCO dataset, which averages AP in different IoUs.
# To use this eval_coco_map.py, [cocoapi](https://github.com/cocodataset/cocoapi) is needed.
import
models.model_builder
as
model_builder
import
models.resnet
as
resnet
import
json
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/eval_helper.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import
os
import
numpy
as
np
import
paddle.fluid
as
fluid
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/learning_rate.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/models/model_builder.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.initializer
import
Constant
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/models/resnet.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.initializer
import
Constant
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/profile.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
import
os
import
time
import
numpy
as
np
import
argparse
import
functools
import
shutil
import
cPickle
from
utility
import
add_arguments
,
print_arguments
from
utility
import
parse_args
,
add_arguments
,
print_arguments
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -16,50 +27,12 @@ import models.model_builder as model_builder
import
models.resnet
as
resnet
from
learning_rate
import
exponential_with_warmup_decay
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
# ENV
add_arg
(
'parallel'
,
bool
,
True
,
"Minibatch size."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether use GPU."
)
add_arg
(
'model_save_dir'
,
str
,
'model'
,
"The path to save model."
)
add_arg
(
'pretrained_model'
,
str
,
'imagenet_resnet50_fusebn'
,
"The init model path."
)
add_arg
(
'dataset'
,
str
,
'coco2017'
,
"coco2014, coco2017, and pascalvoc."
)
add_arg
(
'data_dir'
,
str
,
'data/COCO17'
,
"data directory"
)
add_arg
(
'skip_reader'
,
bool
,
False
,
"Whether to skip data reader."
)
add_arg
(
'use_profile'
,
bool
,
False
,
"Whether to use profiler tool."
)
add_arg
(
'class_num'
,
int
,
81
,
"Class number."
)
add_arg
(
'use_pyreader'
,
bool
,
False
,
"Class number."
)
# SOLVER
add_arg
(
'learning_rate'
,
float
,
0.01
,
"Learning rate."
)
add_arg
(
'num_iteration'
,
int
,
10
,
"Epoch number."
)
# RPN
add_arg
(
'anchor_sizes'
,
int
,
[
32
,
64
,
128
,
256
,
512
],
"The size of anchors."
)
add_arg
(
'aspect_ratios'
,
float
,
[
0.5
,
1.0
,
2.0
],
"The ratio of anchors."
)
add_arg
(
'variance'
,
float
,
[
1.
,
1.
,
1.
,
1.
],
"The variance of anchors."
)
add_arg
(
'rpn_stride'
,
float
,
16.
,
"Stride of the feature map that RPN is attached."
)
# FAST RCNN
# TRAIN TEST
add_arg
(
'batch_size'
,
int
,
1
,
"Minibatch size."
)
add_arg
(
'max_size'
,
int
,
1333
,
"The max resized image size."
)
add_arg
(
'scales'
,
int
,
[
800
],
"The resized image height."
)
add_arg
(
'batch_size_per_im'
,
int
,
512
,
"fast rcnn head batch size"
)
add_arg
(
'mean_value'
,
float
,
[
102.9801
,
115.9465
,
122.7717
],
"pixel mean"
)
add_arg
(
'debug'
,
bool
,
False
,
"Debug mode"
)
#yapf: enable
def
train
(
cfg
):
batch_size
=
cfg
.
batch_size
learning_rate
=
cfg
.
learning_rate
image_shape
=
[
3
,
cfg
.
max_size
,
cfg
.
max_size
]
num_iterations
=
cfg
.
num_iteration
if
cfg
.
debug
:
fluid
.
default_startup_program
().
random_seed
=
1000
fluid
.
default_main_program
().
random_seed
=
1000
import
random
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
num_iterations
=
cfg
.
max_iter
devices
=
os
.
getenv
(
"CUDA_VISIBLE_DEVICES"
)
or
""
devices_num
=
len
(
devices
.
split
(
","
))
...
...
@@ -72,21 +45,22 @@ def train(cfg):
use_random
=
False
)
model
.
build_model
(
image_shape
)
loss_cls
,
loss_bbox
,
rpn_cls_loss
,
rpn_reg_loss
=
model
.
loss
()
loss_cls
.
persistable
=
True
loss_bbox
.
persistable
=
True
rpn_cls_loss
.
persistable
=
True
rpn_reg_loss
.
persistable
=
True
loss_cls
.
persistable
=
True
loss_bbox
.
persistable
=
True
rpn_cls_loss
.
persistable
=
True
rpn_reg_loss
.
persistable
=
True
loss
=
loss_cls
+
loss_bbox
+
rpn_cls_loss
+
rpn_reg_loss
boundaries
=
[
120000
,
160000
]
values
=
[
learning_rate
,
learning_rate
*
0.1
,
learning_rate
*
0.01
]
values
=
[
learning_rate
,
learning_rate
*
0.1
,
learning_rate
*
0.01
]
optimizer
=
fluid
.
optimizer
.
Momentum
(
learning_rate
=
exponential_with_warmup_decay
(
learning_rate
=
learning_rate
,
learning_rate
=
exponential_with_warmup_decay
(
learning_rate
=
learning_rate
,
boundaries
=
boundaries
,
values
=
values
,
warmup_iter
=
500
,
warmup_factor
=
1.0
/
3.0
),
warmup_factor
=
1.0
/
3.0
),
regularization
=
fluid
.
regularizer
.
L2Decay
(
0.0001
),
momentum
=
0.9
)
optimizer
.
minimize
(
loss
)
...
...
@@ -98,22 +72,33 @@ def train(cfg):
exe
.
run
(
fluid
.
default_startup_program
())
if
cfg
.
pretrained_model
:
def
if_exist
(
var
):
return
os
.
path
.
exists
(
os
.
path
.
join
(
cfg
.
pretrained_model
,
var
.
name
))
fluid
.
io
.
load_vars
(
exe
,
cfg
.
pretrained_model
,
predicate
=
if_exist
)
if
cfg
.
parallel
:
train_exe
=
fluid
.
ParallelExecutor
(
use_cuda
=
bool
(
cfg
.
use_gpu
),
loss_name
=
loss
.
name
)
assert
cfg
.
batch_size
%
devices_num
==
0
,
\
"batch_size = %d, devices_num = %d"
%
(
cfg
.
batch_size
,
devices_num
)
batch_size_per_dev
=
cfg
.
batch_size
/
devices_num
if
cfg
.
use_pyreader
:
train_reader
=
reader
.
train
(
cfg
,
batch_size
=
1
,
shuffle
=
not
cfg
.
debug
)
train_reader
=
reader
.
train
(
cfg
,
batch_size
=
batch_size_per_dev
,
total_batch_size
=
cfg
.
batch_size
,
padding_total
=
cfg
.
padding_minibatch
,
shuffle
=
False
)
py_reader
=
model
.
py_reader
py_reader
.
decorate_paddle_reader
(
train_reader
)
else
:
train_reader
=
reader
.
train
(
cfg
,
batch_size
=
cfg
.
batch_size
,
shuffle
=
not
cfg
.
debug
)
feeder
=
fluid
.
DataFeeder
(
place
=
place
,
feed_list
=
model
.
feeds
())
train_reader
=
reader
.
train
(
cfg
,
batch_size
=
cfg
.
batch_size
,
shuffle
=
False
)
feeder
=
fluid
.
DataFeeder
(
place
=
place
,
feed_list
=
model
.
feeds
())
fetch_list
=
[
loss
,
loss_cls
,
loss_bbox
,
rpn_cls_loss
,
rpn_reg_loss
]
...
...
@@ -128,18 +113,23 @@ def train(cfg):
end_time
=
time
.
time
()
reader_time
.
append
(
end_time
-
start_time
)
start_time
=
time
.
time
()
losses
=
train_exe
.
run
(
fetch_list
=
[
v
.
name
for
v
in
fetch_list
],
feed
=
feeder
.
feed
(
data
))
if
cfg
.
parallel
:
losses
=
train_exe
.
run
(
fetch_list
=
[
v
.
name
for
v
in
fetch_list
],
feed
=
feeder
.
feed
(
data
))
else
:
losses
=
exe
.
run
(
fluid
.
default_main_program
(),
fetch_list
=
[
v
.
name
for
v
in
fetch_list
],
feed
=
feeder
.
feed
(
data
))
end_time
=
time
.
time
()
run_time
.
append
(
end_time
-
start_time
)
total_images
+=
data
[
0
][
0
].
shape
[
0
]
total_images
+=
len
(
data
)
lr
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
'learning_rate'
).
get_tensor
())
print
(
"Batch {:d}, lr {:.6f}, loss {:.6f} "
.
format
(
batch_id
,
lr
[
0
],
losses
[
0
][
0
]))
lr
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
'learning_rate'
)
.
get_tensor
())
print
(
"Batch {:d}, lr {:.6f}, loss {:.6f} "
.
format
(
batch_id
,
lr
[
0
],
losses
[
0
][
0
]))
return
reader_time
,
run_time
,
total_images
def
run_pyreader
(
iterations
):
reader_time
=
[
0
]
run_time
=
[]
...
...
@@ -149,13 +139,19 @@ def train(cfg):
try
:
for
batch_id
in
range
(
iterations
):
start_time
=
time
.
time
()
losses
=
train_exe
.
run
(
fetch_list
=
[
v
.
name
for
v
in
fetch_list
])
if
cfg
.
parallel
:
losses
=
train_exe
.
run
(
fetch_list
=
[
v
.
name
for
v
in
fetch_list
])
else
:
losses
=
exe
.
run
(
fluid
.
default_main_program
(),
fetch_list
=
[
v
.
name
for
v
in
fetch_list
])
end_time
=
time
.
time
()
run_time
.
append
(
end_time
-
start_time
)
total_images
+=
devices_num
lr
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
'learning_rate'
).
get_tensor
())
print
(
"Batch {:d}, lr {:.6f}, loss {:.6f} "
.
format
(
batch_id
,
lr
[
0
],
losses
[
0
][
0
]))
lr
=
np
.
array
(
fluid
.
global_scope
().
find_var
(
'learning_rate'
)
.
get_tensor
())
print
(
"Batch {:d}, lr {:.6f}, loss {:.6f} "
.
format
(
batch_id
,
lr
[
0
],
losses
[
0
][
0
]))
except
fluid
.
core
.
EOFException
:
py_reader
.
reset
()
...
...
@@ -167,20 +163,23 @@ def train(cfg):
run_func
(
2
)
# profiling
start
=
time
.
time
()
if
cfg
.
use_profile
:
use_profile
=
False
if
use_profile
:
with
profiler
.
profiler
(
'GPU'
,
'total'
,
'/tmp/profile_file'
):
reader_time
,
run_time
,
total_images
=
run
(
num_iterations
)
reader_time
,
run_time
,
total_images
=
run
_func
(
num_iterations
)
else
:
reader_time
,
run_time
,
total_images
=
run_func
(
num_iterations
)
end
=
time
.
time
()
total_time
=
end
-
start
print
(
"Total time: {0}, reader time: {1} s, run time: {2} s, images/s: {3}"
.
format
(
total_time
,
np
.
sum
(
reader_time
),
np
.
sum
(
run_time
),
total_images
/
total_time
))
print
(
"Total time: {0}, reader time: {1} s, run time: {2} s, images/s: {3}"
.
format
(
total_time
,
np
.
sum
(
reader_time
),
np
.
sum
(
run_time
),
total_images
/
total_time
))
if
__name__
==
'__main__'
:
args
=
parse
r
.
parse
_args
()
args
=
parse_args
()
print_arguments
(
args
)
data_args
=
reader
.
Settings
(
args
)
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/train.py
浏览文件 @
579be0c1
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
time
import
sys
import
numpy
as
np
import
argparse
import
functools
import
time
import
shutil
import
cPickle
from
utility
import
parse_args
,
print_arguments
,
SmoothedValue
import
paddle
...
...
@@ -117,7 +132,7 @@ def train(cfg):
iter_id
,
lr
[
0
],
smoothed_loss
.
get_median_value
(
),
start_time
-
prev_start_time
))
#print('cls_loss ', losses[1][0], ' reg_loss ', losses[2][0], ' loss_cls ', losses[3][0], ' loss_bbox ', losses[4][0]
)
sys
.
stdout
.
flush
(
)
if
(
iter_id
+
1
)
%
cfg
.
snapshot_stride
==
0
:
save_model
(
"model_iter{}"
.
format
(
iter_id
))
except
fluid
.
core
.
EOFException
:
...
...
@@ -143,7 +158,7 @@ def train(cfg):
print
(
"Iter {:d}, lr {:.6f}, loss {:.6f}, time {:.5f}"
.
format
(
iter_id
,
lr
[
0
],
smoothed_loss
.
get_median_value
(),
start_time
-
prev_start_time
))
#print('cls_loss ', losses[1][0], ' reg_loss ', losses[2][0], ' loss_cls ', losses[3][0], ' loss_bbox ', losses[4][0]
)
sys
.
stdout
.
flush
(
)
if
(
iter_id
+
1
)
%
cfg
.
snapshot_stride
==
0
:
save_model
(
"model_iter{}"
.
format
(
iter_id
))
if
(
iter_id
+
1
)
==
cfg
.
max_iter
:
...
...
This diff is collapsed.
Click to expand it.
fluid/faster_rcnn/utility.py
浏览文件 @
579be0c1
"""Contains common utility functions."""
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve.
#
#Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -12,6 +11,9 @@
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
"""
Contains common utility functions.
"""
from
__future__
import
absolute_import
from
__future__
import
division
...
...
@@ -83,8 +85,7 @@ class SmoothedValue(object):
def
parse_args
():
"""
return all args
"""return all args
"""
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部