Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
082e7385
P
PaddleOCR
项目概览
s920243400
/
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看板
提交
082e7385
编写于
10月 28, 2020
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add code comment
上级
90734ca6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
1 deletion
+40
-1
ppocr/data/det/db_process.py
ppocr/data/det/db_process.py
+40
-1
未找到文件。
ppocr/data/det/db_process.py
浏览文件 @
082e7385
...
...
@@ -28,14 +28,22 @@ from .make_border_map import MakeBorderMap
class
DBProcessTrain
(
object
):
"""
DB pre-process for T
rain mode
The pre-process of DB for t
rain mode
"""
def
__init__
(
self
,
params
):
"""
:param params: dict of params
"""
self
.
img_set_dir
=
params
[
'img_set_dir'
]
self
.
image_shape
=
params
[
'image_shape'
]
def
order_points_clockwise
(
self
,
pts
):
"""
Sort the points in the box clockwise
:param pts: points with shape [4, 2]
:return: sorted points
"""
rect
=
np
.
zeros
((
4
,
2
),
dtype
=
"float32"
)
s
=
pts
.
sum
(
axis
=
1
)
rect
[
0
]
=
pts
[
np
.
argmin
(
s
)]
...
...
@@ -46,6 +54,12 @@ class DBProcessTrain(object):
return
rect
def
make_data_dict
(
self
,
imgvalue
,
entry
):
"""
create input dict
:param imgvalue: input image
:param entry: dict of annotations information
:return: created dict of input data information
"""
boxes
=
[]
texts
=
[]
ignores
=
[]
...
...
@@ -71,6 +85,11 @@ class DBProcessTrain(object):
return
data
def
NormalizeImage
(
self
,
data
):
"""
Normalize input image
:param data: input dict
:return: new dict with normalized image
"""
im
=
data
[
'image'
]
img_mean
=
[
0.485
,
0.456
,
0.406
]
img_std
=
[
0.229
,
0.224
,
0.225
]
...
...
@@ -84,6 +103,11 @@ class DBProcessTrain(object):
return
data
def
FilterKeys
(
self
,
data
):
"""
Filter keys
:param data: dict
:return:
"""
filter_keys
=
[
'polys'
,
'texts'
,
'ignore_tags'
,
'shape'
]
for
key
in
filter_keys
:
if
key
in
data
:
...
...
@@ -91,6 +115,11 @@ class DBProcessTrain(object):
return
data
def
convert_label_infor
(
self
,
label_infor
):
"""
encode annotations using json.loads
:param label_infor: string
:return: (image, encoded annotations)
"""
label_infor
=
label_infor
.
decode
()
label_infor
=
label_infor
.
encode
(
'utf-8'
).
decode
(
'utf-8-sig'
)
substr
=
label_infor
.
strip
(
"
\n
"
).
split
(
"
\t
"
)
...
...
@@ -184,6 +213,11 @@ class DBProcessTest(object):
return
im
,
(
ratio_h
,
ratio_w
)
def
resize_image_type1
(
self
,
im
):
"""
resize image to a size self.image_shape
:param im: input image
:return: normalized image and resize ratio
"""
resize_h
,
resize_w
=
self
.
image_shape
ori_h
,
ori_w
=
im
.
shape
[:
2
]
# (h, w, c)
im
=
cv2
.
resize
(
im
,
(
int
(
resize_w
),
int
(
resize_h
)))
...
...
@@ -192,6 +226,11 @@ class DBProcessTest(object):
return
im
,
(
ratio_h
,
ratio_w
)
def
normalize
(
self
,
im
):
"""
Normalize image
:param im: input image
:return: Normalized image
"""
img_mean
=
[
0.485
,
0.456
,
0.406
]
img_std
=
[
0.229
,
0.224
,
0.225
]
im
=
im
.
astype
(
np
.
float32
,
copy
=
False
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录