Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
5c8a6679
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5c8a6679
编写于
10月 29, 2019
作者:
Z
zhangxuefei
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/PaddleHub
into develop
上级
5454044b
3aee2828
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
54 addition
and
28 deletion
+54
-28
paddlehub/serving/app.py
paddlehub/serving/app.py
+33
-28
paddlehub/serving/templates/__init__.py
paddlehub/serving/templates/__init__.py
+14
-0
setup.py
setup.py
+7
-0
未找到文件。
paddlehub/serving/app.py
浏览文件 @
5c8a6679
...
@@ -20,7 +20,6 @@ import time
...
@@ -20,7 +20,6 @@ import time
import
os
import
os
import
base64
import
base64
import
logging
import
logging
import
cv2
import
multiprocessing
as
mp
import
multiprocessing
as
mp
from
multiprocessing.managers
import
BaseManager
from
multiprocessing.managers
import
BaseManager
import
random
import
random
...
@@ -93,7 +92,6 @@ def predict_cv(input_data, module_name, batch_size=1):
...
@@ -93,7 +92,6 @@ def predict_cv(input_data, module_name, batch_size=1):
filename_list
=
[]
filename_list
=
[]
for
index
in
range
(
len
(
input_data
)):
for
index
in
range
(
len
(
input_data
)):
filename_list
.
append
(
input_data
[
index
][
3
])
filename_list
.
append
(
input_data
[
index
][
3
])
cv2
.
imread
(
input_data
[
index
][
3
])
input_images
=
{
"image"
:
filename_list
}
input_images
=
{
"image"
:
filename_list
}
module
=
ImageModelService
.
get_module
(
module_name
)
module
=
ImageModelService
.
get_module
(
module_name
)
method_name
=
module
.
desc
.
attr
.
map
.
data
[
'default_signature'
].
s
method_name
=
module
.
desc
.
attr
.
map
.
data
[
'default_signature'
].
s
...
@@ -130,19 +128,21 @@ def predict_cv(input_data, module_name, batch_size=1):
...
@@ -130,19 +128,21 @@ def predict_cv(input_data, module_name, batch_size=1):
def
worker
():
def
worker
():
global
batch_size_list
,
name_list
,
queue_name_list
,
cv_module
global
batch_size_list
,
name_list
,
queue_name_list
,
cv_module
latest_num
=
random
.
randrange
(
0
,
len
(
queue_name_list
))
latest_num
=
random
.
randrange
(
0
,
len
(
queue_name_list
))
try
:
while
True
:
while
True
:
time
.
sleep
(
0.01
)
time
.
sleep
(
0.01
)
for
index
in
range
(
len
(
queue_name_list
)):
for
index
in
range
(
len
(
queue_name_list
)):
while
queues_dict
[
queue_name_list
[
latest_num
]].
empty
()
is
not
True
:
while
queues_dict
[
queue_name_list
[
latest_num
]].
empty
()
is
not
True
:
input_data
=
[]
input_data
=
[]
lock
.
acquire
()
lock
.
acquire
()
try
:
try
:
batch
=
queues_dict
[
batch
=
queues_dict
[
queue_name_list
[
latest_num
]].
get_attribute
(
"maxsize"
)
queue_name_list
[
latest_num
]].
get_attribute
(
"maxsize"
)
for
index2
in
range
(
batch
):
for
index2
in
range
(
batch
):
if
queues_dict
[
if
queues_dict
[
queue_name_list
[
latest_num
]].
empty
(
queue_name_list
[
latest_num
]].
empty
(
)
is
True
:
)
is
True
:
break
break
input_data
.
append
(
input_data
.
append
(
queues_dict
[
queue_name_list
[
latest_num
]].
get
())
queues_dict
[
queue_name_list
[
latest_num
]].
get
())
...
@@ -155,6 +155,8 @@ def worker():
...
@@ -155,6 +155,8 @@ def worker():
else
:
else
:
pass
pass
latest_num
=
(
latest_num
+
1
)
%
len
(
queue_name_list
)
latest_num
=
(
latest_num
+
1
)
%
len
(
queue_name_list
)
except
KeyboardInterrupt
:
print
(
"Process %s is end."
%
(
os
.
getpid
()))
def
init_pool
(
l
):
def
init_pool
(
l
):
...
@@ -168,7 +170,7 @@ def create_app():
...
@@ -168,7 +170,7 @@ def create_app():
gunicorn_logger
=
logging
.
getLogger
(
'gunicorn.error'
)
gunicorn_logger
=
logging
.
getLogger
(
'gunicorn.error'
)
app_instance
.
logger
.
handlers
=
gunicorn_logger
.
handlers
app_instance
.
logger
.
handlers
=
gunicorn_logger
.
handlers
app_instance
.
logger
.
setLevel
(
gunicorn_logger
.
level
)
app_instance
.
logger
.
setLevel
(
gunicorn_logger
.
level
)
global
queues_dict
global
queues_dict
,
pool
lock
=
mp
.
Lock
()
lock
=
mp
.
Lock
()
pool
=
mp
.
Pool
(
pool
=
mp
.
Pool
(
processes
=
(
mp
.
cpu_count
()
-
1
),
processes
=
(
mp
.
cpu_count
()
-
1
),
...
@@ -310,6 +312,9 @@ def run(is_use_gpu=False, configs=None, port=8888):
...
@@ -310,6 +312,9 @@ def run(is_use_gpu=False, configs=None, port=8888):
return
return
my_app
=
create_app
()
my_app
=
create_app
()
my_app
.
run
(
host
=
"0.0.0.0"
,
port
=
port
,
debug
=
False
)
my_app
.
run
(
host
=
"0.0.0.0"
,
port
=
port
,
debug
=
False
)
pool
.
close
()
pool
.
join
()
print
(
"PaddleHub-Serving has been stopped."
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
paddlehub/serving/templates/__init__.py
0 → 100644
浏览文件 @
5c8a6679
# coding: utf-8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
setup.py
浏览文件 @
5c8a6679
...
@@ -52,6 +52,13 @@ setup(
...
@@ -52,6 +52,13 @@ setup(
author_email
=
'paddle-dev@baidu.com'
,
author_email
=
'paddle-dev@baidu.com'
,
install_requires
=
REQUIRED_PACKAGES
,
install_requires
=
REQUIRED_PACKAGES
,
packages
=
find_packages
(),
packages
=
find_packages
(),
package_data
=
{
'paddlehub/serving/templates'
:
[
'paddlehub/serving/templates/serving_config.json'
,
'paddlehub/serving/templates/main.html'
]
},
include_package_data
=
True
,
# PyPI package information.
# PyPI package information.
classifiers
=
[
classifiers
=
[
'Development Status :: 4 - Beta'
,
'Development Status :: 4 - Beta'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录