Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
b4c5dac2
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b4c5dac2
编写于
6月 03, 2020
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit for tmp
上级
24757ba6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
4 deletion
+40
-4
configs/rec/rec_mv3_none_bilstm_ctc.yml
configs/rec/rec_mv3_none_bilstm_ctc.yml
+2
-1
ppocr/data/rec/dataset_traversal.py
ppocr/data/rec/dataset_traversal.py
+8
-2
ppocr/data/rec/img_tools.py
ppocr/data/rec/img_tools.py
+30
-1
未找到文件。
configs/rec/rec_mv3_none_bilstm_ctc.yml
浏览文件 @
b4c5dac2
Global
:
Global
:
algorithm
:
CRNN
algorithm
:
CRNN
use_gpu
:
fals
e
use_gpu
:
tru
e
epoch_num
:
72
epoch_num
:
72
log_smooth_window
:
20
log_smooth_window
:
20
print_batch_step
:
10
print_batch_step
:
10
...
@@ -17,6 +17,7 @@ Global:
...
@@ -17,6 +17,7 @@ Global:
pretrain_weights
:
./output/rec_CRNN/rec_mv3_none_bilstm_ctc/best_accuracy
pretrain_weights
:
./output/rec_CRNN/rec_mv3_none_bilstm_ctc/best_accuracy
checkpoints
:
checkpoints
:
save_inference_dir
:
save_inference_dir
:
infer_img
:
Architecture
:
Architecture
:
function
:
ppocr.modeling.architectures.rec_model,RecModel
function
:
ppocr.modeling.architectures.rec_model,RecModel
...
...
ppocr/data/rec/dataset_traversal.py
浏览文件 @
b4c5dac2
...
@@ -105,7 +105,10 @@ class LMDBReader(object):
...
@@ -105,7 +105,10 @@ class LMDBReader(object):
img
=
cv2
.
imread
(
single_img
)
img
=
cv2
.
imread
(
single_img
)
if
img
.
shape
[
-
1
]
==
1
or
len
(
list
(
img
.
shape
))
==
2
:
if
img
.
shape
[
-
1
]
==
1
or
len
(
list
(
img
.
shape
))
==
2
:
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_GRAY2BGR
)
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_GRAY2BGR
)
norm_img
=
process_image
(
img
,
self
.
image_shape
)
norm_img
=
process_image
(
img
=
img
,
image_shape
=
self
.
image_shape
,
char_ops
=
self
.
char_ops
)
yield
norm_img
yield
norm_img
else
:
else
:
lmdb_sets
=
self
.
load_hierarchical_lmdb_dataset
()
lmdb_sets
=
self
.
load_hierarchical_lmdb_dataset
()
...
@@ -182,7 +185,10 @@ class SimpleReader(object):
...
@@ -182,7 +185,10 @@ class SimpleReader(object):
img
=
cv2
.
imread
(
single_img
)
img
=
cv2
.
imread
(
single_img
)
if
img
.
shape
[
-
1
]
==
1
or
len
(
list
(
img
.
shape
))
==
2
:
if
img
.
shape
[
-
1
]
==
1
or
len
(
list
(
img
.
shape
))
==
2
:
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_GRAY2BGR
)
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_GRAY2BGR
)
norm_img
=
process_image
(
img
,
self
.
image_shape
)
norm_img
=
process_image
(
img
=
img
,
image_shape
=
self
.
image_shape
,
char_ops
=
self
.
char_ops
)
yield
norm_img
yield
norm_img
else
:
else
:
with
open
(
self
.
label_file_path
,
"rb"
)
as
fin
:
with
open
(
self
.
label_file_path
,
"rb"
)
as
fin
:
...
...
ppocr/data/rec/img_tools.py
浏览文件 @
b4c5dac2
...
@@ -48,6 +48,32 @@ def resize_norm_img(img, image_shape):
...
@@ -48,6 +48,32 @@ def resize_norm_img(img, image_shape):
return
padding_im
return
padding_im
def
resize_norm_img_chinese
(
img
,
image_shape
):
imgC
,
imgH
,
imgW
=
image_shape
# todo: change to 0 and modified image shape
max_wh_ratio
=
10
h
,
w
=
img
.
shape
[
0
],
img
.
shape
[
1
]
ratio
=
w
*
1.0
/
h
max_wh_ratio
=
max
(
max_wh_ratio
,
ratio
)
imgW
=
int
(
32
*
max_wh_ratio
)
if
math
.
ceil
(
imgH
*
ratio
)
>
imgW
:
resized_w
=
imgW
else
:
resized_w
=
int
(
math
.
ceil
(
imgH
*
ratio
))
resized_image
=
cv2
.
resize
(
img
,
(
resized_w
,
imgH
))
resized_image
=
resized_image
.
astype
(
'float32'
)
if
image_shape
[
0
]
==
1
:
resized_image
=
resized_image
/
255
resized_image
=
resized_image
[
np
.
newaxis
,
:]
else
:
resized_image
=
resized_image
.
transpose
((
2
,
0
,
1
))
/
255
resized_image
-=
0.5
resized_image
/=
0.5
padding_im
=
np
.
zeros
((
imgC
,
imgH
,
imgW
),
dtype
=
np
.
float32
)
padding_im
[:,
:,
0
:
resized_w
]
=
resized_image
return
padding_im
def
get_img_data
(
value
):
def
get_img_data
(
value
):
"""get_img_data"""
"""get_img_data"""
if
not
value
:
if
not
value
:
...
@@ -67,7 +93,10 @@ def process_image(img,
...
@@ -67,7 +93,10 @@ def process_image(img,
char_ops
=
None
,
char_ops
=
None
,
loss_type
=
None
,
loss_type
=
None
,
max_text_length
=
None
):
max_text_length
=
None
):
norm_img
=
resize_norm_img
(
img
,
image_shape
)
if
char_ops
.
character_type
==
"en"
:
norm_img
=
resize_norm_img
(
img
,
image_shape
)
else
:
norm_img
=
resize_norm_img_chinese
(
img
,
image_shape
)
norm_img
=
norm_img
[
np
.
newaxis
,
:]
norm_img
=
norm_img
[
np
.
newaxis
,
:]
if
label
is
not
None
:
if
label
is
not
None
:
char_num
=
char_ops
.
get_char_num
()
char_num
=
char_ops
.
get_char_num
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录