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
3892a8ca
"docs/source/vscode:/vscode.git/clone" did not exist on "30132aba308b83187997bd66579c34993e035f6a"
Commit
3892a8ca
authored
Jul 01, 2020
by
LDOUBLEV
Browse files
fix Nan results and add test_reader func
parent
f1f9206b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletion
+26
-1
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+2
-0
tools/infer_rec.py
tools/infer_rec.py
+2
-0
tools/train.py
tools/train.py
+22
-1
No files found.
tools/infer/predict_rec.py
View file @
3892a8ca
...
@@ -122,6 +122,8 @@ class TextRecognizer(object):
...
@@ -122,6 +122,8 @@ class TextRecognizer(object):
blank
=
probs
.
shape
[
1
]
blank
=
probs
.
shape
[
1
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
if
not
valid_ind
:
continue
# rec_res.append([preds_text, score])
# rec_res.append([preds_text, score])
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
[
preds_text
,
score
]
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
[
preds_text
,
score
]
else
:
else
:
...
...
tools/infer_rec.py
View file @
3892a8ca
...
@@ -99,6 +99,8 @@ def main():
...
@@ -99,6 +99,8 @@ def main():
ind
=
np
.
argmax
(
probs
,
axis
=
1
)
ind
=
np
.
argmax
(
probs
,
axis
=
1
)
blank
=
probs
.
shape
[
1
]
blank
=
probs
.
shape
[
1
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
if
not
valid_ind
:
continue
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
elif
loss_type
==
"attention"
:
elif
loss_type
==
"attention"
:
preds
=
np
.
array
(
predict
[
0
])
preds
=
np
.
array
(
predict
[
0
])
...
...
tools/train.py
View file @
3892a8ca
...
@@ -36,7 +36,7 @@ set_paddle_flags(
...
@@ -36,7 +36,7 @@ set_paddle_flags(
FLAGS_eager_delete_tensor_gb
=
0
,
# enable GC to save memory
FLAGS_eager_delete_tensor_gb
=
0
,
# enable GC to save memory
)
)
import
program
import
tools.program
as
program
from
paddle
import
fluid
from
paddle
import
fluid
from
ppocr.utils.utility
import
initial_logger
from
ppocr.utils.utility
import
initial_logger
logger
=
initial_logger
()
logger
=
initial_logger
()
...
@@ -106,6 +106,27 @@ def main():
...
@@ -106,6 +106,27 @@ def main():
program
.
train_eval_rec_run
(
config
,
exe
,
train_info_dict
,
eval_info_dict
)
program
.
train_eval_rec_run
(
config
,
exe
,
train_info_dict
,
eval_info_dict
)
def
test_reader
():
config
=
program
.
load_config
(
FLAGS
.
config
)
program
.
merge_config
(
FLAGS
.
opt
)
print
(
config
)
train_reader
=
reader_main
(
config
=
config
,
mode
=
"train"
)
import
time
starttime
=
time
.
time
()
count
=
0
try
:
for
data
in
train_reader
():
count
+=
1
if
count
%
1
==
0
:
batch_time
=
time
.
time
()
-
starttime
starttime
=
time
.
time
()
print
(
"reader:"
,
count
,
len
(
data
),
batch_time
)
except
Exception
as
e
:
print
(
e
)
print
(
"finish reader:"
,
count
)
print
(
"success"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
program
.
ArgsParser
()
parser
=
program
.
ArgsParser
()
FLAGS
=
parser
.
parse_args
()
FLAGS
=
parser
.
parse_args
()
...
...
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