• 大小: 105KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-17
  • 语言: Python
  • 标签:

资源简介

人体姿势估计和跟踪的简单基线的TensorFlow实现

资源截图

代码片段和文件信息

#!/usr/bin/python3
# coding=utf-8

import os
import os.path as osp
import numpy as np
import cv2
import json
import pickle
import matplotlib.pyplot as plt

import sys
cur_dir = os.path.dirname(__file__)
sys.path.insert(0 osp.join(cur_dir ‘PythonAPI‘))
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval

class Dataset(object):
    
    dataset_name = ‘COCO‘
    num_kps = 17
    kps_names = [‘nose‘ ‘l_eye‘ ‘r_eye‘ ‘l_ear‘ ‘r_ear‘ ‘l_shoulder‘
    ‘r_shoulder‘ ‘l_elbow‘ ‘r_elbow‘ ‘l_wrist‘ ‘r_wrist‘
    ‘l_hip‘ ‘r_hip‘ ‘l_knee‘ ‘r_knee‘ ‘l_ankle‘ ‘r_ankle‘]
    kps_symmetry = [(1 2) (3 4) (5 6) (7 8) (9 10) (11 12) (13 14) (15 16)]
    kps_lines = [(1 2) (0 1) (0 2) (2 4) (1 3) (6 8) (8 10) (5 7) (7 9) (12 14) (14 16) (11 13) (13 15) (5 6) (11 12)]

    human_det_path = osp.join(‘..‘ ‘data‘ dataset_name ‘dets‘ ‘human_detection.json‘) # human detection result
    img_path = osp.join(‘..‘ ‘data‘ dataset_name ‘images‘)
    train_annot_path = osp.join(‘..‘ ‘data‘ dataset_name ‘annotations‘ ‘person_keypoints_train2017.json‘)
    val_annot_path = osp.join(‘..‘ ‘data‘ dataset_name ‘annotations‘ ‘person_keypoints_val2017.json‘)
    test_annot_path = osp.join(‘..‘ ‘data‘ dataset_name ‘annotations‘ ‘image_info_test-dev2017.json‘)

    def load_train_data(self score=False):
        coco = COCO(self.train_annot_path)
        train_data = []
        for aid in coco.anns.keys():
            ann = coco.anns[aid]
            imgname = ‘train2017/‘ + coco.imgs[ann[‘image_id‘]][‘file_name‘]
            joints = ann[‘keypoints‘]
 
            if (ann[‘image_id‘] not in coco.imgs) or ann[‘iscrowd‘] or (np.sum(joints[2::3]) == 0) or (ann[‘num_keypoints‘] == 0):
                continue
           
            # sanitize bboxes
            x y w h = ann[‘bbox‘]
            img = coco.loadImgs(ann[‘image_id‘])[0]
            width height = img[‘width‘] img[‘height‘]
            x1 = np.max((0 x))
            y1 = np.max((0 y))
            x2 = np.min((width - 1 x1 + np.max((0 w - 1))))
            y2 = np.min((height - 1 y1 + np.max((0 h - 1))))
            if ann[‘area‘] > 0 and x2 >= x1 and y2 >= y1:
                bbox = [x1 y1 x2-x1 y2-y1]
            else:
                continue
            
            if score:
                data = dict(image_id = ann[‘image_id‘] imgpath = imgname bbox=bbox joints=joints score=1)
            else:
                data = dict(image_id = ann[‘image_id‘] imgpath = imgname bbox=bbox joints=joints)

            train_data.append(data)

        return train_data
    
    def load_val_data_with_annot(self):
        coco = COCO(self.val_annot_path)
        val_data = []
        for aid in coco.anns.keys():
            ann = coco.anns[aid]
            if ann[‘image_id‘] not in coco.imgs:
                continue
            imgname = ‘val2017/‘ + coco.imgs[ann[‘image_id‘]][‘file_name‘]
            bbox = ann[‘b

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\
     文件          70  2019-07-22 16:13  TF-SimpleHumanPose-master\.gitignore
     文件       10132  2019-07-22 16:13  TF-SimpleHumanPose-master\README.md
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\data\
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\data\COCO\
     文件        6794  2019-07-22 16:13  TF-SimpleHumanPose-master\data\COCO\dataset.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\data\MPII\
     文件        4596  2019-07-22 16:13  TF-SimpleHumanPose-master\data\MPII\dataset.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\data\PoseTrack\
     文件        7295  2019-07-22 16:13  TF-SimpleHumanPose-master\data\PoseTrack\dataset.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\
     文件         110  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\Makefile
     文件          26  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\__init__.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nets\
     文件           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nets\__init__.py
     文件        8001  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nets\basemodel.py
     文件       11902  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nets\resnet_utils.py
     文件       13646  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nets\resnet_v1.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\
     文件           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\__init__.py
     文件        2305  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\cpu_nms.pyx
     文件         146  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\gpu_nms.hpp
     文件        1179  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\gpu_nms.pyx
     文件        3338  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\nms.py
     文件        5062  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\nms_kernel.cu
     文件        5184  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\nms\setup.py
     目录           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\tfflat\
     文件           0  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\tfflat\__init__.py
     文件       17243  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\tfflat\base.py
     文件       12741  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\tfflat\data_provider.py
     文件        1035  2019-07-22 16:13  TF-SimpleHumanPose-master\lib\tfflat\dpflow.py
............此处省略25个文件信息

评论

共有 条评论