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
e7d981b6
"vscode:/vscode.git/clone" did not exist on "3ce905c9d0e926cafdc92cae2521d413be12ce49"
Commit
e7d981b6
authored
Aug 31, 2021
by
LDOUBLEV
Browse files
add resize class and lock seed
parent
f262e33e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
6 deletions
+36
-6
configs/det/det_mv3_db.yml
configs/det/det_mv3_db.yml
+6
-4
ppocr/data/imaug/operators.py
ppocr/data/imaug/operators.py
+30
-2
No files found.
configs/det/det_mv3_db.yml
View file @
e7d981b6
...
@@ -76,10 +76,12 @@ Train:
...
@@ -76,10 +76,12 @@ Train:
-
{
'
type'
:
Fliplr
,
'
args'
:
{
'
p'
:
0.5
}
}
-
{
'
type'
:
Fliplr
,
'
args'
:
{
'
p'
:
0.5
}
}
-
{
'
type'
:
Affine
,
'
args'
:
{
'
rotate'
:
[
-10
,
10
]
}
}
-
{
'
type'
:
Affine
,
'
args'
:
{
'
rotate'
:
[
-10
,
10
]
}
}
-
{
'
type'
:
Resize
,
'
args'
:
{
'
size'
:
[
0.5
,
3
]
}
}
-
{
'
type'
:
Resize
,
'
args'
:
{
'
size'
:
[
0.5
,
3
]
}
}
-
EastRandomCropData
:
-
Resize
:
size
:
[
640
,
640
]
size
:
[
640
,
640
]
max_tries
:
50
# - EastRandomCropData:
keep_ratio
:
true
# size: [640, 640]
# max_tries: 50
# keep_ratio: true
-
MakeBorderMap
:
-
MakeBorderMap
:
shrink_ratio
:
0.4
shrink_ratio
:
0.4
thresh_min
:
0.3
thresh_min
:
0.3
...
@@ -128,4 +130,4 @@ Eval:
...
@@ -128,4 +130,4 @@ Eval:
drop_last
:
False
drop_last
:
False
batch_size_per_card
:
1
# must be 1
batch_size_per_card
:
1
# must be 1
num_workers
:
8
num_workers
:
8
use_shared_memory
:
False
use_shared_memory
:
False
\ No newline at end of file
ppocr/data/imaug/operators.py
View file @
e7d981b6
...
@@ -81,7 +81,7 @@ class NormalizeImage(object):
...
@@ -81,7 +81,7 @@ class NormalizeImage(object):
assert
isinstance
(
img
,
assert
isinstance
(
img
,
np
.
ndarray
),
"invalid input 'img' in NormalizeImage"
np
.
ndarray
),
"invalid input 'img' in NormalizeImage"
data
[
'image'
]
=
(
data
[
'image'
]
=
(
img
.
astype
(
'float32'
)
*
self
.
scale
-
self
.
mean
)
/
self
.
std
img
.
astype
(
'float32'
)
*
self
.
scale
-
self
.
mean
)
/
self
.
std
return
data
return
data
...
@@ -112,6 +112,34 @@ class KeepKeys(object):
...
@@ -112,6 +112,34 @@ class KeepKeys(object):
return
data_list
return
data_list
class
Resize
(
object
):
def
__init__
(
self
,
size
=
(
640
,
640
),
**
kwargs
):
self
.
size
=
size
def
resize_image
(
self
,
img
):
resize_h
,
resize_w
=
self
.
size
ori_h
,
ori_w
=
img
.
shape
[:
2
]
# (h, w, c)
ratio_h
=
float
(
resize_h
)
/
ori_h
ratio_w
=
float
(
resize_w
)
/
ori_w
img
=
cv2
.
resize
(
img
,
(
int
(
resize_w
),
int
(
resize_h
)))
return
img
,
[
ratio_h
,
ratio_w
]
def
__call__
(
self
,
data
):
img
=
data
[
'image'
]
text_polys
=
data
[
'polys'
]
img_resize
,
[
ratio_h
,
ratio_w
]
=
self
.
resize_image
(
img
)
new_boxes
=
[]
for
box
in
text_polys
:
new_box
=
[]
for
cord
in
box
:
new_box
.
append
([
cord
[
0
]
*
ratio_w
,
cord
[
1
]
*
ratio_h
])
new_boxes
.
append
(
new_box
)
data
[
'image'
]
=
img_resize
data
[
'polys'
]
=
np
.
array
(
new_boxes
,
dtype
=
np
.
float32
)
return
data
class
DetResizeForTest
(
object
):
class
DetResizeForTest
(
object
):
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
super
(
DetResizeForTest
,
self
).
__init__
()
super
(
DetResizeForTest
,
self
).
__init__
()
...
@@ -183,7 +211,7 @@ class DetResizeForTest(object):
...
@@ -183,7 +211,7 @@ class DetResizeForTest(object):
else
:
else
:
ratio
=
1.
ratio
=
1.
elif
self
.
limit_type
==
'resize_long'
:
elif
self
.
limit_type
==
'resize_long'
:
ratio
=
float
(
limit_side_len
)
/
max
(
h
,
w
)
ratio
=
float
(
limit_side_len
)
/
max
(
h
,
w
)
else
:
else
:
raise
Exception
(
'not support limit type, image '
)
raise
Exception
(
'not support limit type, image '
)
resize_h
=
int
(
h
*
ratio
)
resize_h
=
int
(
h
*
ratio
)
...
...
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