Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
9f5454b7
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看板
未验证
提交
9f5454b7
编写于
12月 29, 2022
作者:
jm_12138
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update pp-tinypose (#2188)
上级
497e3cea
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
33 deletion
+42
-33
modules/image/keypoint_detection/pp-tinypose/README.md
modules/image/keypoint_detection/pp-tinypose/README.md
+8
-1
modules/image/keypoint_detection/pp-tinypose/infer.py
modules/image/keypoint_detection/pp-tinypose/infer.py
+3
-3
modules/image/keypoint_detection/pp-tinypose/keypoint_infer.py
...es/image/keypoint_detection/pp-tinypose/keypoint_infer.py
+2
-2
modules/image/keypoint_detection/pp-tinypose/module.py
modules/image/keypoint_detection/pp-tinypose/module.py
+19
-2
modules/image/keypoint_detection/pp-tinypose/test.py
modules/image/keypoint_detection/pp-tinypose/test.py
+9
-24
modules/image/keypoint_detection/pp-tinypose/visualize.py
modules/image/keypoint_detection/pp-tinypose/visualize.py
+1
-1
未找到文件。
modules/image/keypoint_detection/pp-tinypose/README.md
浏览文件 @
9f5454b7
...
...
@@ -125,6 +125,9 @@
r = requests.post(url=url, headers=headers, data=json.dumps(data))
```
-
### Gradio APP 支持
从 PaddleHub 2.3.1 开始支持使用链接 http://127.0.0.1:8866/gradio/pp-tinypose 在浏览器中访问 pp-tinypose 的 Gradio APP。
## 五、更新历史
*
1.0.0
...
...
@@ -135,6 +138,10 @@
修复使用 ndarray 输入时无法保存可视化图片的问题
*
1.2.0
添加 Gradio APP 支持
-
```shell
$ hub install pp-tinypose==1.
1
.0
$ hub install pp-tinypose==1.
2
.0
```
modules/image/keypoint_detection/pp-tinypose/infer.py
浏览文件 @
9f5454b7
...
...
@@ -23,6 +23,9 @@ import yaml
from
paddle.inference
import
Config
from
paddle.inference
import
create_predictor
from
.keypoint_preprocess
import
EvalAffine
from
.keypoint_preprocess
import
expand_crop
from
.keypoint_preprocess
import
TopDownEvalAffine
from
.preprocess
import
decode_image
from
.preprocess
import
LetterBoxResize
from
.preprocess
import
NormalizeImage
...
...
@@ -32,9 +35,6 @@ from .preprocess import Permute
from
.preprocess
import
preprocess
from
.preprocess
import
Resize
from
.preprocess
import
WarpAffine
from
.keypoint_preprocess
import
EvalAffine
from
.keypoint_preprocess
import
expand_crop
from
.keypoint_preprocess
import
TopDownEvalAffine
from
.visualize
import
visualize_box
# Global dictionary
...
...
modules/image/keypoint_detection/pp-tinypose/keypoint_infer.py
浏览文件 @
9f5454b7
...
...
@@ -18,10 +18,10 @@ import cv2
import
numpy
as
np
import
yaml
from
.
keypoint_preprocess
import
expand_crop
from
.
infer
import
Detector
from
.keypoint_postprocess
import
HRNetPostProcess
from
.keypoint_preprocess
import
expand_crop
from
.visualize
import
visualize_pose
from
.infer
import
Detector
# Global dictionary
KEYPOINT_SUPPORT_MODELS
=
{
'HigherHRNet'
:
'keypoint_bottomup'
,
'HRNet'
:
'keypoint_topdown'
}
...
...
modules/image/keypoint_detection/pp-tinypose/module.py
浏览文件 @
9f5454b7
...
...
@@ -26,7 +26,6 @@ from .keypoint_infer import KeyPointDetector
from
.preprocess
import
base64_to_cv2
from
.preprocess
import
decode_image
from
.visualize
import
visualize_pose
from
paddlehub.module.module
import
moduleinfo
from
paddlehub.module.module
import
runnable
from
paddlehub.module.module
import
serving
...
...
@@ -38,7 +37,7 @@ from paddlehub.module.module import serving
author
=
"paddlepaddle"
,
author_email
=
""
,
summary
=
"PP-TinyPose is a real-time keypoint detection model optimized by PaddleDetecion for mobile devices."
,
version
=
"1.
1
.0"
)
version
=
"1.
2
.0"
)
class
PP_TinyPose
:
"""
PP-TinyPose Model.
...
...
@@ -136,3 +135,21 @@ class PP_TinyPose:
Add the command input options.
"""
self
.
arg_input_group
.
add_argument
(
'--input_path'
,
type
=
str
,
help
=
"path to image."
)
def
create_gradio_app
(
self
):
import
gradio
as
gr
import
tempfile
import
os
from
PIL
import
Image
def
inference
(
image
,
use_gpu
=
False
):
with
tempfile
.
TemporaryDirectory
()
as
temp_dir
:
self
.
predict
(
img
=
image
,
use_gpu
=
use_gpu
,
visualization
=
True
,
save_path
=
temp_dir
)
return
Image
.
open
(
os
.
path
.
join
(
temp_dir
,
os
.
listdir
(
temp_dir
)[
0
]))
interface
=
gr
.
Interface
(
inference
,
[
gr
.
inputs
.
Image
(
type
=
"filepath"
),
gr
.
Checkbox
(
label
=
'use_gpu'
)],
gr
.
outputs
.
Image
(
type
=
"ndarray"
),
title
=
'pp-tinypose'
)
return
interface
modules/image/keypoint_detection/pp-tinypose/test.py
浏览文件 @
9f5454b7
...
...
@@ -4,13 +4,14 @@ import unittest
import
cv2
import
requests
import
paddlehub
as
hub
import
paddlehub
as
hub
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
'0'
class
TestHubModule
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
)
->
None
:
img_url
=
'https://ai-studio-static-online.cdn.bcebos.com/7799a8ccc5f6471b9d56fb6eff94f82a08b70ca2c7594d3f99877e366c0a2619'
...
...
@@ -28,42 +29,26 @@ class TestHubModule(unittest.TestCase):
shutil
.
rmtree
(
'pp_tinypose_output'
)
def
test_predict1
(
self
):
results
=
self
.
module
.
predict
(
img
=
'tests/test.jpg'
,
visualization
=
False
)
results
=
self
.
module
.
predict
(
img
=
'tests/test.jpg'
,
visualization
=
False
)
kps
=
results
[
0
][
1
]
self
.
assertIsInstance
(
kps
,
list
)
def
test_predict2
(
self
):
results
=
self
.
module
.
predict
(
img
=
cv2
.
imread
(
'tests/test.jpg'
),
visualization
=
False
)
results
=
self
.
module
.
predict
(
img
=
cv2
.
imread
(
'tests/test.jpg'
),
visualization
=
False
)
kps
=
results
[
0
][
1
]
self
.
assertIsInstance
(
kps
,
list
)
def
test_predict3
(
self
):
results
=
self
.
module
.
predict
(
img
=
cv2
.
imread
(
'tests/test.jpg'
),
visualization
=
True
)
results
=
self
.
module
.
predict
(
img
=
cv2
.
imread
(
'tests/test.jpg'
),
visualization
=
True
)
kps
=
results
[
0
][
1
]
self
.
assertIsInstance
(
kps
,
list
)
def
test_predict4
(
self
):
self
.
assertRaises
(
FileNotFoundError
,
self
.
module
.
predict
,
img
=
'no.jpg'
)
self
.
assertRaises
(
FileNotFoundError
,
self
.
module
.
predict
,
img
=
'no.jpg'
)
def
test_predict5
(
self
):
self
.
assertRaises
(
cv2
.
error
,
self
.
module
.
predict
,
img
=
[
'test.jpg'
]
)
self
.
assertRaises
(
TypeError
,
self
.
module
.
predict
,
img
=
[
'test.jpg'
])
if
__name__
==
"__main__"
:
unittest
.
main
()
\ No newline at end of file
unittest
.
main
()
modules/image/keypoint_detection/pp-tinypose/visualize.py
浏览文件 @
9f5454b7
...
...
@@ -13,8 +13,8 @@
# limitations under the License.
from
__future__
import
division
import
os
import
math
import
os
import
cv2
import
numpy
as
np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录