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
316a17b0
"...git@developer.sourcefind.cn:chenpangpang/diffusers.git" did not exist on "a7ca03aa85f94574f06576d2155b3ec061fe8d63"
Commit
316a17b0
authored
Jun 08, 2021
by
WenmuZhou
Browse files
del pad
parent
0ee6137d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
ppocr/postprocess/db_postprocess.py
ppocr/postprocess/db_postprocess.py
+5
-5
No files found.
ppocr/postprocess/db_postprocess.py
View file @
316a17b0
...
@@ -49,12 +49,11 @@ class DBPostProcess(object):
...
@@ -49,12 +49,11 @@ class DBPostProcess(object):
self
.
dilation_kernel
=
None
if
not
use_dilation
else
np
.
array
(
self
.
dilation_kernel
=
None
if
not
use_dilation
else
np
.
array
(
[[
1
,
1
],
[
1
,
1
]])
[[
1
,
1
],
[
1
,
1
]])
def
boxes_from_bitmap
(
self
,
pred
,
_bitmap
,
shape
):
def
boxes_from_bitmap
(
self
,
pred
,
_bitmap
,
dest_width
,
dest_height
):
'''
'''
_bitmap: single map with shape (1, H, W),
_bitmap: single map with shape (1, H, W),
whose values are binarized as {0, 1}
whose values are binarized as {0, 1}
'''
'''
dest_height
,
dest_width
,
ratio_h
,
ratio_w
=
shape
bitmap
=
_bitmap
bitmap
=
_bitmap
height
,
width
=
bitmap
.
shape
height
,
width
=
bitmap
.
shape
...
@@ -89,9 +88,9 @@ class DBPostProcess(object):
...
@@ -89,9 +88,9 @@ class DBPostProcess(object):
box
=
np
.
array
(
box
)
box
=
np
.
array
(
box
)
box
[:,
0
]
=
np
.
clip
(
box
[:,
0
]
=
np
.
clip
(
np
.
round
(
box
[:,
0
]
/
ratio_w
),
0
,
dest_width
)
np
.
round
(
box
[:,
0
]
/
width
*
dest_width
),
0
,
dest_width
)
box
[:,
1
]
=
np
.
clip
(
box
[:,
1
]
=
np
.
clip
(
np
.
round
(
box
[:,
1
]
/
ratio_h
),
0
,
dest_height
)
np
.
round
(
box
[:,
1
]
/
height
*
dest_height
),
0
,
dest_height
)
boxes
.
append
(
box
.
astype
(
np
.
int16
))
boxes
.
append
(
box
.
astype
(
np
.
int16
))
scores
.
append
(
score
)
scores
.
append
(
score
)
return
np
.
array
(
boxes
,
dtype
=
np
.
int16
),
scores
return
np
.
array
(
boxes
,
dtype
=
np
.
int16
),
scores
...
@@ -175,6 +174,7 @@ class DBPostProcess(object):
...
@@ -175,6 +174,7 @@ class DBPostProcess(object):
boxes_batch
=
[]
boxes_batch
=
[]
for
batch_index
in
range
(
pred
.
shape
[
0
]):
for
batch_index
in
range
(
pred
.
shape
[
0
]):
src_h
,
src_w
,
ratio_h
,
ratio_w
=
shape_list
[
batch_index
]
if
self
.
dilation_kernel
is
not
None
:
if
self
.
dilation_kernel
is
not
None
:
mask
=
cv2
.
dilate
(
mask
=
cv2
.
dilate
(
np
.
array
(
segmentation
[
batch_index
]).
astype
(
np
.
uint8
),
np
.
array
(
segmentation
[
batch_index
]).
astype
(
np
.
uint8
),
...
@@ -182,7 +182,7 @@ class DBPostProcess(object):
...
@@ -182,7 +182,7 @@ class DBPostProcess(object):
else
:
else
:
mask
=
segmentation
[
batch_index
]
mask
=
segmentation
[
batch_index
]
boxes
,
scores
=
self
.
boxes_from_bitmap
(
pred
[
batch_index
],
mask
,
boxes
,
scores
=
self
.
boxes_from_bitmap
(
pred
[
batch_index
],
mask
,
s
hape_list
[
batch_index
]
)
s
rc_w
,
src_h
)
boxes_batch
.
append
({
'points'
:
boxes
})
boxes_batch
.
append
({
'points'
:
boxes
})
return
boxes_batch
return
boxes_batch
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