Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
4e9d2e9c
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看板
未验证
提交
4e9d2e9c
编写于
6月 13, 2022
作者:
D
Double_V
提交者:
GitHub
6月 13, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6477 from MikoyChinese/fix-copy-paste
Fix copy_paste no texts augment.
上级
0ba0772c
de91f9a0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
1 deletion
+5
-1
ppocr/data/imaug/copy_paste.py
ppocr/data/imaug/copy_paste.py
+5
-1
未找到文件。
ppocr/data/imaug/copy_paste.py
浏览文件 @
4e9d2e9c
...
@@ -35,10 +35,12 @@ class CopyPaste(object):
...
@@ -35,10 +35,12 @@ class CopyPaste(object):
point_num
=
data
[
'polys'
].
shape
[
1
]
point_num
=
data
[
'polys'
].
shape
[
1
]
src_img
=
data
[
'image'
]
src_img
=
data
[
'image'
]
src_polys
=
data
[
'polys'
].
tolist
()
src_polys
=
data
[
'polys'
].
tolist
()
src_texts
=
data
[
'texts'
]
src_ignores
=
data
[
'ignore_tags'
].
tolist
()
src_ignores
=
data
[
'ignore_tags'
].
tolist
()
ext_data
=
data
[
'ext_data'
][
0
]
ext_data
=
data
[
'ext_data'
][
0
]
ext_image
=
ext_data
[
'image'
]
ext_image
=
ext_data
[
'image'
]
ext_polys
=
ext_data
[
'polys'
]
ext_polys
=
ext_data
[
'polys'
]
ext_texts
=
ext_data
[
'texts'
]
ext_ignores
=
ext_data
[
'ignore_tags'
]
ext_ignores
=
ext_data
[
'ignore_tags'
]
indexs
=
[
i
for
i
in
range
(
len
(
ext_ignores
))
if
not
ext_ignores
[
i
]]
indexs
=
[
i
for
i
in
range
(
len
(
ext_ignores
))
if
not
ext_ignores
[
i
]]
...
@@ -53,7 +55,7 @@ class CopyPaste(object):
...
@@ -53,7 +55,7 @@ class CopyPaste(object):
src_img
=
cv2
.
cvtColor
(
src_img
,
cv2
.
COLOR_BGR2RGB
)
src_img
=
cv2
.
cvtColor
(
src_img
,
cv2
.
COLOR_BGR2RGB
)
ext_image
=
cv2
.
cvtColor
(
ext_image
,
cv2
.
COLOR_BGR2RGB
)
ext_image
=
cv2
.
cvtColor
(
ext_image
,
cv2
.
COLOR_BGR2RGB
)
src_img
=
Image
.
fromarray
(
src_img
).
convert
(
'RGBA'
)
src_img
=
Image
.
fromarray
(
src_img
).
convert
(
'RGBA'
)
for
poly
,
tag
in
zip
(
select_polys
,
select_ignores
):
for
idx
,
poly
,
tag
in
zip
(
select_idxs
,
select_polys
,
select_ignores
):
box_img
=
get_rotate_crop_image
(
ext_image
,
poly
)
box_img
=
get_rotate_crop_image
(
ext_image
,
poly
)
src_img
,
box
=
self
.
paste_img
(
src_img
,
box_img
,
src_polys
)
src_img
,
box
=
self
.
paste_img
(
src_img
,
box_img
,
src_polys
)
...
@@ -62,6 +64,7 @@ class CopyPaste(object):
...
@@ -62,6 +64,7 @@ class CopyPaste(object):
for
_
in
range
(
len
(
box
),
point_num
):
for
_
in
range
(
len
(
box
),
point_num
):
box
.
append
(
box
[
-
1
])
box
.
append
(
box
[
-
1
])
src_polys
.
append
(
box
)
src_polys
.
append
(
box
)
src_texts
.
append
(
ext_texts
[
idx
])
src_ignores
.
append
(
tag
)
src_ignores
.
append
(
tag
)
src_img
=
cv2
.
cvtColor
(
np
.
array
(
src_img
),
cv2
.
COLOR_RGB2BGR
)
src_img
=
cv2
.
cvtColor
(
np
.
array
(
src_img
),
cv2
.
COLOR_RGB2BGR
)
h
,
w
=
src_img
.
shape
[:
2
]
h
,
w
=
src_img
.
shape
[:
2
]
...
@@ -70,6 +73,7 @@ class CopyPaste(object):
...
@@ -70,6 +73,7 @@ class CopyPaste(object):
src_polys
[:,
:,
1
]
=
np
.
clip
(
src_polys
[:,
:,
1
],
0
,
h
)
src_polys
[:,
:,
1
]
=
np
.
clip
(
src_polys
[:,
:,
1
],
0
,
h
)
data
[
'image'
]
=
src_img
data
[
'image'
]
=
src_img
data
[
'polys'
]
=
src_polys
data
[
'polys'
]
=
src_polys
data
[
'texts'
]
=
src_texts
data
[
'ignore_tags'
]
=
np
.
array
(
src_ignores
)
data
[
'ignore_tags'
]
=
np
.
array
(
src_ignores
)
return
data
return
data
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录