Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
4369552e
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4369552e
编写于
8月 15, 2022
作者:
文幕地方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add in and out box_format
上级
a8efe28f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
15 deletion
+26
-15
configs/table/SLANet.yml
configs/table/SLANet.yml
+4
-2
configs/table/table_master.yml
configs/table/table_master.yml
+4
-2
ppocr/data/imaug/label_ops.py
ppocr/data/imaug/label_ops.py
+18
-11
未找到文件。
configs/table/SLANet.yml
浏览文件 @
4369552e
...
@@ -86,7 +86,8 @@ Train:
...
@@ -86,7 +86,8 @@ Train:
loc_reg_num
:
*loc_reg_num
loc_reg_num
:
*loc_reg_num
max_text_length
:
*max_text_length
max_text_length
:
*max_text_length
-
TableBoxEncode
:
-
TableBoxEncode
:
box_format
:
*box_format
in_box_format
:
*box_format
out_box_format
:
*box_format
-
ResizeTableImage
:
-
ResizeTableImage
:
max_len
:
488
max_len
:
488
-
NormalizeImage
:
-
NormalizeImage
:
...
@@ -121,7 +122,8 @@ Eval:
...
@@ -121,7 +122,8 @@ Eval:
loc_reg_num
:
*loc_reg_num
loc_reg_num
:
*loc_reg_num
max_text_length
:
*max_text_length
max_text_length
:
*max_text_length
-
TableBoxEncode
:
-
TableBoxEncode
:
box_format
:
*box_format
in_box_format
:
*box_format
out_box_format
:
*box_format
-
ResizeTableImage
:
-
ResizeTableImage
:
max_len
:
488
max_len
:
488
-
NormalizeImage
:
-
NormalizeImage
:
...
...
configs/table/table_master.yml
浏览文件 @
4369552e
...
@@ -90,7 +90,8 @@ Train:
...
@@ -90,7 +90,8 @@ Train:
-
PaddingTableImage
:
-
PaddingTableImage
:
size
:
[
480
,
480
]
size
:
[
480
,
480
]
-
TableBoxEncode
:
-
TableBoxEncode
:
box_format
:
*box_format
in_box_format
:
*box_format
out_box_format
:
*box_format
-
NormalizeImage
:
-
NormalizeImage
:
scale
:
1./255.
scale
:
1./255.
mean
:
[
0.5
,
0.5
,
0.5
]
mean
:
[
0.5
,
0.5
,
0.5
]
...
@@ -126,7 +127,8 @@ Eval:
...
@@ -126,7 +127,8 @@ Eval:
-
PaddingTableImage
:
-
PaddingTableImage
:
size
:
[
480
,
480
]
size
:
[
480
,
480
]
-
TableBoxEncode
:
-
TableBoxEncode
:
box_format
:
*box_format
in_box_format
:
*box_format
out_box_format
:
*box_format
-
NormalizeImage
:
-
NormalizeImage
:
scale
:
1./255.
scale
:
1./255.
mean
:
[
0.5
,
0.5
,
0.5
]
mean
:
[
0.5
,
0.5
,
0.5
]
...
...
ppocr/data/imaug/label_ops.py
浏览文件 @
4369552e
...
@@ -749,28 +749,35 @@ class TableMasterLabelEncode(TableLabelEncode):
...
@@ -749,28 +749,35 @@ class TableMasterLabelEncode(TableLabelEncode):
class
TableBoxEncode
(
object
):
class
TableBoxEncode
(
object
):
def
__init__
(
self
,
box_format
=
'xyxy'
,
**
kwargs
):
def
__init__
(
self
,
in_box_format
=
'xyxy'
,
out_
box_format
=
'xyxy'
,
**
kwargs
):
assert
box_format
in
[
'xywh'
,
'xyxy'
,
'xyxyxyxy'
]
assert
box_format
in
[
'xywh'
,
'xyxy'
,
'xyxyxyxy'
]
self
.
box_format
=
box_format
self
.
in_box_format
=
in_box_format
self
.
out_box_format
=
out_box_format
def
__call__
(
self
,
data
):
def
__call__
(
self
,
data
):
img_height
,
img_width
=
data
[
'image'
].
shape
[:
2
]
img_height
,
img_width
=
data
[
'image'
].
shape
[:
2
]
bboxes
=
data
[
'bboxes'
]
bboxes
=
data
[
'bboxes'
]
if
self
.
box_format
==
'xywh'
and
bboxes
.
shape
[
1
]
==
4
:
if
self
.
in_box_format
!=
self
.
out_box_format
:
bboxes
=
self
.
xyxy2xywh
(
bboxes
)
if
self
.
out_box_format
==
'xywh'
:
if
self
.
in_box_format
==
'xyxyxyxy'
:
bboxes
=
self
.
xyxyxyxy2xywh
(
bboxes
)
elif
self
.
in_box_format
==
'xyxy'
:
bboxes
=
self
.
xyxy2xywh
(
bboxes
)
bboxes
[:,
0
::
2
]
/=
img_width
bboxes
[:,
0
::
2
]
/=
img_width
bboxes
[:,
1
::
2
]
/=
img_height
bboxes
[:,
1
::
2
]
/=
img_height
data
[
'bboxes'
]
=
bboxes
data
[
'bboxes'
]
=
bboxes
return
data
return
data
def
xyxyxyxy2xywh
(
self
,
boxes
):
new_bboxes
=
np
.
zeros
([
len
(
bboxes
),
4
])
new_bboxes
[:,
0
]
=
bboxes
[:,
0
::
2
].
min
()
# x1
new_bboxes
[:,
1
]
=
bboxes
[:,
1
::
2
].
min
()
# y1
new_bboxes
[:,
2
]
=
bboxes
[:,
0
::
2
].
max
()
-
new_bboxes
[:,
0
]
# w
new_bboxes
[:,
3
]
=
bboxes
[:,
1
::
2
].
max
()
-
new_bboxes
[:,
1
]
# h
return
new_bboxes
def
xyxy2xywh
(
self
,
bboxes
):
def
xyxy2xywh
(
self
,
bboxes
):
"""
Convert coord (x1,y1,x2,y2) to (x,y,w,h).
where (x1,y1) is top-left, (x2,y2) is bottom-right.
(x,y) is bbox center and (w,h) is width and height.
:param bboxes: (x1, y1, x2, y2)
:return:
"""
new_bboxes
=
np
.
empty_like
(
bboxes
)
new_bboxes
=
np
.
empty_like
(
bboxes
)
new_bboxes
[:,
0
]
=
(
bboxes
[:,
0
]
+
bboxes
[:,
2
])
/
2
# x center
new_bboxes
[:,
0
]
=
(
bboxes
[:,
0
]
+
bboxes
[:,
2
])
/
2
# x center
new_bboxes
[:,
1
]
=
(
bboxes
[:,
1
]
+
bboxes
[:,
3
])
/
2
# y center
new_bboxes
[:,
1
]
=
(
bboxes
[:,
1
]
+
bboxes
[:,
3
])
/
2
# y center
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录