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
4cea42d5
"...slim/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "89cab814d79a40a1d312e6a3bc4718ec7dc9c7b2"
Commit
4cea42d5
authored
Jan 27, 2022
by
zhiminzhang0830
Browse files
add ignore_orientation
parent
9f62b610
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
ppocr/data/imaug/operators.py
ppocr/data/imaug/operators.py
+13
-13
No files found.
ppocr/data/imaug/operators.py
View file @
4cea42d5
...
...
@@ -28,9 +28,14 @@ import numpy as np
class
DecodeImage
(
object
):
""" decode image """
def
__init__
(
self
,
img_mode
=
'RGB'
,
channel_first
=
False
,
**
kwargs
):
def
__init__
(
self
,
img_mode
=
'RGB'
,
channel_first
=
False
,
ignore_orientation
=
False
,
**
kwargs
):
self
.
img_mode
=
img_mode
self
.
channel_first
=
channel_first
self
.
ignore_orientation
=
ignore_orientation
def
__call__
(
self
,
data
):
img
=
data
[
'image'
]
...
...
@@ -41,7 +46,11 @@ class DecodeImage(object):
assert
type
(
img
)
is
bytes
and
len
(
img
)
>
0
,
"invalid input 'img' in DecodeImage"
img
=
np
.
frombuffer
(
img
,
dtype
=
'uint8'
)
img
=
cv2
.
imdecode
(
img
,
1
)
if
self
.
ignore_orientation
:
img
=
cv2
.
imdecode
(
img
,
cv2
.
IMREAD_IGNORE_ORIENTATION
|
cv2
.
IMREAD_COLOR
)
else
:
img
=
cv2
.
imdecode
(
img
,
1
)
if
img
is
None
:
return
None
if
self
.
img_mode
==
'GRAY'
:
...
...
@@ -60,14 +69,9 @@ class DecodeImage(object):
class
NRTRDecodeImage
(
object
):
""" decode image """
def
__init__
(
self
,
img_mode
=
'RGB'
,
channel_first
=
False
,
ignore_orientation
=
False
,
**
kwargs
):
def
__init__
(
self
,
img_mode
=
'RGB'
,
channel_first
=
False
,
**
kwargs
):
self
.
img_mode
=
img_mode
self
.
channel_first
=
channel_first
self
.
ignore_orientation
=
ignore_orientation
def
__call__
(
self
,
data
):
img
=
data
[
'image'
]
...
...
@@ -79,11 +83,7 @@ class NRTRDecodeImage(object):
img
)
>
0
,
"invalid input 'img' in DecodeImage"
img
=
np
.
frombuffer
(
img
,
dtype
=
'uint8'
)
if
self
.
ignore_orientation
:
img
=
cv2
.
imdecode
(
img
,
cv2
.
IMREAD_IGNORE_ORIENTATION
|
cv2
.
IMREAD_COLOR
)
else
:
img
=
cv2
.
imdecode
(
img
,
1
)
img
=
cv2
.
imdecode
(
img
,
1
)
if
img
is
None
:
return
None
...
...
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