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

update openpose_body_estimation (#1969)

* update openpose_body_estimation

* add clean func
上级 931f1e7c
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
import os import os
import time import time
import copy import copy
import base64
import argparse import argparse
from typing import Union from typing import Union
from collections import OrderedDict from collections import OrderedDict
...@@ -26,7 +25,7 @@ import paddle.nn as nn ...@@ -26,7 +25,7 @@ import paddle.nn as nn
import numpy as np import numpy as np
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_body_estimation.processor as P from . import processor as P
@moduleinfo( @moduleinfo(
...@@ -36,7 +35,7 @@ import openpose_body_estimation.processor as P ...@@ -36,7 +35,7 @@ import openpose_body_estimation.processor as P
author_email="", author_email="",
summary="Openpose_body_estimation is a body pose estimation model based on Realtime Multi-Person 2D Pose \ summary="Openpose_body_estimation is a body pose estimation model based on Realtime Multi-Person 2D Pose \
Estimation using Part Affinity Fields.", Estimation using Part Affinity Fields.",
version="1.0.0") version="1.1.0")
class BodyPoseModel(nn.Layer): class BodyPoseModel(nn.Layer):
""" """
BodyposeModel BodyposeModel
......
import os
import base64 import base64
import math import math
from typing import Callable from typing import Callable
import cv2 import cv2
import numpy as np import numpy as np
from scipy.ndimage.filters import gaussian_filter from scipy.ndimage import gaussian_filter
class PadDownRight: class PadDownRight:
......
...@@ -153,8 +153,10 @@ ...@@ -153,8 +153,10 @@
* 1.0.0 * 1.0.0
初始发布 初始发布
* 1.1.0
* ```shell * ```shell
$ hub install openpose_body_estimation==1.0.0 $ hub install openpose_body_estimation==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://ai-studio-static-online.cdn.bcebos.com/7799a8ccc5f6471b9d56fb6eff94f82a08b70ca2c7594d3f99877e366c0a2619'
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_body_estimation")
@classmethod
def tearDownClass(cls) -> None:
shutil.rmtree('tests')
shutil.rmtree('inference')
shutil.rmtree('openpose_body')
def test_predict1(self):
results = self.module.predict(
img='tests/test.jpg',
visualization=False
)
kps = results['candidate'].tolist()
self.assertIsInstance(kps, list)
def test_predict2(self):
results = self.module.predict(
img=cv2.imread('tests/test.jpg'),
visualization=False
)
kps = results['candidate'].tolist()
self.assertIsInstance(kps, list)
def test_predict3(self):
results = self.module.predict(
img=cv2.imread('tests/test.jpg'),
visualization=True
)
kps = results['candidate'].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_body_estimation.pdmodel'))
self.assertTrue(os.path.exists('./inference/model/openpose_body_estimation.pdiparams'))
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册