Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
895d44bc
Unverified
Commit
895d44bc
authored
Feb 07, 2021
by
xiaoting
Committed by
GitHub
Feb 07, 2021
Browse files
Merge pull request #1971 from tink2123/fix_eval_for_srn
polish code for srn eval
parents
810cba39
ff6b193a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
tools/program.py
tools/program.py
+13
-5
No files found.
tools/program.py
View file @
895d44bc
...
...
@@ -182,6 +182,8 @@ def train(config,
model_average
=
False
model
.
train
()
use_srn
=
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
if
'start_epoch'
in
best_model_dict
:
start_epoch
=
best_model_dict
[
'start_epoch'
]
else
:
...
...
@@ -200,7 +202,7 @@ def train(config,
break
lr
=
optimizer
.
get_lr
()
images
=
batch
[
0
]
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
if
use_srn
:
others
=
batch
[
-
4
:]
preds
=
model
(
images
,
others
)
model_average
=
True
...
...
@@ -256,8 +258,12 @@ def train(config,
min_average_window
=
10000
,
max_average_window
=
15625
)
Model_Average
.
apply
()
cur_metric
=
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
)
cur_metric
=
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
,
use_srn
=
use_srn
)
cur_metric_str
=
'cur metric, {}'
.
format
(
', '
.
join
(
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
cur_metric
.
items
()]))
logger
.
info
(
cur_metric_str
)
...
...
@@ -321,7 +327,8 @@ def train(config,
return
def
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
):
def
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
,
use_srn
=
False
):
model
.
eval
()
with
paddle
.
no_grad
():
total_frame
=
0.0
...
...
@@ -332,7 +339,8 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
break
images
=
batch
[
0
]
start
=
time
.
time
()
if
"SRN"
in
str
(
model
.
head
):
if
use_srn
:
others
=
batch
[
-
4
:]
preds
=
model
(
images
,
others
)
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment