Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
b7e4528d
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1525
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b7e4528d
编写于
1月 19, 2021
作者:
D
Double_V
提交者:
GitHub
1月 19, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1763 from WenmuZhou/dygraph_rc
fix typo error and tps alignment
上级
0da98724
f17b96b9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
19 deletion
+33
-19
doc/doc_ch/add_new_algorithm.md
doc/doc_ch/add_new_algorithm.md
+2
-2
doc/doc_en/add_new_algorithm_en.md
doc/doc_en/add_new_algorithm_en.md
+2
-2
ppocr/modeling/transforms/tps.py
ppocr/modeling/transforms/tps.py
+29
-15
未找到文件。
doc/doc_ch/add_new_algorithm.md
浏览文件 @
b7e4528d
...
...
@@ -95,7 +95,7 @@ class MyBackbone(nn.Layer):
self
.
conv
=
nn
.
xxxx
def
forward
(
self
,
inputs
):
# your ne
c
work forward
# your ne
t
work forward
y
=
self
.
conv
(
inputs
)
return
y
```
...
...
@@ -300,4 +300,4 @@ Optimizer:
regularizer
:
name
:
'
L2'
factor
:
0
```
\ No newline at end of file
```
doc/doc_en/add_new_algorithm_en.md
浏览文件 @
b7e4528d
...
...
@@ -96,7 +96,7 @@ class MyBackbone(nn.Layer):
self
.
conv
=
nn
.
xxxx
def
forward
(
self
,
inputs
):
# your ne
c
work forward
# your ne
t
work forward
y
=
self
.
conv
(
inputs
)
return
y
```
...
...
@@ -301,4 +301,4 @@ Optimizer:
regularizer
:
name
:
'
L2'
factor
:
0
```
\ No newline at end of file
```
ppocr/modeling/transforms/tps.py
浏览文件 @
b7e4528d
...
...
@@ -203,9 +203,9 @@ class GridGenerator(nn.Layer):
def
build_C_paddle
(
self
):
""" Return coordinates of fiducial points in I_r; C """
F
=
self
.
F
ctrl_pts_x
=
paddle
.
linspace
(
-
1.0
,
1.0
,
int
(
F
/
2
))
ctrl_pts_y_top
=
-
1
*
paddle
.
ones
([
int
(
F
/
2
)])
ctrl_pts_y_bottom
=
paddle
.
ones
([
int
(
F
/
2
)])
ctrl_pts_x
=
paddle
.
linspace
(
-
1.0
,
1.0
,
int
(
F
/
2
)
,
dtype
=
'float64'
)
ctrl_pts_y_top
=
-
1
*
paddle
.
ones
([
int
(
F
/
2
)]
,
dtype
=
'float64'
)
ctrl_pts_y_bottom
=
paddle
.
ones
([
int
(
F
/
2
)]
,
dtype
=
'float64'
)
ctrl_pts_top
=
paddle
.
stack
([
ctrl_pts_x
,
ctrl_pts_y_top
],
axis
=
1
)
ctrl_pts_bottom
=
paddle
.
stack
([
ctrl_pts_x
,
ctrl_pts_y_bottom
],
axis
=
1
)
C
=
paddle
.
concat
([
ctrl_pts_top
,
ctrl_pts_bottom
],
axis
=
0
)
...
...
@@ -213,12 +213,16 @@ class GridGenerator(nn.Layer):
def
build_P_paddle
(
self
,
I_r_size
):
I_r_height
,
I_r_width
=
I_r_size
I_r_grid_x
=
(
paddle
.
arange
(
-
I_r_width
,
I_r_width
,
2
).
astype
(
'float32'
)
+
1.0
)
/
I_r_width
# self.I_r_width
I_r_grid_y
=
(
paddle
.
arange
(
-
I_r_height
,
I_r_height
,
2
).
astype
(
'float32'
)
+
1.0
)
/
I_r_height
# self.I_r_height
I_r_grid_x
=
paddle
.
divide
(
paddle
.
arange
(
-
I_r_width
,
I_r_width
,
2
,
dtype
=
'float64'
)
+
1.0
,
paddle
.
to_tensor
(
I_r_width
,
dtype
=
'float64'
))
I_r_grid_y
=
paddle
.
divide
(
paddle
.
arange
(
-
I_r_height
,
I_r_height
,
2
,
dtype
=
'float64'
)
+
1.0
,
paddle
.
to_tensor
(
I_r_height
,
dtype
=
'float64'
))
# self.I_r_height
# P: self.I_r_width x self.I_r_height x 2
P
=
paddle
.
stack
(
paddle
.
meshgrid
(
I_r_grid_x
,
I_r_grid_y
),
axis
=
2
)
P
=
paddle
.
transpose
(
P
,
perm
=
[
1
,
0
,
2
])
...
...
@@ -228,7 +232,7 @@ class GridGenerator(nn.Layer):
def
build_inv_delta_C_paddle
(
self
,
C
):
""" Return inv_delta_C which is needed to calculate T """
F
=
self
.
F
hat_C
=
paddle
.
zeros
((
F
,
F
),
dtype
=
'float
32
'
)
# F x F
hat_C
=
paddle
.
zeros
((
F
,
F
),
dtype
=
'float
64
'
)
# F x F
for
i
in
range
(
0
,
F
):
for
j
in
range
(
i
,
F
):
if
i
==
j
:
...
...
@@ -241,13 +245,21 @@ class GridGenerator(nn.Layer):
delta_C
=
paddle
.
concat
(
# F+3 x F+3
[
paddle
.
concat
(
[
paddle
.
ones
((
F
,
1
)),
C
,
hat_C
],
axis
=
1
),
# F x F+3
[
paddle
.
ones
(
(
F
,
1
),
dtype
=
'float64'
),
C
,
hat_C
],
axis
=
1
),
# F x F+3
paddle
.
concat
(
[
paddle
.
zeros
((
2
,
3
)),
paddle
.
transpose
(
C
,
perm
=
[
1
,
0
])],
[
paddle
.
zeros
(
(
2
,
3
),
dtype
=
'float64'
),
paddle
.
transpose
(
C
,
perm
=
[
1
,
0
])
],
axis
=
1
),
# 2 x F+3
paddle
.
concat
(
[
paddle
.
zeros
((
1
,
3
)),
paddle
.
ones
((
1
,
F
))],
[
paddle
.
zeros
(
(
1
,
3
),
dtype
=
'float64'
),
paddle
.
ones
(
(
1
,
F
),
dtype
=
'float64'
)
],
axis
=
1
)
# 1 x F+3
],
axis
=
0
)
...
...
@@ -268,7 +280,9 @@ class GridGenerator(nn.Layer):
# rbf: n x F
rbf
=
paddle
.
multiply
(
paddle
.
square
(
rbf_norm
),
paddle
.
log
(
rbf_norm
+
eps
))
P_hat
=
paddle
.
concat
([
paddle
.
ones
((
n
,
1
)),
P
,
rbf
],
axis
=
1
)
P_hat
=
paddle
.
concat
(
[
paddle
.
ones
(
(
n
,
1
),
dtype
=
'float64'
),
P
,
rbf
],
axis
=
1
)
return
P_hat
# n x F+3
def
get_expand_tensor
(
self
,
batch_C_prime
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录