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
e458c2c7
Unverified
Commit
e458c2c7
authored
Jun 30, 2020
by
xiaoting
Committed by
GitHub
Jun 30, 2020
Browse files
Merge pull request #277 from tink2123/fix_resize_shape
fix resize shape
parents
36964d08
5fae5ffd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
ppocr/data/rec/img_tools.py
ppocr/data/rec/img_tools.py
+6
-4
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+1
-1
No files found.
ppocr/data/rec/img_tools.py
View file @
e458c2c7
...
...
@@ -97,10 +97,11 @@ def process_image(img,
max_text_length
=
None
,
tps
=
None
,
infer_mode
=
False
):
if
not
infer_mode
or
char_ops
.
character_type
==
"en"
or
tps
!=
None
:
norm_img
=
resize_norm_img
(
img
,
image_shape
)
else
:
if
infer_mode
and
char_ops
.
character_type
==
"ch"
and
not
tps
:
norm_img
=
resize_norm_img_chinese
(
img
,
image_shape
)
else
:
norm_img
=
resize_norm_img
(
img
,
image_shape
)
norm_img
=
norm_img
[
np
.
newaxis
,
:]
if
label
is
not
None
:
# char_num = char_ops.get_char_num()
...
...
@@ -109,7 +110,8 @@ def process_image(img,
logger
.
info
(
"Warning in ppocr/data/rec/img_tools.py:line106: Wrong data type."
"Excepted string with length between 1 and {}, but "
"got '{}'. Label is '{}'"
.
format
(
max_text_length
,
len
(
text
),
label
))
"got '{}'. Label is '{}'"
.
format
(
max_text_length
,
len
(
text
),
label
))
return
None
else
:
if
loss_type
==
"ctc"
:
...
...
tools/infer/predict_rec.py
View file @
e458c2c7
...
...
@@ -53,7 +53,7 @@ class TextRecognizer(object):
imgC
,
imgH
,
imgW
=
self
.
rec_image_shape
assert
imgC
==
img
.
shape
[
2
]
if
self
.
character_type
==
"ch"
:
imgW
=
int
(
math
.
ceil
(
32
*
max_wh_ratio
))
imgW
=
int
((
32
*
max_wh_ratio
))
h
,
w
=
img
.
shape
[:
2
]
ratio
=
w
/
float
(
h
)
if
math
.
ceil
(
imgH
*
ratio
)
>
imgW
:
...
...
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