Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
df4a2f6a
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
1 年多 前同步成功
通知
1533
Star
32963
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看板
提交
df4a2f6a
编写于
9月 07, 2021
作者:
A
andyjpaddle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update rec_sar_head
上级
073fad37
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
10 deletion
+10
-10
ppocr/losses/rec_sar_loss.py
ppocr/losses/rec_sar_loss.py
+1
-1
ppocr/modeling/heads/rec_sar_head.py
ppocr/modeling/heads/rec_sar_head.py
+9
-9
未找到文件。
ppocr/losses/rec_sar_loss.py
浏览文件 @
df4a2f6a
...
...
@@ -9,7 +9,7 @@ from paddle import nn
class
SARLoss
(
nn
.
Layer
):
def
__init__
(
self
,
**
kwargs
):
super
(
SARLoss
,
self
).
__init__
()
self
.
loss_func
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
(
reduction
=
"mean"
,
ignore_index
=
9
2
)
self
.
loss_func
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
(
reduction
=
"mean"
,
ignore_index
=
9
6
)
def
forward
(
self
,
predicts
,
batch
):
predict
=
predicts
[:,
:
-
1
,
:]
# ignore last index of outputs to be in same seq_len with targets
...
...
ppocr/modeling/heads/rec_sar_head.py
浏览文件 @
df4a2f6a
...
...
@@ -118,8 +118,7 @@ class BaseDecoder(nn.Layer):
class
ParallelSARDecoder
(
BaseDecoder
):
"""
Args:
num_classes (int): Output class number.
channels (list[int]): Network layer channels.
out_channels (int): Output class number.
enc_bi_rnn (bool): If True, use bidirectional RNN in encoder.
dec_bi_rnn (bool): If True, use bidirectional RNN in decoder.
dec_drop_rnn (float): Dropout of RNN layer in decoder.
...
...
@@ -137,7 +136,7 @@ class ParallelSARDecoder(BaseDecoder):
"""
def
__init__
(
self
,
num_classes
=
93
,
# 90 + unknown + start + padding
out_channels
,
# 90 + unknown + start + padding
enc_bi_rnn
=
False
,
dec_bi_rnn
=
False
,
dec_drop_rnn
=
0.0
,
...
...
@@ -148,8 +147,6 @@ class ParallelSARDecoder(BaseDecoder):
pred_dropout
=
0.1
,
max_text_length
=
30
,
mask
=
True
,
start_idx
=
91
,
padding_idx
=
92
,
# 92
pred_concat
=
True
,
**
kwargs
):
super
().
__init__
()
...
...
@@ -157,7 +154,8 @@ class ParallelSARDecoder(BaseDecoder):
self
.
num_classes
=
num_classes
self
.
enc_bi_rnn
=
enc_bi_rnn
self
.
d_k
=
d_k
self
.
start_idx
=
start_idx
self
.
start_idx
=
out_channels
-
2
self
.
padding_idx
=
out_channels
-
1
self
.
max_seq_len
=
max_text_length
self
.
mask
=
mask
self
.
pred_concat
=
pred_concat
...
...
@@ -191,7 +189,7 @@ class ParallelSARDecoder(BaseDecoder):
# Decoder input embedding
self
.
embedding
=
nn
.
Embedding
(
self
.
num_classes
,
encoder_rnn_out_size
,
padding_idx
=
padding_idx
)
self
.
num_classes
,
encoder_rnn_out_size
,
padding_idx
=
self
.
padding_idx
)
# Prediction layer
self
.
pred_dropout
=
nn
.
Dropout
(
pred_dropout
)
...
...
@@ -330,6 +328,7 @@ class ParallelSARDecoder(BaseDecoder):
class
SARHead
(
nn
.
Layer
):
def
__init__
(
self
,
out_channels
,
enc_bi_rnn
=
False
,
enc_drop_rnn
=
0.1
,
enc_gru
=
False
,
...
...
@@ -351,7 +350,8 @@ class SARHead(nn.Layer):
# decoder module
self
.
decoder
=
ParallelSARDecoder
(
enc_bi_rnn
=
enc_bi_rnn
,
out_channels
=
out_channels
,
enc_bi_rnn
=
enc_bi_rnn
,
dec_bi_rnn
=
dec_bi_rnn
,
dec_drop_rnn
=
dec_drop_rnn
,
dec_gru
=
dec_gru
,
...
...
@@ -375,4 +375,4 @@ class SARHead(nn.Layer):
# (bsz, seq_len, num_classes)
return
final_out
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录