Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
znstj
PaddleOCR
提交
3a0090dc
P
PaddleOCR
项目概览
znstj
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3a0090dc
编写于
12月 21, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete fluid
上级
59af7359
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
23 addition
and
26 deletion
+23
-26
ppocr/losses/det_sast_loss.py
ppocr/losses/det_sast_loss.py
+22
-22
tools/infer/predict_cls.py
tools/infer/predict_cls.py
+0
-1
tools/infer/predict_det.py
tools/infer/predict_det.py
+0
-1
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+0
-1
tools/program.py
tools/program.py
+1
-1
未找到文件。
ppocr/losses/det_sast_loss.py
浏览文件 @
3a0090dc
...
@@ -19,7 +19,6 @@ from __future__ import print_function
...
@@ -19,7 +19,6 @@ from __future__ import print_function
import
paddle
import
paddle
from
paddle
import
nn
from
paddle
import
nn
from
.det_basic_loss
import
DiceLoss
from
.det_basic_loss
import
DiceLoss
import
paddle.fluid
as
fluid
import
numpy
as
np
import
numpy
as
np
...
@@ -27,9 +26,7 @@ class SASTLoss(nn.Layer):
...
@@ -27,9 +26,7 @@ class SASTLoss(nn.Layer):
"""
"""
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
eps
=
1e-6
,
**
kwargs
):
eps
=
1e-6
,
**
kwargs
):
super
(
SASTLoss
,
self
).
__init__
()
super
(
SASTLoss
,
self
).
__init__
()
self
.
dice_loss
=
DiceLoss
(
eps
=
eps
)
self
.
dice_loss
=
DiceLoss
(
eps
=
eps
)
...
@@ -53,10 +50,12 @@ class SASTLoss(nn.Layer):
...
@@ -53,10 +50,12 @@ class SASTLoss(nn.Layer):
score_loss
=
1.0
-
2
*
intersection
/
(
union
+
1e-5
)
score_loss
=
1.0
-
2
*
intersection
/
(
union
+
1e-5
)
#border loss
#border loss
l_border_split
,
l_border_norm
=
paddle
.
split
(
l_border
,
num_or_sections
=
[
4
,
1
],
axis
=
1
)
l_border_split
,
l_border_norm
=
paddle
.
split
(
l_border
,
num_or_sections
=
[
4
,
1
],
axis
=
1
)
f_border_split
=
f_border
f_border_split
=
f_border
border_ex_shape
=
l_border_norm
.
shape
*
np
.
array
([
1
,
4
,
1
,
1
])
border_ex_shape
=
l_border_norm
.
shape
*
np
.
array
([
1
,
4
,
1
,
1
])
l_border_norm_split
=
paddle
.
expand
(
x
=
l_border_norm
,
shape
=
border_ex_shape
)
l_border_norm_split
=
paddle
.
expand
(
x
=
l_border_norm
,
shape
=
border_ex_shape
)
l_border_score
=
paddle
.
expand
(
x
=
l_score
,
shape
=
border_ex_shape
)
l_border_score
=
paddle
.
expand
(
x
=
l_score
,
shape
=
border_ex_shape
)
l_border_mask
=
paddle
.
expand
(
x
=
l_mask
,
shape
=
border_ex_shape
)
l_border_mask
=
paddle
.
expand
(
x
=
l_mask
,
shape
=
border_ex_shape
)
...
@@ -72,7 +71,8 @@ class SASTLoss(nn.Layer):
...
@@ -72,7 +71,8 @@ class SASTLoss(nn.Layer):
(
paddle
.
sum
(
l_border_score
*
l_border_mask
)
+
1e-5
)
(
paddle
.
sum
(
l_border_score
*
l_border_mask
)
+
1e-5
)
#tvo_loss
#tvo_loss
l_tvo_split
,
l_tvo_norm
=
paddle
.
split
(
l_tvo
,
num_or_sections
=
[
8
,
1
],
axis
=
1
)
l_tvo_split
,
l_tvo_norm
=
paddle
.
split
(
l_tvo
,
num_or_sections
=
[
8
,
1
],
axis
=
1
)
f_tvo_split
=
f_tvo
f_tvo_split
=
f_tvo
tvo_ex_shape
=
l_tvo_norm
.
shape
*
np
.
array
([
1
,
8
,
1
,
1
])
tvo_ex_shape
=
l_tvo_norm
.
shape
*
np
.
array
([
1
,
8
,
1
,
1
])
l_tvo_norm_split
=
paddle
.
expand
(
x
=
l_tvo_norm
,
shape
=
tvo_ex_shape
)
l_tvo_norm_split
=
paddle
.
expand
(
x
=
l_tvo_norm
,
shape
=
tvo_ex_shape
)
...
@@ -91,7 +91,8 @@ class SASTLoss(nn.Layer):
...
@@ -91,7 +91,8 @@ class SASTLoss(nn.Layer):
(
paddle
.
sum
(
l_tvo_score
*
l_tvo_mask
)
+
1e-5
)
(
paddle
.
sum
(
l_tvo_score
*
l_tvo_mask
)
+
1e-5
)
#tco_loss
#tco_loss
l_tco_split
,
l_tco_norm
=
paddle
.
split
(
l_tco
,
num_or_sections
=
[
2
,
1
],
axis
=
1
)
l_tco_split
,
l_tco_norm
=
paddle
.
split
(
l_tco
,
num_or_sections
=
[
2
,
1
],
axis
=
1
)
f_tco_split
=
f_tco
f_tco_split
=
f_tco
tco_ex_shape
=
l_tco_norm
.
shape
*
np
.
array
([
1
,
2
,
1
,
1
])
tco_ex_shape
=
l_tco_norm
.
shape
*
np
.
array
([
1
,
2
,
1
,
1
])
l_tco_norm_split
=
paddle
.
expand
(
x
=
l_tco_norm
,
shape
=
tco_ex_shape
)
l_tco_norm_split
=
paddle
.
expand
(
x
=
l_tco_norm
,
shape
=
tco_ex_shape
)
...
@@ -109,7 +110,6 @@ class SASTLoss(nn.Layer):
...
@@ -109,7 +110,6 @@ class SASTLoss(nn.Layer):
tco_loss
=
paddle
.
sum
(
tco_out_loss
*
l_tco_score
*
l_tco_mask
)
/
\
tco_loss
=
paddle
.
sum
(
tco_out_loss
*
l_tco_score
*
l_tco_mask
)
/
\
(
paddle
.
sum
(
l_tco_score
*
l_tco_mask
)
+
1e-5
)
(
paddle
.
sum
(
l_tco_score
*
l_tco_mask
)
+
1e-5
)
# total loss
# total loss
tvo_lw
,
tco_lw
=
1.5
,
1.5
tvo_lw
,
tco_lw
=
1.5
,
1.5
score_lw
,
border_lw
=
1.0
,
1.0
score_lw
,
border_lw
=
1.0
,
1.0
...
...
tools/infer/predict_cls.py
浏览文件 @
3a0090dc
...
@@ -24,7 +24,6 @@ import numpy as np
...
@@ -24,7 +24,6 @@ import numpy as np
import
math
import
math
import
time
import
time
import
traceback
import
traceback
import
paddle.fluid
as
fluid
import
tools.infer.utility
as
utility
import
tools.infer.utility
as
utility
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
...
...
tools/infer/predict_det.py
浏览文件 @
3a0090dc
...
@@ -22,7 +22,6 @@ import cv2
...
@@ -22,7 +22,6 @@ import cv2
import
numpy
as
np
import
numpy
as
np
import
time
import
time
import
sys
import
sys
import
paddle
import
tools.infer.utility
as
utility
import
tools.infer.utility
as
utility
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils.logging
import
get_logger
...
...
tools/infer/predict_rec.py
浏览文件 @
3a0090dc
...
@@ -23,7 +23,6 @@ import numpy as np
...
@@ -23,7 +23,6 @@ import numpy as np
import
math
import
math
import
time
import
time
import
traceback
import
traceback
import
paddle.fluid
as
fluid
import
tools.infer.utility
as
utility
import
tools.infer.utility
as
utility
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
...
...
tools/program.py
浏览文件 @
3a0090dc
...
@@ -131,7 +131,7 @@ def check_gpu(use_gpu):
...
@@ -131,7 +131,7 @@ def check_gpu(use_gpu):
"model on CPU"
"model on CPU"
try
:
try
:
if
use_gpu
and
not
paddle
.
fluid
.
is_compiled_with_cuda
():
if
use_gpu
and
not
paddle
.
is_compiled_with_cuda
():
print
(
err
)
print
(
err
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
except
Exception
as
e
:
except
Exception
as
e
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录