• 大小: 4.28MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: Python
  • 标签:

资源简介

PyTorch实时多人姿态估计项目的实现

资源截图

代码片段和文件信息

# !/usr/bin/env python3
# coding=utf-8
# author=dave.fang@outlook.com
# create=20171225

import cv2
import math
import torch
import torch.nn as nn

from torch import np
from torch.autograd import Variable

from utils import *
from scipy.ndimage.filters import gaussian_filter

# find connection in the specified sequence center 29 is in the position 15
limb_seq = [[2 3] [2 6] [3 4] [4 5] [6 7] [7 8] [2 9] [9 10]
            [10 11] [2 12] [12 13] [13 14] [2 1] [1 15] [15 17]
            [1 16] [16 18] [3 17] [6 18]]

# the middle joints heatmap correpondence
map_ids = [[31 32] [39 40] [33 34] [35 36] [41 42] [43 44] [19 20] [21 22]
           [23 24] [25 26] [27 28] [29 30] [47 48] [49 50] [53 54] [51 52]
           [55 56] [37 38] [45 46]]

# visualize
colors = [[255 0 0] [255 85 0] [255 170 0] [255 255 0] [170 255 0] [85 255 0] [0 255 0]
          [0 255 85] [0 255 170] [0 255 255] [0 170 255] [0 85 255] [0 0 255] [85 0 255]
          [170 0 255] [255 0 255] [255 0 170] [255 0 85]]


class PoseEstimation(nn.Module):
    def __init__(self model_dict):
        super(PoseEstimation self).__init__()

        self.model0 = model_dict[‘block_0‘]
        self.model1_1 = model_dict[‘block1_1‘]
        self.model2_1 = model_dict[‘block2_1‘]
        self.model3_1 = model_dict[‘block3_1‘]
        self.model4_1 = model_dict[‘block4_1‘]
        self.model5_1 = model_dict[‘block5_1‘]
        self.model6_1 = model_dict[‘block6_1‘]

        self.model1_2 = model_dict[‘block1_2‘]
        self.model2_2 = model_dict[‘block2_2‘]
        self.model3_2 = model_dict[‘block3_2‘]
        self.model4_2 = model_dict[‘block4_2‘]
        self.model5_2 = model_dict[‘block5_2‘]
        self.model6_2 = model_dict[‘block6_2‘]

    def forward(self x):
        out1 = self.model0(x)

        out1_1 = self.model1_1(out1)
        out1_2 = self.model1_2(out1)
        out2 = torch.cat([out1_1 out1_2 out1] 1)

        out2_1 = self.model2_1(out2)
        out2_2 = self.model2_2(out2)
        out3 = torch.cat([out2_1 out2_2 out1] 1)

        out3_1 = self.model3_1(out3)
        out3_2 = self.model3_2(out3)
        out4 = torch.cat([out3_1 out3_2 out1] 1)

        out4_1 = self.model4_1(out4)
        out4_2 = self.model4_2(out4)
        out5 = torch.cat([out4_1 out4_2 out1] 1)

        out5_1 = self.model5_1(out5)
        out5_2 = self.model5_2(out5)
        out6 = torch.cat([out5_1 out5_2 out1] 1)

        out6_1 = self.model6_1(out6)
        out6_2 = self.model6_2(out6)

        return out6_1 out6_2


def make_layers(layer_dict):
    layers = []

    for i in range(len(layer_dict) - 1):
        layer = layer_dict[i]
        for k in layer:
            v = layer[k]
            if ‘pool‘ in k:
                layers += [nn.MaxPool2d(kernel_size=v[0] stride=v[1] padding=v[2])]
            else:
                conv2d = nn.Conv2d(in_channels=v[

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-12-26 06:44  pytorch-pose-estimation-master\
     文件        1157  2017-12-26 06:44  pytorch-pose-estimation-master\.gitignore
     文件         842  2017-12-26 06:44  pytorch-pose-estimation-master\README.md
     文件     1787007  2017-12-26 06:44  pytorch-pose-estimation-master\demo_pic.ipynb
     文件     2425695  2017-12-26 06:44  pytorch-pose-estimation-master\demo_pic_detail.ipynb
     文件     1799966  2017-12-26 06:44  pytorch-pose-estimation-master\demo_pic_func.ipynb
     目录           0  2017-12-26 06:44  pytorch-pose-estimation-master\models\
     文件        1157  2017-12-26 06:44  pytorch-pose-estimation-master\models\.gitignore
     文件       15535  2017-12-26 06:44  pytorch-pose-estimation-master\pose_estimation.py
     文件        1031  2017-12-26 06:44  pytorch-pose-estimation-master\utils.py

评论

共有 条评论