Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
759e7385
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看板
提交
759e7385
编写于
5月 13, 2020
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix infer
上级
5d70fd44
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
9 deletion
+17
-9
ppocr/modeling/architectures/rec_model.py
ppocr/modeling/architectures/rec_model.py
+3
-1
ppocr/postprocess/db_postprocess.py
ppocr/postprocess/db_postprocess.py
+1
-1
tools/export_model.py
tools/export_model.py
+2
-1
tools/infer/predict_det.py
tools/infer/predict_det.py
+4
-4
tools/infer/predict_eval.py
tools/infer/predict_eval.py
+6
-1
tools/infer/utility.py
tools/infer/utility.py
+1
-1
未找到文件。
ppocr/modeling/architectures/rec_model.py
浏览文件 @
759e7385
...
@@ -109,6 +109,8 @@ class RecModel(object):
...
@@ -109,6 +109,8 @@ class RecModel(object):
decoded_out
,
'label'
:
label
}
decoded_out
,
'label'
:
label
}
return
loader
,
outputs
return
loader
,
outputs
elif
mode
==
"export"
:
elif
mode
==
"export"
:
return
[
image
,
{
'decoded_out'
:
decoded_out
}]
predict
=
predicts
[
'predict'
]
predict
=
fluid
.
layers
.
softmax
(
predict
)
return
[
image
,
{
'decoded_out'
:
decoded_out
,
'predicts'
:
predict
}]
else
:
else
:
return
loader
,
{
'decoded_out'
:
decoded_out
}
return
loader
,
{
'decoded_out'
:
decoded_out
}
ppocr/postprocess/db_postprocess.py
浏览文件 @
759e7385
...
@@ -81,7 +81,7 @@ class DBPostProcess(object):
...
@@ -81,7 +81,7 @@ class DBPostProcess(object):
scores
[
index
]
=
score
scores
[
index
]
=
score
return
boxes
,
scores
return
boxes
,
scores
def
unclip
(
self
,
box
,
unclip_ratio
=
1.5
):
def
unclip
(
self
,
box
,
unclip_ratio
=
2.0
):
poly
=
Polygon
(
box
)
poly
=
Polygon
(
box
)
distance
=
poly
.
area
*
unclip_ratio
/
poly
.
length
distance
=
poly
.
area
*
unclip_ratio
/
poly
.
length
offset
=
pyclipper
.
PyclipperOffset
()
offset
=
pyclipper
.
PyclipperOffset
()
...
...
tools/export_model.py
浏览文件 @
759e7385
...
@@ -52,7 +52,8 @@ def main():
...
@@ -52,7 +52,8 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
# check if set use_gpu=True in paddlepaddle cpu version
use_gpu
=
config
[
'Global'
][
'use_gpu'
]
use_gpu
=
config
[
'Global'
][
'use_gpu'
]
program
.
check_gpu
(
True
)
# program.check_gpu(True)
use_gpu
=
False
alg
=
config
[
'Global'
][
'algorithm'
]
alg
=
config
[
'Global'
][
'algorithm'
]
assert
alg
in
[
'EAST'
,
'DB'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
]
assert
alg
in
[
'EAST'
,
'DB'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
]
...
...
tools/infer/predict_det.py
浏览文件 @
759e7385
...
@@ -116,10 +116,10 @@ class TextDetector(object):
...
@@ -116,10 +116,10 @@ class TextDetector(object):
rect_height
=
int
(
np
.
linalg
.
norm
(
box
[
0
]
-
box
[
3
]))
rect_height
=
int
(
np
.
linalg
.
norm
(
box
[
0
]
-
box
[
3
]))
if
rect_width
<=
10
or
rect_height
<=
10
:
if
rect_width
<=
10
or
rect_height
<=
10
:
continue
continue
if
diffh
<=
10
and
diffw
<=
10
:
#
if diffh <= 10 and diffw <= 10:
box
=
self
.
expand_det_res
(
#
box = self.expand_det_res(
copy
.
deepcopy
(
box
),
bbox_height
,
bbox_width
,
img_height
,
#
copy.deepcopy(box), bbox_height, bbox_width, img_height,
img_width
)
#
img_width)
dt_boxes_new
.
append
(
box
)
dt_boxes_new
.
append
(
box
)
dt_boxes
=
np
.
array
(
dt_boxes_new
)
dt_boxes
=
np
.
array
(
dt_boxes_new
)
return
dt_boxes
return
dt_boxes
...
...
tools/infer/predict_eval.py
浏览文件 @
759e7385
...
@@ -38,6 +38,8 @@ if __name__ == "__main__":
...
@@ -38,6 +38,8 @@ if __name__ == "__main__":
total_time_all
=
0
total_time_all
=
0
count
=
0
count
=
0
save_path
=
"./inference_output/predict.txt"
save_path
=
"./inference_output/predict.txt"
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
save_path
)):
os
.
makedirs
(
os
.
path
.
dirname
(
save_path
))
fout
=
open
(
save_path
,
"wb"
)
fout
=
open
(
save_path
,
"wb"
)
for
image_name
in
image_file_list
:
for
image_name
in
image_file_list
:
image_file
=
image_name
image_file
=
image_name
...
@@ -77,7 +79,10 @@ if __name__ == "__main__":
...
@@ -77,7 +79,10 @@ if __name__ == "__main__":
draw_img_save
=
os
.
path
.
join
(
draw_img_save
=
os
.
path
.
join
(
os
.
path
.
dirname
(
save_path
),
"inference_draw"
,
os
.
path
.
dirname
(
save_path
),
"inference_draw"
,
os
.
path
.
basename
(
image_file
))
os
.
path
.
basename
(
image_file
))
cv2
.
imwrite
(
draw_img_save
,
new_img
)
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
draw_img_save
)):
os
.
makedirs
(
os
.
path
.
dirname
(
draw_img_save
))
cv2
.
imwrite
(
draw_img_save
,
new_img
[:,
:,
::
-
1
])
print
(
"drawed img saved in {}"
.
format
(
draw_img_save
))
# save predicted results in txt file
# save predicted results in txt file
otstr
=
image_name
+
"
\t
"
+
json
.
dumps
(
bbox_list
)
+
"
\n
"
otstr
=
image_name
+
"
\t
"
+
json
.
dumps
(
bbox_list
)
+
"
\n
"
fout
.
write
(
otstr
.
encode
(
'utf-8'
))
fout
.
write
(
otstr
.
encode
(
'utf-8'
))
...
...
tools/infer/utility.py
浏览文件 @
759e7385
...
@@ -138,7 +138,7 @@ def draw_ocr(image, boxes, txts, scores, draw_txt):
...
@@ -138,7 +138,7 @@ def draw_ocr(image, boxes, txts, scores, draw_txt):
for
i
,
txt
in
enumerate
(
txts
):
for
i
,
txt
in
enumerate
(
txts
):
font
=
ImageFont
.
truetype
(
font
=
ImageFont
.
truetype
(
"/simfang.TTF"
,
font_size
,
encoding
=
"utf-8"
)
"
./doc
/simfang.TTF"
,
font_size
,
encoding
=
"utf-8"
)
new_txt
=
str
(
i
)
+
': '
+
txt
+
' '
+
str
(
scores
[
i
])
new_txt
=
str
(
i
)
+
': '
+
txt
+
' '
+
str
(
scores
[
i
])
draw_txt
.
text
((
20
,
gap
*
(
i
+
1
)),
new_txt
,
txt_color
,
font
=
font
)
draw_txt
.
text
((
20
,
gap
*
(
i
+
1
)),
new_txt
,
txt_color
,
font
=
font
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录