Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
5dd4fe7f
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5dd4fe7f
编写于
7月 01, 2020
作者:
J
Jiawei Wang
提交者:
GitHub
7月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #711 from wangjiawei04/blazeface
support Blazeface
上级
2205dbed
4cb95a6c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
88 addition
and
1 deletion
+88
-1
python/examples/blazeface/README.md
python/examples/blazeface/README.md
+23
-0
python/examples/blazeface/test_client.py
python/examples/blazeface/test_client.py
+38
-0
python/paddle_serving_app/models/model_list.py
python/paddle_serving_app/models/model_list.py
+2
-1
python/paddle_serving_app/reader/functional.py
python/paddle_serving_app/reader/functional.py
+1
-0
python/paddle_serving_app/reader/image_reader.py
python/paddle_serving_app/reader/image_reader.py
+24
-0
未找到文件。
python/examples/blazeface/README.md
0 → 100644
浏览文件 @
5dd4fe7f
# Blazeface
## Get Model
```
python -m paddle_serving_app.package --get_model blazeface
tar -xzvf blazeface.tar.gz
```
## RPC Service
### Start Service
```
python -m paddle_serving_server.serve --model serving_server --port 9494
```
### Client Prediction
```
python test_client.py serving_client/serving_client_conf.prototxt test.jpg
```
the result is in
`output`
folder, including a json file and image file with bounding boxes.
python/examples/blazeface/test_client.py
0 → 100644
浏览文件 @
5dd4fe7f
# Copyright (c) 2020 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.
from
paddle_serving_client
import
Client
from
paddle_serving_app.reader
import
*
import
sys
import
numpy
as
np
preprocess
=
Sequential
([
File2Image
(),
Normalize
([
104
,
117
,
123
],
[
127.502231
,
127.502231
,
127.502231
],
False
)
])
postprocess
=
BlazeFacePostprocess
(
"label_list.txt"
,
"output"
)
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
'127.0.0.1:9494'
])
im_0
=
preprocess
(
sys
.
argv
[
2
])
tmp
=
Transpose
((
2
,
0
,
1
))
im
=
tmp
(
im_0
)
fetch_map
=
client
.
predict
(
feed
=
{
"image"
:
im
},
fetch
=
[
"detection_output_0.tmp_0"
])
fetch_map
[
"image"
]
=
sys
.
argv
[
2
]
fetch_map
[
"im_shape"
]
=
im_0
.
shape
postprocess
(
fetch_map
)
python/paddle_serving_app/models/model_list.py
浏览文件 @
5dd4fe7f
...
...
@@ -24,7 +24,8 @@ class ServingModels(object):
"SentimentAnalysis"
]
=
[
"senta_bilstm"
,
"senta_bow"
,
"senta_cnn"
]
self
.
model_dict
[
"SemanticRepresentation"
]
=
[
"ernie"
]
self
.
model_dict
[
"ChineseWordSegmentation"
]
=
[
"lac"
]
self
.
model_dict
[
"ObjectDetection"
]
=
[
"faster_rcnn"
,
"yolov4"
]
self
.
model_dict
[
"ObjectDetection"
]
=
[
"faster_rcnn"
,
"yolov4"
,
"blazeface"
]
self
.
model_dict
[
"ImageSegmentation"
]
=
[
"unet"
,
"deeplabv3"
,
"deeplabv3+cityscapes"
]
...
...
python/paddle_serving_app/reader/functional.py
浏览文件 @
5dd4fe7f
...
...
@@ -29,6 +29,7 @@ def normalize(img, mean, std, channel_first):
else
:
img_mean
=
np
.
array
(
mean
).
reshape
((
1
,
1
,
3
))
img_std
=
np
.
array
(
std
).
reshape
((
1
,
1
,
3
))
img
=
np
.
array
(
img
).
astype
(
"float32"
)
img
-=
img_mean
img
/=
img_std
return
img
...
...
python/paddle_serving_app/reader/image_reader.py
浏览文件 @
5dd4fe7f
...
...
@@ -440,6 +440,30 @@ class RCNNPostprocess(object):
self
.
label_file
,
self
.
output_dir
)
class
BlazeFacePostprocess
(
RCNNPostprocess
):
def
clip_bbox
(
self
,
bbox
,
im_size
=
None
):
h
=
1.
if
im_size
is
None
else
im_size
[
0
]
w
=
1.
if
im_size
is
None
else
im_size
[
1
]
xmin
=
max
(
min
(
bbox
[
0
],
w
),
0.
)
ymin
=
max
(
min
(
bbox
[
1
],
h
),
0.
)
xmax
=
max
(
min
(
bbox
[
2
],
w
),
0.
)
ymax
=
max
(
min
(
bbox
[
3
],
h
),
0.
)
return
xmin
,
ymin
,
xmax
,
ymax
def
_get_bbox_result
(
self
,
fetch_map
,
fetch_name
,
clsid2catid
):
result
=
{}
is_bbox_normalized
=
True
#for blaze face, set true here
output
=
fetch_map
[
fetch_name
]
lod
=
[
fetch_map
[
fetch_name
+
'.lod'
]]
lengths
=
self
.
_offset_to_lengths
(
lod
)
np_data
=
np
.
array
(
output
)
result
[
'bbox'
]
=
(
np_data
,
lengths
)
result
[
'im_id'
]
=
np
.
array
([[
0
]])
result
[
"im_shape"
]
=
np
.
array
(
fetch_map
[
"im_shape"
]).
astype
(
np
.
int32
)
bbox_results
=
self
.
_bbox2out
([
result
],
clsid2catid
,
is_bbox_normalized
)
return
bbox_results
class
Sequential
(
object
):
"""
Args:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录