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
6f0e14a5
Commit
6f0e14a5
authored
Feb 14, 2022
by
zhiminzhang0830
Browse files
modify Pad
parent
853ebd9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
ppocr/data/imaug/operators.py
ppocr/data/imaug/operators.py
+22
-5
No files found.
ppocr/data/imaug/operators.py
View file @
6f0e14a5
...
@@ -167,20 +167,37 @@ class KeepKeys(object):
...
@@ -167,20 +167,37 @@ class KeepKeys(object):
class
Pad
(
object
):
class
Pad
(
object
):
def
__init__
(
self
,
size_div
=
32
,
**
kwargs
):
def
__init__
(
self
,
size
=
None
,
size_div
=
32
,
**
kwargs
):
if
size
is
not
None
and
not
isinstance
(
size
,
(
int
,
list
,
tuple
)):
raise
TypeError
(
"Type of target_size is invalid. Now is {}"
.
format
(
type
(
size
)))
if
isinstance
(
size
,
int
):
size
=
[
size
,
size
]
self
.
size
=
size
self
.
size_div
=
size_div
self
.
size_div
=
size_div
def
__call__
(
self
,
data
):
def
__call__
(
self
,
data
):
img
=
data
[
'image'
]
img
=
data
[
'image'
]
resize_h2
=
max
(
int
(
math
.
ceil
(
img
.
shape
[
0
]
/
32
)
*
32
),
32
)
img_h
,
img_w
=
img
.
shape
[
0
],
img
.
shape
[
1
]
resize_w2
=
max
(
int
(
math
.
ceil
(
img
.
shape
[
1
]
/
32
)
*
32
),
32
)
if
self
.
size
:
resize_h2
,
resize_w2
=
self
.
size
assert
(
img_h
<
resize_h2
and
img_w
<
resize_w2
),
'(h, w) of target size should be greater than (img_h, img_w)'
else
:
resize_h2
=
max
(
int
(
math
.
ceil
(
img
.
shape
[
0
]
/
self
.
size_div
)
*
self
.
size_div
),
self
.
size_div
)
resize_w2
=
max
(
int
(
math
.
ceil
(
img
.
shape
[
1
]
/
self
.
size_div
)
*
self
.
size_div
),
self
.
size_div
)
img
=
cv2
.
copyMakeBorder
(
img
=
cv2
.
copyMakeBorder
(
img
,
img
,
0
,
0
,
resize_h2
-
img
.
shape
[
0
]
,
resize_h2
-
img
_h
,
0
,
0
,
resize_w2
-
img
.
shape
[
1
]
,
resize_w2
-
img
_w
,
cv2
.
BORDER_CONSTANT
,
cv2
.
BORDER_CONSTANT
,
value
=
0
)
value
=
0
)
data
[
'image'
]
=
img
data
[
'image'
]
=
img
...
...
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