Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
1af190ed
P
PaddleOCR
项目概览
weixin_41840029
/
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看板
未验证
提交
1af190ed
编写于
10月 31, 2022
作者:
Z
zhoujun
提交者:
GitHub
10月 31, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to 0-dimensional tensor (#8165)
上级
484e4812
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
15 deletion
+17
-15
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+1
-1
test_tipc/prepare.sh
test_tipc/prepare.sh
+3
-1
test_tipc/supplementary/train.py
test_tipc/supplementary/train.py
+13
-13
未找到文件。
ppocr/postprocess/rec_postprocess.py
浏览文件 @
1af190ed
...
@@ -891,7 +891,7 @@ class VLLabelDecode(BaseRecLabelDecode):
...
@@ -891,7 +891,7 @@ class VLLabelDecode(BaseRecLabelDecode):
)
+
length
[
i
])].
topk
(
1
)[
0
][:,
0
]
)
+
length
[
i
])].
topk
(
1
)[
0
][:,
0
]
preds_prob
=
paddle
.
exp
(
preds_prob
=
paddle
.
exp
(
paddle
.
log
(
preds_prob
).
sum
()
/
(
preds_prob
.
shape
[
0
]
+
1e-6
))
paddle
.
log
(
preds_prob
).
sum
()
/
(
preds_prob
.
shape
[
0
]
+
1e-6
))
text
.
append
((
preds_text
,
preds_prob
.
numpy
()[
0
]
))
text
.
append
((
preds_text
,
float
(
preds_prob
)
))
if
label
is
None
:
if
label
is
None
:
return
text
return
text
label
=
self
.
decode
(
label
)
label
=
self
.
decode
(
label
)
...
...
test_tipc/prepare.sh
浏览文件 @
1af190ed
...
@@ -150,7 +150,9 @@ if [ ${MODE} = "lite_train_lite_infer" ];then
...
@@ -150,7 +150,9 @@ if [ ${MODE} = "lite_train_lite_infer" ];then
# pretrain lite train data
# pretrain lite train data
wget
-nc
-P
./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
--no-check-certificate
wget
-nc
-P
./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams
--no-check-certificate
wget
-nc
-P
./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar
--no-check-certificate
wget
-nc
-P
./pretrain_models/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar
--no-check-certificate
cd
./pretrain_models/
&&
tar
xf det_mv3_db_v2.0_train.tar
&&
cd
../
cd
./pretrain_models/
tar
xf det_mv3_db_v2.0_train.tar
cd
../
if
[[
${
model_name
}
=
~
"ch_PP-OCRv2_det"
]]
;
then
if
[[
${
model_name
}
=
~
"ch_PP-OCRv2_det"
]]
;
then
wget
-nc
-P
./pretrain_models/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_distill_train.tar
--no-check-certificate
wget
-nc
-P
./pretrain_models/ https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_distill_train.tar
--no-check-certificate
cd
./pretrain_models/
&&
tar
xf ch_PP-OCRv2_det_distill_train.tar
&&
cd
../
cd
./pretrain_models/
&&
tar
xf ch_PP-OCRv2_det_distill_train.tar
&&
cd
../
...
...
test_tipc/supplementary/train.py
浏览文件 @
1af190ed
...
@@ -168,22 +168,22 @@ def train(config, scaler=None):
...
@@ -168,22 +168,22 @@ def train(config, scaler=None):
if
idx
%
10
==
0
:
if
idx
%
10
==
0
:
et
=
time
.
time
()
et
=
time
.
time
()
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
+=
f
"loss:
{
avg_loss
.
numpy
()[
0
]
}
"
strs
+=
f
"loss:
{
float
(
avg_loss
)
}
"
strs
+=
f
", acc_topk1:
{
acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
acc
[
'top5'
].
numpy
()[
0
]
}
"
strs
+=
f
", acc_topk1:
{
float
(
acc
[
'top1'
])
}
, acc_top5:
{
float
(
acc
[
'top5'
])
}
"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
logger
.
info
(
strs
)
logger
.
info
(
strs
)
st
=
time
.
time
()
st
=
time
.
time
()
if
epoch
%
10
==
0
:
if
epoch
%
10
==
0
:
acc
=
eval
(
config
,
model
)
acc
=
eval
(
config
,
model
)
if
len
(
best_acc
)
<
1
or
acc
[
'top5'
].
numpy
()[
0
]
>
best_acc
[
'top5'
]:
if
len
(
best_acc
)
<
1
or
float
(
acc
[
'top5'
])
>
best_acc
[
'top5'
]:
best_acc
=
acc
best_acc
=
acc
best_acc
[
'epoch'
]
=
epoch
best_acc
[
'epoch'
]
=
epoch
is_best
=
True
is_best
=
True
else
:
else
:
is_best
=
False
is_best
=
False
logger
.
info
(
logger
.
info
(
f
"The best acc: acc_topk1:
{
best_acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
best_acc
[
'top5'
].
numpy
()[
0
]
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
f
"The best acc: acc_topk1:
{
float
(
best_acc
[
'top1'
])
}
, acc_top5:
{
float
(
best_acc
[
'top5'
])
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
)
)
save_model
(
save_model
(
model
,
model
,
...
@@ -276,22 +276,22 @@ def train_distill(config, scaler=None):
...
@@ -276,22 +276,22 @@ def train_distill(config, scaler=None):
if
idx
%
10
==
0
:
if
idx
%
10
==
0
:
et
=
time
.
time
()
et
=
time
.
time
()
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
+=
f
"loss:
{
avg_loss
.
numpy
()[
0
]
}
"
strs
+=
f
"loss:
{
float
(
avg_loss
)
}
"
strs
+=
f
", acc_topk1:
{
acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
acc
[
'top5'
].
numpy
()[
0
]
}
"
strs
+=
f
", acc_topk1:
{
float
(
acc
[
'top1'
])
}
, acc_top5:
{
float
(
acc
[
'top5'
])
}
"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
logger
.
info
(
strs
)
logger
.
info
(
strs
)
st
=
time
.
time
()
st
=
time
.
time
()
if
epoch
%
10
==
0
:
if
epoch
%
10
==
0
:
acc
=
eval
(
config
,
model
.
_layers
.
student
)
acc
=
eval
(
config
,
model
.
_layers
.
student
)
if
len
(
best_acc
)
<
1
or
acc
[
'top5'
].
numpy
()[
0
]
>
best_acc
[
'top5'
]:
if
len
(
best_acc
)
<
1
or
float
(
acc
[
'top5'
])
>
best_acc
[
'top5'
]:
best_acc
=
acc
best_acc
=
acc
best_acc
[
'epoch'
]
=
epoch
best_acc
[
'epoch'
]
=
epoch
is_best
=
True
is_best
=
True
else
:
else
:
is_best
=
False
is_best
=
False
logger
.
info
(
logger
.
info
(
f
"The best acc: acc_topk1:
{
best_acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
best_acc
[
'top5'
].
numpy
()[
0
]
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
f
"The best acc: acc_topk1:
{
float
(
best_acc
[
'top1'
])
}
, acc_top5:
{
float
(
best_acc
[
'top5'
])
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
)
)
save_model
(
save_model
(
...
@@ -401,22 +401,22 @@ def train_distill_multiopt(config, scaler=None):
...
@@ -401,22 +401,22 @@ def train_distill_multiopt(config, scaler=None):
if
idx
%
10
==
0
:
if
idx
%
10
==
0
:
et
=
time
.
time
()
et
=
time
.
time
()
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
=
f
"epoch: [
{
epoch
}
/
{
EPOCH
}
], iter: [
{
idx
}
/
{
data_num
}
], "
strs
+=
f
"loss:
{
avg_loss
.
numpy
()[
0
]
}
, loss1:
{
avg_loss1
.
numpy
()[
0
]
}
"
strs
+=
f
"loss:
{
float
(
avg_loss
)
}
, loss1:
{
float
(
avg_loss1
)
}
"
strs
+=
f
", acc_topk1:
{
acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
acc
[
'top5'
].
numpy
()[
0
]
}
"
strs
+=
f
", acc_topk1:
{
float
(
acc
[
'top1'
])
}
, acc_top5:
{
float
(
acc
[
'top5'
])
}
"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
strs
+=
f
", batch_time:
{
round
(
et
-
st
,
4
)
}
s"
logger
.
info
(
strs
)
logger
.
info
(
strs
)
st
=
time
.
time
()
st
=
time
.
time
()
if
epoch
%
10
==
0
:
if
epoch
%
10
==
0
:
acc
=
eval
(
config
,
model
.
_layers
.
student
)
acc
=
eval
(
config
,
model
.
_layers
.
student
)
if
len
(
best_acc
)
<
1
or
acc
[
'top5'
].
numpy
()[
0
]
>
best_acc
[
'top5'
]:
if
len
(
best_acc
)
<
1
or
float
(
acc
[
'top5'
])
>
best_acc
[
'top5'
]:
best_acc
=
acc
best_acc
=
acc
best_acc
[
'epoch'
]
=
epoch
best_acc
[
'epoch'
]
=
epoch
is_best
=
True
is_best
=
True
else
:
else
:
is_best
=
False
is_best
=
False
logger
.
info
(
logger
.
info
(
f
"The best acc: acc_topk1:
{
best_acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
best_acc
[
'top5'
].
numpy
()[
0
]
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
f
"The best acc: acc_topk1:
{
float
(
best_acc
[
'top1'
])
}
, acc_top5:
{
float
(
best_acc
[
'top5'
])
}
, best_epoch:
{
best_acc
[
'epoch'
]
}
"
)
)
save_model
(
save_model
(
model
,
[
optimizer
,
optimizer1
],
model
,
[
optimizer
,
optimizer1
],
...
@@ -450,7 +450,7 @@ def eval(config, model):
...
@@ -450,7 +450,7 @@ def eval(config, model):
labels
=
paddle
.
concat
(
labels
,
axis
=
0
)
labels
=
paddle
.
concat
(
labels
,
axis
=
0
)
acc
=
metric_func
(
outs
,
labels
)
acc
=
metric_func
(
outs
,
labels
)
strs
=
f
"The metric are as follows: acc_topk1:
{
acc
[
'top1'
].
numpy
()[
0
]
}
, acc_top5:
{
acc
[
'top5'
].
numpy
()[
0
]
}
"
strs
=
f
"The metric are as follows: acc_topk1:
{
float
(
acc
[
'top1'
])
}
, acc_top5:
{
float
(
acc
[
'top5'
])
}
"
logger
.
info
(
strs
)
logger
.
info
(
strs
)
return
acc
return
acc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录