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
2f978f63
Commit
2f978f63
authored
Apr 21, 2021
by
Jethong
Browse files
add metric mode
parent
e2b84da8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
configs/e2e/e2e_r50_vd_pg.yml
configs/e2e/e2e_r50_vd_pg.yml
+1
-0
ppocr/data/imaug/label_ops.py
ppocr/data/imaug/label_ops.py
+22
-4
ppocr/metrics/e2e_metric.py
ppocr/metrics/e2e_metric.py
+2
-3
No files found.
configs/e2e/e2e_r50_vd_pg.yml
View file @
2f978f63
...
@@ -60,6 +60,7 @@ PostProcess:
...
@@ -60,6 +60,7 @@ PostProcess:
name
:
PGPostProcess
name
:
PGPostProcess
score_thresh
:
0.5
score_thresh
:
0.5
mode
:
fast
# fast or slow two ways
mode
:
fast
# fast or slow two ways
Metric
:
Metric
:
name
:
E2EMetric
name
:
E2EMetric
mode
:
A
# A or B
mode
:
A
# A or B
...
...
ppocr/data/imaug/label_ops.py
View file @
2f978f63
...
@@ -199,14 +199,32 @@ class E2ELabelEncode_test(BaseRecLabelEncode):
...
@@ -199,14 +199,32 @@ class E2ELabelEncode_test(BaseRecLabelEncode):
character_type
,
use_space_char
)
character_type
,
use_space_char
)
def
__call__
(
self
,
data
):
def
__call__
(
self
,
data
):
texts
=
data
[
'texts'
]
import
json
padnum
=
len
(
self
.
dict
)
label
=
data
[
'label'
]
label
=
json
.
loads
(
label
)
nBox
=
len
(
label
)
boxes
,
txts
,
txt_tags
=
[],
[],
[]
for
bno
in
range
(
0
,
nBox
):
box
=
label
[
bno
][
'points'
]
txt
=
label
[
bno
][
'transcription'
]
boxes
.
append
(
box
)
txts
.
append
(
txt
)
if
txt
in
[
'*'
,
'###'
]:
txt_tags
.
append
(
True
)
else
:
txt_tags
.
append
(
False
)
boxes
=
np
.
array
(
boxes
,
dtype
=
np
.
float32
)
txt_tags
=
np
.
array
(
txt_tags
,
dtype
=
np
.
bool
)
data
[
'polys'
]
=
boxes
data
[
'ignore_tags'
]
=
txt_tags
temp_texts
=
[]
temp_texts
=
[]
for
text
in
t
e
xts
:
for
text
in
txts
:
text
=
text
.
lower
()
text
=
text
.
lower
()
text
=
self
.
encode
(
text
)
text
=
self
.
encode
(
text
)
if
text
is
None
:
if
text
is
None
:
return
None
return
None
text
=
text
+
[
36
]
*
(
self
.
max_text_len
-
len
(
text
)
text
=
text
+
[
padnum
]
*
(
self
.
max_text_len
-
len
(
text
)
)
# use 36 to pad
)
# use 36 to pad
temp_texts
.
append
(
text
)
temp_texts
.
append
(
text
)
data
[
'texts'
]
=
np
.
array
(
temp_texts
)
data
[
'texts'
]
=
np
.
array
(
temp_texts
)
...
...
ppocr/metrics/e2e_metric.py
View file @
2f978f63
...
@@ -39,7 +39,7 @@ class E2EMetric(object):
...
@@ -39,7 +39,7 @@ class E2EMetric(object):
def
__call__
(
self
,
preds
,
batch
,
**
kwargs
):
def
__call__
(
self
,
preds
,
batch
,
**
kwargs
):
if
self
.
mode
==
'A'
:
if
self
.
mode
==
'A'
:
gt_polyons_batch
=
batch
[
2
]
gt_polyons_batch
=
batch
[
2
]
temp_gt_strs_batch
=
batch
[
3
]
temp_gt_strs_batch
=
batch
[
3
]
[
0
]
ignore_tags_batch
=
batch
[
4
]
ignore_tags_batch
=
batch
[
4
]
gt_strs_batch
=
[]
gt_strs_batch
=
[]
...
@@ -51,8 +51,7 @@ class E2EMetric(object):
...
@@ -51,8 +51,7 @@ class E2EMetric(object):
gt_strs_batch
.
append
(
t
)
gt_strs_batch
.
append
(
t
)
for
pred
,
gt_polyons
,
gt_strs
,
ignore_tags
in
zip
(
for
pred
,
gt_polyons
,
gt_strs
,
ignore_tags
in
zip
(
[
preds
],
[
gt_polyons_batch
],
[
gt_strs_batch
],
[
preds
],
gt_polyons_batch
,
[
gt_strs_batch
],
ignore_tags_batch
):
ignore_tags_batch
):
# prepare gt
# prepare gt
gt_info_list
=
[{
gt_info_list
=
[{
'points'
:
gt_polyon
,
'points'
:
gt_polyon
,
...
...
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