Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
e4fe2ecd
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 2 年 前同步成功
通知
285
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看板
未验证
提交
e4fe2ecd
编写于
12月 29, 2022
作者:
jm_12138
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add gradio app (#2166)
上级
2f48efda
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
12 deletion
+49
-12
modules/image/face_detection/pyramidbox_lite_mobile/README.md
...les/image/face_detection/pyramidbox_lite_mobile/README.md
+8
-1
modules/image/face_detection/pyramidbox_lite_mobile/README_en.md
.../image/face_detection/pyramidbox_lite_mobile/README_en.md
+8
-2
modules/image/face_detection/pyramidbox_lite_mobile/data_feed.py
.../image/face_detection/pyramidbox_lite_mobile/data_feed.py
+0
-1
modules/image/face_detection/pyramidbox_lite_mobile/module.py
...les/image/face_detection/pyramidbox_lite_mobile/module.py
+32
-6
modules/image/face_detection/pyramidbox_lite_mobile/processor.py
.../image/face_detection/pyramidbox_lite_mobile/processor.py
+1
-2
未找到文件。
modules/image/face_detection/pyramidbox_lite_mobile/README.md
浏览文件 @
e4fe2ecd
...
...
@@ -150,6 +150,9 @@
print(r.json()["results"])
```
-
### gradio app 支持
从 PaddleHub 2.3.1 开始支持使用链接 http://127.0.0.1:8866/gradio/pyramidbox_lite_mobile 在浏览器中访问 pyramidbox_lite_mobile 的 Gradio APP。
## 五、更新历史
...
...
@@ -165,6 +168,10 @@
修复无法导出推理模型的问题
*
1.4.0
添加 Gradio APP 支持
-
```shell
$ hub install pyramidbox_lite_mobile==1.
3
.0
$ hub install pyramidbox_lite_mobile==1.
4
.0
```
modules/image/face_detection/pyramidbox_lite_mobile/README_en.md
浏览文件 @
e4fe2ecd
...
...
@@ -149,6 +149,8 @@
print(r.json()["results"])
```
-
### Gradio APP support
Starting with PaddleHub 2.3.1, the Gradio APP for pyramidbox_lite_mobile is supported to be accessed in the browser using the link http://127.0.0.1:8866/gradio/pyramidbox_lite_mobile.
## V.Release Note
...
...
@@ -163,7 +165,11 @@
*
1.3.0
Fix a bug of save_inference_model
*
1.4.0
Add Gradio APP support.
-
```shell
$ hub install pyramidbox_lite_mobile==1.
3
.0
$ hub install pyramidbox_lite_mobile==1.
4
.0
```
modules/image/face_detection/pyramidbox_lite_mobile/data_feed.py
浏览文件 @
e4fe2ecd
# coding=utf-8
import
os
import
time
from
collections
import
OrderedDict
...
...
modules/image/face_detection/pyramidbox_lite_mobile/module.py
浏览文件 @
e4fe2ecd
# coding=utf-8
from
__future__
import
absolute_import
from
__future__
import
division
...
...
@@ -10,10 +9,10 @@ import numpy as np
import
paddle
from
paddle.inference
import
Config
from
paddle.inference
import
create_predictor
from
.data_feed
import
reader
from
.processor
import
base64_to_cv2
from
.processor
import
postprocess
from
paddlehub.module.module
import
moduleinfo
from
paddlehub.module.module
import
runnable
from
paddlehub.module.module
import
serving
...
...
@@ -24,10 +23,12 @@ from paddlehub.module.module import serving
author
=
"baidu-vis"
,
author_email
=
""
,
summary
=
"PyramidBox-Lite-Mobile is a high-performance face detection model."
,
version
=
"1.
3
.0"
)
version
=
"1.
4
.0"
)
class
PyramidBoxLiteMobile
:
def
__init__
(
self
):
self
.
default_pretrained_model_path
=
os
.
path
.
join
(
self
.
directory
,
"pyramidbox_lite_mobile_face_detection"
,
"model"
)
self
.
default_pretrained_model_path
=
os
.
path
.
join
(
self
.
directory
,
"pyramidbox_lite_mobile_face_detection"
,
"model"
)
self
.
_set_config
()
self
.
processor
=
self
...
...
@@ -35,8 +36,8 @@ class PyramidBoxLiteMobile:
"""
predictor config setting
"""
model
=
self
.
default_pretrained_model_path
+
'.pdmodel'
params
=
self
.
default_pretrained_model_path
+
'.pdiparams'
model
=
self
.
default_pretrained_model_path
+
'.pdmodel'
params
=
self
.
default_pretrained_model_path
+
'.pdiparams'
cpu_config
=
Config
(
model
,
params
)
cpu_config
.
disable_glog_info
()
cpu_config
.
disable_gpu
()
...
...
@@ -188,3 +189,28 @@ class PyramidBoxLiteMobile:
type
=
ast
.
literal_eval
,
default
=
0.6
,
help
=
"confidence threshold."
)
def
create_gradio_app
(
self
):
import
gradio
as
gr
import
tempfile
import
os
from
PIL
import
Image
def
inference
(
image
,
shrink
,
confs_threshold
):
with
tempfile
.
TemporaryDirectory
()
as
temp_dir
:
self
.
face_detection
(
paths
=
[
image
],
use_gpu
=
False
,
visualization
=
True
,
output_dir
=
temp_dir
,
shrink
=
shrink
,
confs_threshold
=
confs_threshold
)
return
Image
.
open
(
os
.
path
.
join
(
temp_dir
,
os
.
listdir
(
temp_dir
)[
0
]))
interface
=
gr
.
Interface
(
inference
,
[
gr
.
inputs
.
Image
(
type
=
"filepath"
),
gr
.
Slider
(
0.0
,
1.0
,
0.5
,
step
=
0.01
),
gr
.
Slider
(
0.0
,
1.0
,
0.6
,
step
=
0.01
)
],
gr
.
outputs
.
Image
(
type
=
"ndarray"
),
title
=
'pyramidbox_lite_mobile'
)
return
interface
modules/image/face_detection/pyramidbox_lite_mobile/processor.py
浏览文件 @
e4fe2ecd
# coding=utf-8
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
base64
import
os
import
time
import
base64
import
cv2
import
numpy
as
np
from
PIL
import
Image
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录