id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
12,906 | import torch
import torch.nn as nn
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1,
base_width=64, dilation=1, norm_layer=None):
super(BasicBlock, self).__init__()
if norm_layer is None:
norm_layer =... | r"""ResNet-34 model from `"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,907 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""ResNet-50 model from `"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,908 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""ResNet-101 model from `"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,909 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""ResNet-152 model from `"Deep Residual Learning for Image Recognition" <https://arxiv.org/pdf/1512.03385.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,910 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""ResNeXt-50 32x4d model from `"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,911 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""ResNeXt-101 32x8d model from `"Aggregated Residual Transformation for Deep Neural Networks" <https://arxiv.org/pdf/1611.05431.pdf>`_ Args: pretrained (bool): If True, returns a model pre-trained on ImageNet progress (bool): If True, displays a progress bar of the download to stderr |
12,912 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""Wide ResNet-50-2 model from `"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_ The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-20... |
12,913 | import torch
import torch.nn as nn
class Bottleneck(nn.Module):
# Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2)
# while original implementation places the stride at the first 1x1 convolution(self.conv1)
# according to "Deep residual learning for image recognitio... | r"""Wide ResNet-101-2 model from `"Wide Residual Networks" <https://arxiv.org/pdf/1605.07146.pdf>`_ The model is the same as ResNet except for the bottleneck number of channels which is twice larger in every block. The number of channels in outer 1x1 convolutions is the same, e.g. last block in ResNet-50 has 2048-512-2... |
12,914 | import torch
The provided code snippet includes necessary dependencies for implementing the `interpolate` function. Write a Python function `def interpolate(feat, uv)` to solve the following problem:
:param feat: [B, C, H, W] image features :param uv: [B, 2, N] uv coordinates in the image plane, range [-1, 1] :return:... | :param feat: [B, C, H, W] image features :param uv: [B, 2, N] uv coordinates in the image plane, range [-1, 1] :return: [B, C, N] image features at the uv coordinates |
12,915 | import torch
import torch.nn.functional as F
def _softmax(tensor, temperature, dim=-1):
return F.softmax(tensor * temperature, dim=dim)
def softargmax1d(
heatmaps,
temperature=None,
normalize_keypoints=True,
):
dtype, device = heatmaps.dtype, heatmaps.device
if temperature is None:
... | null |
12,916 | import torch
import torch.nn.functional as F
def _softmax(tensor, temperature, dim=-1):
return F.softmax(tensor * temperature, dim=dim)
def softargmax2d(
heatmaps,
temperature=None,
normalize_keypoints=True,
):
dtype, device = heatmaps.dtype, heatmaps.device
if temperature is None:
... | null |
12,917 | import torch
import torch.nn.functional as F
def _softmax(tensor, temperature, dim=-1):
return F.softmax(tensor * temperature, dim=dim)
def softargmax3d(
heatmaps,
temperature=None,
normalize_keypoints=True,
):
dtype, device = heatmaps.dtype, heatmaps.device
if temperature is None:
... | null |
12,918 | import torch
import torch.nn.functional as F
The provided code snippet includes necessary dependencies for implementing the `get_heatmap_preds` function. Write a Python function `def get_heatmap_preds(batch_heatmaps, normalize_keypoints=True)` to solve the following problem:
get predictions from score maps heatmaps: n... | get predictions from score maps heatmaps: numpy.ndarray([batch_size, num_joints, height, width]) |
12,919 | import torch
import torch.nn as nn
from .. import config
from .smpl_head import SMPL
The provided code snippet includes necessary dependencies for implementing the `perspective_projection` function. Write a Python function `def perspective_projection(points, rotation, translation, cam_intrinsics)` to solve the followi... | This function computes the perspective projection of a set of points. Input: points (bs, N, 3): 3D points rotation (bs, 3, 3): Camera rotation translation (bs, 3): Camera translation cam_intrinsics (bs, 3, 3): Camera intrinsics |
12,920 | import torch
import torch.nn as nn
from .. import config
from .smpl_head import SMPL
def convert_pare_to_full_img_cam(
pare_cam, bbox_height, bbox_center,
img_w, img_h, focal_length, crop_res=224):
# Converts weak perspective camera estimated by PARE in
# bbox coords to perspective camera in fu... | null |
12,921 | import math
import torch
import numpy as np
import torch.nn as nn
from ..config import SMPL_MEAN_PARAMS
from ..utils.geometry import rot6d_to_rotmat, rotmat_to_rot6d
def keep_variance(x, min_variance):
return x + min_variance | null |
12,922 | import os
import time
import yaml
import shutil
import argparse
import operator
import itertools
from os.path import join
from functools import reduce
from yacs.config import CfgNode as CN
from typing import Dict, List, Union, Any
hparams = CN()
hparams.LOG_DIR = 'logs/experiments'
hparams.METHOD = 'pare'
hparams.EXP_N... | null |
12,923 | import os
import time
import yaml
import shutil
import argparse
import operator
import itertools
from os.path import join
from functools import reduce
from yacs.config import CfgNode as CN
from typing import Dict, List, Union, Any
hparams = CN()
hparams.LOG_DIR = 'logs/experiments'
hparams.METHOD = 'pare'
hparams.EXP_N... | null |
12,924 | import os
import torch
import torch.nn as nn
from .config import update_hparams
from .head import PareHead
from .backbone.utils import get_backbone_info
from .backbone.hrnet import hrnet_w32
from os.path import join
from easymocap.multistage.torchgeometry import rotation_matrix_to_axis_angle
import cv2
from ..basetopdo... | null |
12,925 | import torch
import numpy as np
from torch.nn import functional as F
The provided code snippet includes necessary dependencies for implementing the `rot6d_to_rotmat` function. Write a Python function `def rot6d_to_rotmat(x)` to solve the following problem:
Convert 6D rotation representation to 3x3 rotation matrix. Bas... | Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 Input: (B,6) Batch of 6-D rotation representations Output: (B,3,3) Batch of corresponding rotation matrices |
12,926 | import torch
import numpy as np
from torch.nn import functional as F
def rotmat_to_rot6d(x):
rotmat = x.reshape(-1, 3, 3)
rot6d = rotmat[:, :, :2].reshape(x.shape[0], -1)
return rot6d | null |
12,927 | import torch
import numpy as np
from torch.nn import functional as F
def quaternion_to_angle_axis(quaternion: torch.Tensor) -> torch.Tensor:
"""
This function is borrowed from https://github.com/kornia/kornia
Convert quaternion vector to angle axis of rotation.
Adapted from ceres C++ library: ceres-solv... | This function is borrowed from https://github.com/kornia/kornia Convert 3x4 rotation matrix to Rodrigues vector Args: rotation_matrix (Tensor): rotation matrix. Returns: Tensor: Rodrigues vector transformation. Shape: - Input: :math:`(N, 3, 4)` - Output: :math:`(N, 3)` Example: >>> input = torch.rand(2, 3, 4) # Nx4x4 >... |
12,928 | import torch
import numpy as np
from torch.nn import functional as F
def convert_perspective_to_weak_perspective(
perspective_camera,
focal_length=5000.,
img_res=224,
):
# Convert Weak Perspective Camera [s, tx, ty] to camera translation [tx, ty, tz]
# in 3D given the bounding box size
... | null |
12,929 | import torch
import numpy as np
from torch.nn import functional as F
The provided code snippet includes necessary dependencies for implementing the `perspective_projection` function. Write a Python function `def perspective_projection(points, rotation, translation, focal_length, camera_cente... | This function computes the perspective projection of a set of points. Input: points (bs, N, 3): 3D points rotation (bs, 3, 3): Camera rotation translation (bs, 3): Camera translation focal_length (bs,) or scalar: Focal length camera_center (bs, 2): Camera center |
12,930 | import torch
import numpy as np
from torch.nn import functional as F
def convert_weak_perspective_to_perspective(
weak_perspective_camera,
focal_length=5000.,
img_res=224,
):
# Convert Weak Perspective Camera [s, tx, ty] to camera translation [tx, ty, tz]
# in 3D given the bounding box s... | This function computes the perspective projection of a set of points. Input: points (bs, N, 3): 3D points rotation (bs, 3, 3): Camera rotation translation (bs, 3): Camera translation focal_length (bs,) or scalar: Focal length camera_center (bs, 2): Camera center |
12,931 | import torch
import numpy as np
from torch.nn import functional as F
def estimate_translation_np(S, joints_2d, joints_conf, focal_length=5000., img_size=224.):
"""Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d.
Input:
S: (25, 3) 3D joint locations
joint... | Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d. Input: S: (B, 49, 3) 3D joint locations joints: (B, 49, 3) 2D joint locations and confidence Returns: (B, 3) camera translation vectors |
12,932 | import torch
import numpy as np
from torch.nn import functional as F
def estimate_translation_np(S, joints_2d, joints_conf, focal_length=5000., img_size=224.):
"""Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d.
Input:
S: (25, 3) 3D joint locations
joint... | Find camera translation that brings 3D joints S closest to 2D the corresponding joints_2d. Input: S: (B, 49, 3) 3D joint locations joints: (B, 49, 3) 2D joint locations and confidence Returns: (B, 3) camera translation vectors |
12,933 | import torch
import numpy as np
from torch.nn import functional as F
def get_coord_maps(size=56):
xx_ones = torch.ones([1, size], dtype=torch.int32)
xx_ones = xx_ones.unsqueeze(-1)
xx_range = torch.arange(size, dtype=torch.int32).unsqueeze(0)
xx_range = xx_range.unsqueeze(1)
xx_channel = torch.ma... | null |
12,934 | import torch
import numpy as np
from torch.nn import functional as F
def look_at(eye, at=np.array([0, 0, 0]), up=np.array([0, 0, 1]), eps=1e-5):
at = at.astype(float).reshape(1, 3)
up = up.astype(float).reshape(1, 3)
eye = eye.reshape(-1, 3)
up = up.repeat(eye.shape[0] // up.shape[0], axis=0)
eps = ... | null |
12,935 | import torch
import numpy as np
from torch.nn import functional as F
def batch_rot2aa(Rs):
def batch_rodrigues(theta):
def rectify_pose(camera_r, body_aa, rotate_x=False):
body_r = batch_rodrigues(body_aa).reshape(-1,3,3)
if rotate_x:
rotate_x = torch.tensor([[[1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, ... | null |
12,936 | import torch
import numpy as np
from torch.nn import functional as F
def euler_to_quaternion(r):
x = r[..., 0]
y = r[..., 1]
z = r[..., 2]
z = z/2.0
y = y/2.0
x = x/2.0
cz = torch.cos(z)
sz = torch.sin(z)
cy = torch.cos(y)
sy = torch.sin(y)
cx = torch.cos(x)
sx = torch.si... | null |
12,937 | import torch
import numpy as np
from torch.nn import functional as F
The provided code snippet includes necessary dependencies for implementing the `euler_angles_from_rotmat` function. Write a Python function `def euler_angles_from_rotmat(R)` to solve the following problem:
computer euler angles for rotation around x,... | computer euler angles for rotation around x, y, z axis from rotation amtrix R: 4x4 rotation matrix https://www.gregslabaugh.net/publications/euler.pdf |
12,938 | import numpy as np
def keypoint_hflip(kp, img_width):
# Flip a keypoint horizontally around the y-axis
# kp N,2
if len(kp.shape) == 2:
kp[:,0] = (img_width - 1.) - kp[:,0]
elif len(kp.shape) == 3:
kp[:, :, 0] = (img_width - 1.) - kp[:, :, 0]
return kp | null |
12,939 | import numpy as np
def convert_kps(joints2d, src, dst):
src_names = eval(f'get_{src}_joint_names')()
dst_names = eval(f'get_{dst}_joint_names')()
out_joints2d = np.zeros((joints2d.shape[0], len(dst_names), joints2d.shape[-1]))
for idx, jn in enumerate(dst_names):
if jn in src_names:
... | null |
12,940 | import numpy as np
def get_perm_idxs(src, dst):
src_names = eval(f'get_{src}_joint_names')()
dst_names = eval(f'get_{dst}_joint_names')()
idxs = [src_names.index(h) for h in dst_names if h in src_names]
return idxs | null |
12,941 | import numpy as np
def get_mpii3d_test_joint_names():
return [
'headtop', # 'head_top',
'neck',
'rshoulder',# 'right_shoulder',
'relbow',# 'right_elbow',
'rwrist',# 'right_wrist',
'lshoulder',# 'left_shoulder',
'lelbow', # 'left_elbow',
'lwrist', # 'l... | null |
12,942 | import numpy as np
def get_mpii3d_joint_names():
return [
'spine3', # 0,
'spine4', # 1,
'spine2', # 2,
'Spine (H36M)', #'spine', # 3,
'hip', # 'pelvis', # 4,
'neck', # 5,
'Head (H36M)', # 'head', # 6,
"headtop", # 'head_top', # 7,
'left_clavic... | null |
12,943 | import numpy as np
def get_insta_joint_names():
return [
'OP RHeel',
'OP RKnee',
'OP RHip',
'OP LHip',
'OP LKnee',
'OP LHeel',
'OP RWrist',
'OP RElbow',
'OP RShoulder',
'OP LShoulder',
'OP LElbow',
'OP LWrist',
... | null |
12,944 | import numpy as np
def get_mmpose_joint_names():
# this naming is for the first 23 joints of MMPose
# does not include hands and face
return [
'OP Nose', # 1
'OP LEye', # 2
'OP REye', # 3
'OP LEar', # 4
'OP REar', # 5
'OP LShoulder', # 6
'OP RShoulder... | null |
12,945 | import numpy as np
def get_insta_skeleton():
return np.array(
[
[0 , 1],
[1 , 2],
[2 , 3],
[3 , 4],
[4 , 5],
[6 , 7],
[7 , 8],
[8 , 9],
[9 ,10],
[2 , 8],
[3 , 9],
... | null |
12,946 | import numpy as np
def get_staf_skeleton():
return np.array(
[
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[1, 5],
[5, 6],
[6, 7],
[1, 8],
[8, 9],
[9, 10],
[10, 11],
[8, 12],
... | null |
12,947 | import numpy as np
def get_staf_joint_names():
return [
'OP Nose', # 0,
'OP Neck', # 1,
'OP RShoulder', # 2,
'OP RElbow', # 3,
'OP RWrist', # 4,
'OP LShoulder', # 5,
'OP LElbow', # 6,
'OP LWrist', # 7,
'OP MidHip', # 8,
'OP RHip', # 9,... | null |
12,948 | import numpy as np
def get_spin_op_joint_names():
return [
'OP Nose', # 0
'OP Neck', # 1
'OP RShoulder', # 2
'OP RElbow', # 3
'OP RWrist', # 4
'OP LShoulder', # 5
'OP LElbow', # 6
'OP LWrist', # 7
'OP MidH... | null |
12,949 | import numpy as np
def get_openpose_joint_names():
return [
'OP Nose', # 0
'OP Neck', # 1
'OP RShoulder', # 2
'OP RElbow', # 3
'OP RWrist', # 4
'OP LShoulder', # 5
'OP LElbow', # 6
'OP LWrist', # 7
'OP Mid... | null |
12,950 | import numpy as np
def get_spin_joint_names():
return [
'OP Nose', # 0
'OP Neck', # 1
'OP RShoulder', # 2
'OP RElbow', # 3
'OP RWrist', # 4
'OP LShoulder', # 5
'OP LElbow', # 6
'OP LWrist', # 7
'OP MidHip'... | null |
12,951 | import numpy as np
def get_muco3dhp_joint_names():
return [
'headtop',
'thorax',
'rshoulder',
'relbow',
'rwrist',
'lshoulder',
'lelbow',
'lwrist',
'rhip',
'rknee',
'rankle',
'lhip',
'lknee',
'lankle',
... | null |
12,952 | import numpy as np
def get_h36m_joint_names():
return [
'hip', # 0
'lhip', # 1
'lknee', # 2
'lankle', # 3
'rhip', # 4
'rknee', # 5
'rankle', # 6
'Spine (H36M)', # 7
'neck', # 8
'Head (H36M)', # 9
'headtop', # 10
... | null |
12,953 | import numpy as np
def get_spin_skeleton():
return np.array(
[
[0 , 1],
[1 , 2],
[2 , 3],
[3 , 4],
[1 , 5],
[5 , 6],
[6 , 7],
[1 , 8],
[8 , 9],
[9 ,10],
[10,11],
[... | null |
12,954 | import numpy as np
def get_openpose_skeleton():
return np.array(
[
[0 , 1],
[1 , 2],
[2 , 3],
[3 , 4],
[1 , 5],
[5 , 6],
[6 , 7],
[1 , 8],
[8 , 9],
[9 ,10],
[10,11],
... | null |
12,955 | import numpy as np
def get_posetrack_joint_names():
return [
"nose",
"neck",
"headtop",
"lear",
"rear",
"lshoulder",
"rshoulder",
"lelbow",
"relbow",
"lwrist",
"rwrist",
"lhip",
"rhip",
"lknee",
... | null |
12,956 | import numpy as np
def get_posetrack_original_kp_names():
return [
'nose',
'head_bottom',
'head_top',
'left_ear',
'right_ear',
'left_shoulder',
'right_shoulder',
'left_elbow',
'right_elbow',
'left_wrist',
'right_wrist',
... | null |
12,957 | import numpy as np
def get_pennaction_joint_names():
return [
"headtop", # 0
"lshoulder", # 1
"rshoulder", # 2
"lelbow", # 3
"relbow", # 4
"lwrist", # 5
"rwrist", # 6
"lhip" , # 7
"rhip" , # 8
"lknee", # 9
"rknee"... | null |
12,958 | import numpy as np
def get_common_joint_names():
return [
"rankle", # 0 "lankle", # 0
"rknee", # 1 "lknee", # 1
"rhip", # 2 "lhip", # 2
"lhip", # 3 "rhip", # 3
"lknee", # 4 "rknee", # 4
"lankle", # 5 "rankle", # 5... | null |
12,959 | import numpy as np
def get_common_paper_joint_names():
return [
"Right Ankle", # 0 "lankle", # 0
"Right Knee", # 1 "lknee", # 1
"Right Hip", # 2 "lhip", # 2
"Left Hip", # 3 "rhip", # 3
"Left Knee", # 4 "rknee", # 4
"Left... | null |
12,960 | import numpy as np
def get_common_skeleton():
return np.array(
[
[ 0, 1 ],
[ 1, 2 ],
[ 3, 4 ],
[ 4, 5 ],
[ 6, 7 ],
[ 7, 8 ],
[ 8, 2 ],
[ 8, 9 ],
[ 9, 3 ],
[ 2, 3 ],
[ 8, 12],
... | null |
12,961 | import numpy as np
def get_coco_joint_names():
return [
"nose", # 0
"leye", # 1
"reye", # 2
"lear", # 3
"rear", # 4
"lshoulder", # 5
"rshoulder", # 6
"lelbow", # 7
"relbow", # 8
"lwrist", # 9
"... | null |
12,962 | import numpy as np
def get_ochuman_joint_names():
return [
'rshoulder',
'relbow',
'rwrist',
'lshoulder',
'lelbow',
'lwrist',
'rhip',
'rknee',
'rankle',
'lhip',
'lknee',
'lankle',
'headtop',
'neck',
... | null |
12,963 | import numpy as np
def get_crowdpose_joint_names():
return [
'lshoulder',
'rshoulder',
'lelbow',
'relbow',
'lwrist',
'rwrist',
'lhip',
'rhip',
'lknee',
'rknee',
'lankle',
'rankle',
'headtop',
'neck'
... | null |
12,964 | import numpy as np
def get_coco_skeleton():
# 0 - nose,
# 1 - leye,
# 2 - reye,
# 3 - lear,
# 4 - rear,
# 5 - lshoulder,
# 6 - rshoulder,
# 7 - lelbow,
# 8 - relbow,
# 9 - lwrist,
# 10 - rwrist,
# 11 - lhip,
# 12 - rhip,
# 13 - lknee,
# 14 - rknee,
... | null |
12,965 | import numpy as np
def get_mpii_joint_names():
return [
"rankle", # 0
"rknee", # 1
"rhip", # 2
"lhip", # 3
"lknee", # 4
"lankle", # 5
"hip", # 6
"thorax", # 7
"neck", # 8
"headtop", # 9
"... | null |
12,966 | import numpy as np
def get_mpii_skeleton():
# 0 - rankle,
# 1 - rknee,
# 2 - rhip,
# 3 - lhip,
# 4 - lknee,
# 5 - lankle,
# 6 - hip,
# 7 - thorax,
# 8 - neck,
# 9 - headtop,
# 10 - rwrist,
# 11 - relbow,
# 12 - rshoulder,
# 13 - lshoulder,
# 14 - le... | null |
12,967 | import numpy as np
def get_aich_joint_names():
return [
"rshoulder", # 0
"relbow", # 1
"rwrist", # 2
"lshoulder", # 3
"lelbow", # 4
"lwrist", # 5
"rhip", # 6
"rknee", # 7
"rankle", # 8
"lhip", # 9
"... | null |
12,968 | import numpy as np
def get_aich_skeleton():
# 0 - rshoulder,
# 1 - relbow,
# 2 - rwrist,
# 3 - lshoulder,
# 4 - lelbow,
# 5 - lwrist,
# 6 - rhip,
# 7 - rknee,
# 8 - rankle,
# 9 - lhip,
# 10 - lknee,
# 11 - lankle,
# 12 - headtop,
# 13 - neck,
return... | null |
12,969 | import numpy as np
def get_3dpw_joint_names():
return [
"nose", # 0
"thorax", # 1
"rshoulder", # 2
"relbow", # 3
"rwrist", # 4
"lshoulder", # 5
"lelbow", # 6
"lwrist", # 7
"rhip", # 8
"rknee", # 9
"... | null |
12,970 | import numpy as np
def get_3dpw_skeleton():
return np.array(
[
[ 0, 1 ],
[ 1, 2 ],
[ 2, 3 ],
[ 3, 4 ],
[ 1, 5 ],
[ 5, 6 ],
[ 6, 7 ],
[ 2, 8 ],
[ 5, 11],
[ 8, 11],
[ 8, 9 ],
... | null |
12,971 | import numpy as np
def get_smplcoco_joint_names():
return [
"rankle", # 0
"rknee", # 1
"rhip", # 2
"lhip", # 3
"lknee", # 4
"lankle", # 5
"rwrist", # 6
"relbow", # 7
"rshoulder", # 8
"lshoulder", # 9
... | null |
12,972 | import numpy as np
def get_smplcoco_skeleton():
return np.array(
[
[ 0, 1 ],
[ 1, 2 ],
[ 3, 4 ],
[ 4, 5 ],
[ 6, 7 ],
[ 7, 8 ],
[ 8, 12],
[12, 9 ],
[ 9, 10],
[10, 11],
[12, 13]... | null |
12,973 | import numpy as np
def get_smpl_joint_names():
return [
'hips', # 0
'leftUpLeg', # 1
'rightUpLeg', # 2
'spine', # 3
'leftLeg', # 4
'rightLeg', # 5
'spine1', # 6
'leftFoot', # 7
'ri... | null |
12,974 | import numpy as np
def get_smpl_paper_joint_names():
return [
'Hips', # 0
'Left Hip', # 1
'Right Hip', # 2
'Spine', # 3
'Left Knee', # 4
'Right Knee', # 5
'Spine_1', # 6
'Left Ankle', # 7
... | null |
12,975 | import numpy as np
def get_smpl_neighbor_triplets():
return [
[ 0, 1, 2 ], # 0
[ 1, 4, 0 ], # 1
[ 2, 0, 5 ], # 2
[ 3, 0, 6 ], # 3
[ 4, 7, 1 ], # 4
[ 5, 2, 8 ], # 5
[ 6, 3, 9 ], # 6
[ 7, 10, 4 ], # 7
[ 8, 5, 11], # 8
[ ... | null |
12,976 | import numpy as np
def get_smpl_skeleton():
return np.array(
[
[ 0, 1 ],
[ 0, 2 ],
[ 0, 3 ],
[ 1, 4 ],
[ 2, 5 ],
[ 3, 6 ],
[ 4, 7 ],
[ 5, 8 ],
[ 6, 9 ],
[ 7, 10],
[ 8, 11],
... | null |
12,977 | import numpy as np
def map_spin_joints_to_smpl():
# this function primarily will be used to copy 2D keypoint
# confidences to pose parameters
return [
[(39, 27, 28), 0], # hip,lhip,rhip->hips
[(28,), 1], # lhip->leftUpLeg
[(27,), 2], # rhip->rightUpLeg
[(41, 27, 28, 39), ... | null |
12,978 | import numpy as np
def map_smpl_to_common():
return [
[(11, 8), 0], # rightToe, rightFoot -> rankle
[(5,), 1], # rightleg -> rknee,
[(2,), 2], # rhip
[(1,), 3], # lhip
[(4,), 4], # leftLeg -> lknee
[(10, 7), 5], # lefttoe, leftfoot -> lankle
[(21, 23), 6], # ... | null |
12,979 | import numpy as np
def relation_among_spin_joints():
# this function primarily will be used to copy 2D keypoint
# confidences to 3D joints
return [
[(), 25],
[(), 26],
[(39,), 27],
[(39,), 28],
[(), 29],
[(), 30],
[(), 31],
[(), 32],
[... | null |
12,980 | from typing import Any
import numpy as np
from easymocap.mytools.debug_utils import mywarn, log
def solve_translation(X, x, K):
A = np.zeros((2*X.shape[0], 3))
b = np.zeros((2*X.shape[0], 1))
fx, fy = K[0, 0], K[1, 1]
cx, cy = K[0, 2], K[1, 2]
for nj in range(X.shape[0]):
A[2*nj, 0] = 1
... | null |
12,981 | import numpy as np
import itertools
from easymocap.mytools.triangulator import batch_triangulate, project_points
from easymocap.mytools.debug_utils import log, mywarn, myerror
def project_and_distance(kpts3d, RT, kpts2d):
kpts_proj = project_points(kpts3d, RT)
# 1. distance between input and projection
conf... | null |
12,982 | import numpy as np
from itertools import combinations
from easymocap.mytools.camera_utils import Undistort
from easymocap.mytools.triangulator import iterative_triangulate
The provided code snippet includes necessary dependencies for implementing the `batch_triangulate` function. Write a Python function `def batch_tri... | triangulate the keypoints of whole body Args: keypoints_ (nViews, nJoints, 3): 2D detections Pall (nViews, 3, 4): projection matrix of each view min_view (int, optional): min view for visible points. Defaults to 2. Returns: keypoints3d: (nJoints, 4) |
12,983 | import numpy as np
from itertools import combinations
from easymocap.mytools.camera_utils import Undistort
from easymocap.mytools.triangulator import iterative_triangulate
def project_wo_dist(keypoints, RT, einsum='vab,kb->vka'):
homo = np.concatenate([keypoints[..., :3], np.ones_like(keypoints[..., :1])], axis=-1... | null |
12,984 | from typing import Any
import numpy as np
import cv2
def views_from_dimGroups(dimGroups):
views = np.zeros(dimGroups[-1], dtype=np.int)
for nv in range(len(dimGroups) - 1):
views[dimGroups[nv]:dimGroups[nv+1]] = nv
return views | null |
12,985 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
def dict_of_numpy_to_tensor(body_params, device):
params_ = {}
for key, val in body_params.items():
if isinstance(val, dict):
params_[key] = dict_of_numpy_to_ten... | null |
12,986 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
def dict_of_tensor_to_numpy(body_params):
params_ = {}
for key, val in body_params.items():
if isinstance(val, dict):
params_[key] = dict_of_tensor_to_numpy(val)... | null |
12,987 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
class LBFGS(Optimizer):
"""Implements L-BFGS algorithm, heavily inspired by `minFunc
<https://www.cs.ubc.ca/~schmidtm/Software/minFunc.html>`.
.. warning::
This optimiz... | null |
12,988 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
def grad_require(params, flag=False):
if isinstance(params, list):
for par in params:
par.requires_grad = flag
elif isinstance(params, dict):
for key, p... | null |
12,989 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
def make_closure(optimizer, model, params, infos, loss, device):
loss_func = {}
for key, val in loss.items():
loss_func[key] = load_object(val['module'], val['args'])
... | null |
12,990 | import torch
import torch.nn as nn
from easymocap.config import Config, load_object
from easymocap.mytools.debug_utils import log
def rel_change(prev_val, curr_val):
return (prev_val - curr_val) / max([1e-5, abs(prev_val), abs(curr_val)]) | null |
12,991 | import numpy as np
import cv2
from easymocap.mytools.camera_utils import Undistort
from easymocap.mytools.debug_utils import mywarn
from .triangulate import batch_triangulate, project_wo_dist
from collections import defaultdict
def LOG_ARRAY(array2d, format='{:>8.2f} '):
res = ''
for i in range(array2d.shape[0... | null |
12,992 | import numpy as np
import cv2
from easymocap.mytools.camera_utils import Undistort
from easymocap.mytools.debug_utils import log, mywarn, myerror
from .iterative_triangulate import iterative_triangulate
from easymocap.mytools.triangulator import project_points, batch_triangulate
from easymocap.mytools.timer import Time... | null |
12,993 | import os
import torch
import numpy as np
from easymocap.bodymodel.smpl import SMPLModel
from easymocap.mytools.debug_utils import log
def try_to_download_SMPL(model_dir):
cmd = 'wget https://www.dropbox.com/s/aeulffqzb3zmh8x/pare-github-data.zip'
os.system(cmd)
os.makedirs(model_dir, exist_ok=True)
cm... | null |
12,994 | import os
from typing import Any
import numpy as np
import cv2
from os.path import join
from easymocap.mytools.vis_base import plot_keypoints_auto, merge, plot_bbox, get_rgb, plot_cross
from easymocap.datasets.base import add_logo
from easymocap.mytools.camera_utils import Undistort
def projectPoints(k3d, camera):
... | null |
12,995 | from tqdm import tqdm
import cv2
import os
from easymocap.visualize.pyrender_wrapper import plot_meshes
from os.path import join
import numpy as np
from easymocap.datasets.base import add_logo
from easymocap.mytools.vis_base import merge, plot_bbox
from easymocap.mytools.camera_utils import Undistort
from .vis import V... | null |
12,996 | from easymocap.mytools.camera_utils import read_cameras
from easymocap.mytools.debug_utils import log, myerror, mywarn
from easymocap.mytools.file_utils import read_json
from .basedata import ImageDataBase, read_mv_images, find_best_people, find_all_people
import os
from os.path import join
import numpy as np
import cv... | null |
12,997 | from easymocap.mytools.camera_utils import read_cameras
from easymocap.mytools.debug_utils import log, myerror, mywarn
from easymocap.mytools.file_utils import read_json
from .basedata import ImageDataBase, read_mv_images, find_best_people, find_all_people
import os
from os.path import join
import numpy as np
import cv... | null |
12,998 | from easymocap.mytools.camera_utils import read_cameras
from easymocap.mytools.debug_utils import log, myerror, mywarn
from easymocap.mytools.file_utils import read_json
from .basedata import ImageDataBase, read_mv_images, find_best_people, find_all_people
import os
from os.path import join
import numpy as np
import cv... | null |
12,999 | from easymocap.mytools.camera_utils import read_cameras
from easymocap.mytools.debug_utils import log, myerror, mywarn
from easymocap.mytools.file_utils import read_json
from .basedata import ImageDataBase, read_mv_images, find_best_people, find_all_people
import os
from os.path import join
import numpy as np
import cv... | null |
13,000 | from easymocap.mytools.camera_utils import read_cameras
from easymocap.mytools.debug_utils import log, myerror, mywarn
from easymocap.mytools.file_utils import read_json
from .basedata import ImageDataBase, read_mv_images, find_best_people, find_all_people
import os
from os.path import join
import numpy as np
import cv... | null |
13,001 | import os
from os.path import join
import numpy as np
import cv2
from easymocap.mytools.debug_utils import log, myerror, mywarn
def log(text):
myprint(text, 'info')
def read_mv_images(root, root_images, ext, subs):
assert os.path.exists(os.path.join(root, root_images)), f'root {root}/{root_images} not exists'... | null |
13,002 | import os
from os.path import join
import numpy as np
import cv2
from easymocap.mytools.debug_utils import log, myerror, mywarn
def FloatArray(x):
return np.array(x, dtype=np.float32)
def find_best_people(annots):
if len(annots) == 0:
return {}
# TODO: find the best
annot = annots[0]
bbox =... | null |
13,003 | import os
from os.path import join
import numpy as np
import cv2
from easymocap.mytools.debug_utils import log, myerror, mywarn
def FloatArray(x):
return np.array(x, dtype=np.float32)
def find_all_people(annots):
if len(annots) == 0:
return {}
bbox = FloatArray([annot['bbox'] for annot in annots])
... | null |
13,004 | from tqdm import tqdm
import numpy as np
import os
from os.path import join
from glob import glob
from ..affinity.affinity import getDimGroups
from ..affinity.matchSVT import matchSVT
from ..mytools.reader import read_keypoints2d, read_keypoints3d
from ..mytools.file_utils import read_annot, read_json, save_annot, save... | null |
13,005 | from termcolor import colored
import os
from os.path import join
import shutil
import subprocess
import time
import datetime
def toc():
return time.time() * 1000 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.