Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
eb2f719d
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看板
提交
eb2f719d
编写于
10月 12, 2020
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ocr 1012
上级
0e4ae332
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
14 deletion
+22
-14
deploy/pdserving/clas_local_server.py
deploy/pdserving/clas_local_server.py
+2
-1
deploy/pdserving/clas_rpc_server.py
deploy/pdserving/clas_rpc_server.py
+2
-1
deploy/pdserving/ocr_local_server.py
deploy/pdserving/ocr_local_server.py
+1
-1
deploy/pdserving/ocr_rpc_server.py
deploy/pdserving/ocr_rpc_server.py
+3
-3
doc/doc_ch/serving_inference.md
doc/doc_ch/serving_inference.md
+14
-8
未找到文件。
deploy/pdserving/clas_local_server.py
浏览文件 @
eb2f719d
...
@@ -74,6 +74,7 @@ class TextClassifierHelper(TextClassifier):
...
@@ -74,6 +74,7 @@ class TextClassifierHelper(TextClassifier):
prob_out
=
outputs
[
0
]
prob_out
=
outputs
[
0
]
label_out
=
outputs
[
1
]
label_out
=
outputs
[
1
]
indices
=
args
[
"indices"
]
indices
=
args
[
"indices"
]
img_list
=
args
[
"img_list"
]
cls_res
=
[[
''
,
0.0
]]
*
len
(
label_out
)
cls_res
=
[[
''
,
0.0
]]
*
len
(
label_out
)
if
len
(
label_out
.
shape
)
!=
1
:
if
len
(
label_out
.
shape
)
!=
1
:
prob_out
,
label_out
=
label_out
,
prob_out
prob_out
,
label_out
=
label_out
,
prob_out
...
@@ -84,7 +85,7 @@ class TextClassifierHelper(TextClassifier):
...
@@ -84,7 +85,7 @@ class TextClassifierHelper(TextClassifier):
cls_res
[
indices
[
rno
]]
=
[
label
,
score
]
cls_res
[
indices
[
rno
]]
=
[
label
,
score
]
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
img_list
[
indices
[
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
rno
]],
1
)
img_list
[
indices
[
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
rno
]],
1
)
return
args
[
"img_list"
]
,
cls_res
return
img_list
,
cls_res
class
OCRService
(
WebService
):
class
OCRService
(
WebService
):
...
...
deploy/pdserving/clas_rpc_server.py
浏览文件 @
eb2f719d
...
@@ -79,6 +79,7 @@ class TextClassifierHelper(TextClassifier):
...
@@ -79,6 +79,7 @@ class TextClassifierHelper(TextClassifier):
prob_out
=
outputs
[
0
]
prob_out
=
outputs
[
0
]
label_out
=
outputs
[
1
]
label_out
=
outputs
[
1
]
indices
=
args
[
"indices"
]
indices
=
args
[
"indices"
]
img_list
=
args
[
"img_list"
]
cls_res
=
[[
''
,
0.0
]]
*
len
(
label_out
)
cls_res
=
[[
''
,
0.0
]]
*
len
(
label_out
)
if
len
(
label_out
.
shape
)
!=
1
:
if
len
(
label_out
.
shape
)
!=
1
:
prob_out
,
label_out
=
label_out
,
prob_out
prob_out
,
label_out
=
label_out
,
prob_out
...
@@ -89,7 +90,7 @@ class TextClassifierHelper(TextClassifier):
...
@@ -89,7 +90,7 @@ class TextClassifierHelper(TextClassifier):
cls_res
[
indices
[
rno
]]
=
[
label
,
score
]
cls_res
[
indices
[
rno
]]
=
[
label
,
score
]
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
img_list
[
indices
[
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
rno
]],
1
)
img_list
[
indices
[
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
rno
]],
1
)
return
args
[
"img_list"
]
,
cls_res
return
img_list
,
cls_res
class
OCRService
(
WebService
):
class
OCRService
(
WebService
):
...
...
deploy/pdserving/ocr_local_server.py
浏览文件 @
eb2f719d
...
@@ -50,7 +50,7 @@ class TextSystemHelper(TextSystem):
...
@@ -50,7 +50,7 @@ class TextSystemHelper(TextSystem):
self
.
det_client
=
Debugger
()
self
.
det_client
=
Debugger
()
self
.
det_client
.
load_model_config
(
self
.
det_client
.
load_model_config
(
global_args
.
det_model_dir
,
gpu
=
True
,
profile
=
False
)
global_args
.
det_model_dir
,
gpu
=
True
,
profile
=
False
)
self
.
fetch
=
[
"
ctc_greedy_decoder_0.tmp_0"
,
"softmax_0
.tmp_0"
]
self
.
fetch
=
[
"
save_infer_model/scale_0.tmp_0"
,
"save_infer_model/scale_1
.tmp_0"
]
def
preprocess
(
self
,
img
):
def
preprocess
(
self
,
img
):
feed
,
fetch
,
self
.
tmp_args
=
self
.
text_detector
.
preprocess
(
img
)
feed
,
fetch
,
self
.
tmp_args
=
self
.
text_detector
.
preprocess
(
img
)
...
...
deploy/pdserving/ocr_rpc_server.py
浏览文件 @
eb2f719d
...
@@ -43,14 +43,14 @@ class TextSystemHelper(TextSystem):
...
@@ -43,14 +43,14 @@ class TextSystemHelper(TextSystem):
if
self
.
use_angle_cls
:
if
self
.
use_angle_cls
:
self
.
clas_client
=
Client
()
self
.
clas_client
=
Client
()
self
.
clas_client
.
load_client_config
(
self
.
clas_client
.
load_client_config
(
"
ocr_clas
_client/serving_client_conf.prototxt"
)
"
cls_infer
_client/serving_client_conf.prototxt"
)
self
.
clas_client
.
connect
([
"127.0.0.1:9294"
])
self
.
clas_client
.
connect
([
"127.0.0.1:9294"
])
self
.
text_classifier
=
TextClassifierHelper
(
args
)
self
.
text_classifier
=
TextClassifierHelper
(
args
)
self
.
det_client
=
Client
()
self
.
det_client
=
Client
()
self
.
det_client
.
load_client_config
(
self
.
det_client
.
load_client_config
(
"det_
db
_client/serving_client_conf.prototxt"
)
"det_
infer
_client/serving_client_conf.prototxt"
)
self
.
det_client
.
connect
([
"127.0.0.1:9293"
])
self
.
det_client
.
connect
([
"127.0.0.1:9293"
])
self
.
fetch
=
[
"
ctc_greedy_decoder_0.tmp_0"
,
"softmax_0
.tmp_0"
]
self
.
fetch
=
[
"
save_infer_model/scale_0.tmp_0"
,
"save_infer_model/scale_1
.tmp_0"
]
def
preprocess
(
self
,
img
):
def
preprocess
(
self
,
img
):
feed
,
fetch
,
self
.
tmp_args
=
self
.
text_detector
.
preprocess
(
img
)
feed
,
fetch
,
self
.
tmp_args
=
self
.
text_detector
.
preprocess
(
img
)
...
...
doc/doc_ch/serving_inference.md
浏览文件 @
eb2f719d
...
@@ -16,17 +16,23 @@
...
@@ -16,17 +16,23 @@
**操作系统版本:Linux/Windows**
**操作系统版本:Linux/Windows**
**Python版本: 2.7/3.6/3.7**
**Python版本: 2.7/3.
5/3.
6/3.7**
**Python操作指南:**
**Python操作指南:**
目前Serving用于OCR的部分功能还在测试当中,因此在这里我们给出
[
Servnig latest package
](
https://github.com/PaddlePaddle/Serving/blob/develop/doc/LATEST_PACKAGES.md
)
大家根据自己的环境选择需要安装的whl包即可,例如以Python 3.5为例,执行下列命令
```
```
#CPU/GPU版本选择一个
#CPU/GPU版本选择一个
#GPU版本服务端
#GPU版本服务端
python -m pip install paddle_serving_server_gpu
#CUDA 9
python -m pip install -U https://paddle-serving.bj.bcebos.com/whl/paddle_serving_server_gpu-0.0.0.post9-py3-none-any.whl
#CUDA 10
python -m pip install -U https://paddle-serving.bj.bcebos.com/whl/paddle_serving_server_gpu-0.0.0.post10-py3-none-any.whl
#CPU版本服务端
#CPU版本服务端
python -m pip install
paddle_serving_server
python -m pip install
-U https://paddle-serving.bj.bcebos.com/whl/paddle_serving_server-0.0.0-py3-none-any.whl
#客户端和App包使用以下链接(CPU,GPU通用)
#客户端和App包使用以下链接(CPU,GPU通用)
python -m pip install
paddle_serving_app paddle_serving_client
python -m pip install
-U https://paddle-serving.bj.bcebos.com/whl/paddle_serving_client-0.0.0-cp36-none-any.whl https://paddle-serving.bj.bcebos.com/whl/paddle_serving_app-0.0.0-py3-none-any.whl
```
```
## 二、训练模型转Serving模型
## 二、训练模型转Serving模型
...
@@ -214,12 +220,12 @@ python rec_web_client.py
...
@@ -214,12 +220,12 @@ python rec_web_client.py
```
```
#标准版,Linux用户
#标准版,Linux用户
#GPU用户
#GPU用户
python -m paddle_serving_server_gpu.serve --model det_
mv
_server --port 9293 --gpu_id 0
python -m paddle_serving_server_gpu.serve --model det_
infer
_server --port 9293 --gpu_id 0
python -m paddle_serving_server_gpu.serve --model
ocr_cls
_server --port 9294 --gpu_id 0
python -m paddle_serving_server_gpu.serve --model
cls_infer
_server --port 9294 --gpu_id 0
python ocr_rpc_server.py
python ocr_rpc_server.py
#CPU用户
#CPU用户
python -m paddle_serving_server.serve --model det_
mv
_server --port 9293
python -m paddle_serving_server.serve --model det_
infer
_server --port 9293
python -m paddle_serving_server.serve --model
ocr_cls
_server --port 9294
python -m paddle_serving_server.serve --model
cls_infer
_server --port 9294
python ocr_rpc_server.py
python ocr_rpc_server.py
#快速版,Windows/Linux用户
#快速版,Windows/Linux用户
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录