未验证 提交 96baa2b8 编写于 作者: jm_12138's avatar jm_12138 提交者: GitHub

update openpose_hands_estimation (#1971)

* update openpose_hands_estimation

* add clean func
上级 d430fc35
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
# limitations under the License. # limitations under the License.
import os import os
import base64
import copy import copy
import time import time
import argparse import argparse
...@@ -26,11 +25,11 @@ import numpy as np ...@@ -26,11 +25,11 @@ import numpy as np
import paddle.nn as nn import paddle.nn as nn
import paddlehub as hub import paddlehub as hub
from skimage.measure import label from skimage.measure import label
from scipy.ndimage.filters import gaussian_filter from scipy.ndimage import gaussian_filter
from paddlehub.module.module import moduleinfo, runnable, serving from paddlehub.module.module import moduleinfo, runnable, serving
import paddlehub.vision.transforms as T import paddlehub.vision.transforms as T
import openpose_hands_estimation.processor as P from . import processor as P
@moduleinfo( @moduleinfo(
...@@ -40,7 +39,7 @@ import openpose_hands_estimation.processor as P ...@@ -40,7 +39,7 @@ import openpose_hands_estimation.processor as P
author_email="", author_email="",
summary="Openpose_hands_estimation is a hand pose estimation model based on Hand Keypoint Detection in \ summary="Openpose_hands_estimation is a hand pose estimation model based on Hand Keypoint Detection in \
Single Images using Multiview Bootstrapping.", Single Images using Multiview Bootstrapping.",
version="1.0.0") version="1.1.0")
class HandPoseModel(nn.Layer): class HandPoseModel(nn.Layer):
""" """
HandposeModel HandposeModel
......
...@@ -154,8 +154,10 @@ ...@@ -154,8 +154,10 @@
初始发布 初始发布
* 1.1.0
* ```shell * ```shell
$ hub install hand_pose_localization==1.0.0 $ hub install hand_pose_localization==1.1.0
``` ```
import os
import shutil
import unittest
import cv2
import requests
import paddlehub as hub
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
class TestHubModule(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
img_url = 'https://unsplash.com/photos/QUVLQPt37n0/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8M3x8cGVyc29uJTIwaGFuZHMlMjBoZWxsb3xlbnwwfHx8fDE2NjE4NjE1MzE&force=true&w=640'
if not os.path.exists('tests'):
os.makedirs('tests')
response = requests.get(img_url)
assert response.status_code == 200, 'Network Error.'
with open('tests/test.jpg', 'wb') as f:
f.write(response.content)
cls.module = hub.Module(name="openpose_hands_estimation")
@classmethod
def tearDownClass(cls) -> None:
shutil.rmtree('tests')
shutil.rmtree('inference')
shutil.rmtree('openpose_body')
shutil.rmtree('openpose_hand')
def test_predict1(self):
results = self.module.predict(
img='tests/test.jpg',
visualization=False
)
kps = results['all_hand_peaks'][0].tolist()
self.assertIsInstance(kps, list)
def test_predict2(self):
results = self.module.predict(
img=cv2.imread('tests/test.jpg'),
visualization=False
)
kps = results['all_hand_peaks'][0].tolist()
self.assertIsInstance(kps, list)
def test_predict3(self):
results = self.module.predict(
img=cv2.imread('tests/test.jpg'),
visualization=True
)
kps = results['all_hand_peaks'][0].tolist()
self.assertIsInstance(kps, list)
def test_predict4(self):
self.assertRaises(
AttributeError,
self.module.predict,
img='no.jpg'
)
def test_predict5(self):
self.assertRaises(
AttributeError,
self.module.predict,
img=['test.jpg']
)
def test_save_inference_model(self):
self.module.save_inference_model('./inference/model')
self.assertTrue(os.path.exists('./inference/model/openpose_hands_estimation.pdmodel'))
self.assertTrue(os.path.exists('./inference/model/openpose_hands_estimation.pdiparams'))
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册