目录
输出结果
论文复现:《Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》
https://arxiv.org/abs/1611.08050
代码实现
更新……
1. import argparse 2. import time 3. 4. import cv2 5. 6. from processing import extract_parts, draw 7. 8. from config_reader import config_reader 9. from model.cmu_model import get_testing_model 10. 11. #CV:基于keras利用算法MobilenetV2实现局部相似域的多人二维姿态实时估计 12. #论文复现:《Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》 13. 14. 15. if __name__ == '__main__': 16. parser = argparse.ArgumentParser() 17. # parser.add_argument('--image', type=str, required=True, help='input image') 18. parser.add_argument('--image', type=str, default='F:/File_Python/Python_example/Human_Posture_Detection/images/ZMS03.jpg', help='input image') 19. parser.add_argument('--output', type=str, default='result.png', help='output image') 20. parser.add_argument('--model', type=str, default='model/keras_Realtime_Multi_Person_Pose_Estimation_model.h5', help='path to the weights file') 21. 22. args = parser.parse_args() 23. image_path = args.image 24. output = args.output 25. keras_weights_file = args.model 26. 27. tic = time.time() 28. print('start processing...') 29. 30. # load model 31. 32. # authors of original model don't use 33. # vgg normalization (subtracting mean) on input images 34. model = get_testing_model() 35. model.load_weights(keras_weights_file) 36. 37. # load config 38. params, model_params = config_reader() 39. 40. input_image = cv2.imread(image_path) # B,G,R order 41. 42. body_parts, all_peaks, subset, candidate = extract_parts(input_image, params, model, model_params) 43. canvas = draw(input_image, all_peaks, subset, candidate) 44. 45. toc = time.time() 46. print('processing time is %.5f' % (toc - tic)) 47. 48. cv2.imshow('keras_Realtime_Multi_Person_Pose_Estimation_model',canvas) 49. cv2.waitKey() 50. cv2.imwrite(output, canvas) 51. 52. cv2.destroyAllWindows() 53. 54. 55.