CV:基于keras利用算法MobilenetV2实现局部相似域的多人二维姿态实时估计(詹姆斯扣篮+美女跳舞)

CV:基于keras利用算法MobilenetV2实现局部相似域的多人二维姿态实时估计(詹姆斯扣篮+美女跳舞)


输出结果

论文复现:《Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》
https://arxiv.org/abs/1611.08050

代码实现

更新……

import argparse
import time

import cv2

from processing import extract_parts, draw

from config_reader import config_reader
from model.cmu_model import get_testing_model

#CV:基于keras利用算法MobilenetV2实现局部相似域的多人二维姿态实时估计
#论文复现:《Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
#     parser.add_argument('--image', type=str, required=True, help='input image')
    parser.add_argument('--image', type=str, default='F:/File_Python/Python_example/Human_Posture_Detection/images/ZMS03.jpg', help='input image')
    parser.add_argument('--output', type=str, default='result.png', help='output image')
    parser.add_argument('--model', type=str, default='model/keras_Realtime_Multi_Person_Pose_Estimation_model.h5', help='path to the weights file')

    args = parser.parse_args()
    image_path = args.image
    output = args.output
    keras_weights_file = args.model

    tic = time.time()
    print('start processing...')

    # load model

    # authors of original model don't use
    # vgg normalization (subtracting mean) on input images
    model = get_testing_model()
    model.load_weights(keras_weights_file)

    # load config
    params, model_params = config_reader()

    input_image = cv2.imread(image_path)  # B,G,R order

    body_parts, all_peaks, subset, candidate = extract_parts(input_image, params, model, model_params)
    canvas = draw(input_image, all_peaks, subset, candidate)

    toc = time.time()
    print('processing time is %.5f' % (toc - tic))

    cv2.imshow('keras_Realtime_Multi_Person_Pose_Estimation_model',canvas)
    cv2.waitKey()
    cv2.imwrite(output, canvas)

    cv2.destroyAllWindows()

(0)

相关推荐