id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
13,006
from termcolor import colored import os from os.path import join import shutil import subprocess import time import datetime def log_time(text): strf = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f') print(colored(strf, 'yellow'), colored(text, 'green'))
null
13,007
from termcolor import colored import os from os.path import join import shutil import subprocess import time import datetime def myprint(cmd, level): color = {'run': 'blue', 'info': 'green', 'warn': 'yellow', 'error': 'red'}[level] print(colored(cmd, color)) warning_infos = set() def oncewarn(text): if tex...
null
13,008
from termcolor import colored import os from os.path import join import shutil import subprocess import time import datetime def mkdir(path): if os.path.exists(path): return 0 log('mkdir {}'.format(path)) os.makedirs(path, exist_ok=True) def cp(srcname, dstname): mkdir(join(os.path.dirname(dstn...
null
13,009
from termcolor import colored import os from os.path import join import shutil import subprocess import time import datetime def print_table(header, contents): from tabulate import tabulate length = len(contents[0]) tables = [[] for _ in range(length)] mean = ['Mean'] for icnt, content in enumerate...
null
13,010
import cv2 import numpy as np import os from os.path import join def camera_from_img(img): height, width = img.shape[0], img.shape[1] # focal = 1.2*max(height, width) # as colmap focal = 1.2*min(height, width) # as colmap K = np.array([focal, 0., width/2, 0., focal, height/2, 0. ,0., 1.]).reshape(3, 3)...
null
13,011
import cv2 import numpy as np import os from os.path import join def unproj(kpts, invK): homo = np.hstack([kpts[:, :2], np.ones_like(kpts[:, :1])]) homo = homo @ invK.T return np.hstack([homo[:, :2], kpts[:, 2:]])
null
13,012
import cv2 import numpy as np import os from os.path import join def get_Pall(cameras, camnames): Pall = np.stack([cameras[cam]['K'] @ np.hstack((cameras[cam]['R'], cameras[cam]['T'])) for cam in camnames]) return Pall
null
13,013
import cv2 import numpy as np import os from os.path import join def get_fundamental_matrix(cameras, basenames): skew_op = lambda x: np.array([[0, -x[2], x[1]], [x[2], 0, -x[0]], [-x[1], x[0], 0]]) fundamental_op = lambda K_0, R_0, T_0, K_1, R_1, T_1: np.linalg.inv(K_0).T @ ( R_0 @ R_1.T) @ K_1.T @...
null
13,014
import cv2 import numpy as np import os from os.path import join def interp_cameras(cameras, keys, step=20, loop=True, allstep=-1, **kwargs): from scipy.spatial.transform import Rotation as R from scipy.spatial.transform import Slerp if allstep != -1: tall = np.linspace(0., 1., allstep+1)[:-1].resh...
null
13,015
import numpy as np def simple_reprojection_error(kpts1, kpts1_proj): # (N, 3) error = np.mean((kpts1[:, :2] - kpts1_proj[:, :2])**2) return error
null
13,016
import numpy as np def solveZ(A): u, s, v = np.linalg.svd(A) X = v[-1, :] X = X / X[3] return X[:3] def simple_triangulate(kpts, Pall): # kpts: (nViews, 3) # Pall: (nViews, 3, 4) # return: kpts3d(3,), conf: float nViews = len(kpts) A = np.zeros((nViews*2, 4), dtype=np.float) r...
null
13,017
import numpy as np def projectN3(kpts3d, Pall): # kpts3d: (N, 3) nViews = len(Pall) kp3d = np.hstack((kpts3d[:, :3], np.ones((kpts3d.shape[0], 1)))) kp2ds = [] for nv in range(nViews): kp2d = Pall[nv] @ kp3d.T kp2d[:2, :] /= kp2d[2:, :] kp2ds.append(kp2d.T[None, :, :]) kp...
null
13,018
import numpy as np def check_limb(keypoints3d, limb_means, thres=0.5): # keypoints3d: (nJ, 4) valid = True cnt = 0 for (src, dst), val in limb_means.items(): if not (keypoints3d[src, 3] > 0 and keypoints3d[dst, 3] > 0): continue cnt += 1 # 计算骨长 l_est = np.li...
null
13,019
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary MAX_I...
null
13,020
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary MAX_I...
null
13,021
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary IS_PY...
null
13,022
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary IS_PY...
null
13,023
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary Came...
null
13,024
import shutil import sys import os import sqlite3 import numpy as np from os.path import join import cv2 from .debug_utils import mkdir, run_cmd, log, mywarn from .colmap_structure import Camera, Image, CAMERA_MODEL_NAMES from .colmap_structure import rotmat2qvec from .colmap_structure import read_points3d_binary clas...
null
13,025
import os import json import numpy as np from os.path import join def save_numpy_dict(file, data): if not os.path.exists(os.path.dirname(file)): os.makedirs(os.path.dirname(file)) res = {} for key, val in data.items(): res[key] = val.tolist() with open(file, 'w') as f: json.dump...
null
13,026
import os import json import numpy as np from os.path import join def read_numpy_dict(path): assert os.path.exists(path), path with open(path) as f: data = json.load(f) for key, val in data.items(): data[key] = np.array(val, dtype=np.float32) return data
null
13,027
import os import json import numpy as np from os.path import join def read_json(path): assert os.path.exists(path), path with open(path) as f: try: data = json.load(f) except: print('Reading error {}'.format(path)) data = [] return data def append_json(fi...
null
13,028
import os import json import numpy as np from os.path import join def getFileList(root, ext='.jpg'): files = [] dirs = os.listdir(root) while len(dirs) > 0: path = dirs.pop() fullname = join(root, path) if os.path.isfile(fullname) and fullname.endswith(ext): files.append...
null
13,029
import os import json import numpy as np from os.path import join def array2raw(array, separator=' ', fmt='%.3f'): assert len(array.shape) == 2, 'Only support MxN matrix, {}'.format(array.shape) res = [] for data in array: res.append(separator.join([fmt%(d) for d in data]))
null
13,030
import os import json import numpy as np from os.path import join def write_common_results(dumpname=None, results=[], keys=[], fmt='%2.3f'): format_out = {'float_kind':lambda x: fmt % x} out_text = [] out_text.append('[\n') for idata, data in enumerate(results): out_text.append(' {\n') ...
null
13,031
import os import json import numpy as np from os.path import join def write_common_results(dumpname=None, results=[], keys=[], fmt='%2.3f'): format_out = {'float_kind':lambda x: fmt % x} out_text = [] out_text.append('[\n') for idata, data in enumerate(results): out_text.append(' {\n') ...
null
13,032
import os import json import numpy as np from os.path import join def batch_bbox_from_pose(keypoints2d, height, width, rate=0.1): # TODO:write this in batch bboxes = np.zeros((keypoints2d.shape[0], 5), dtype=np.float32) border = 20 for bn in range(keypoints2d.shape[0]): valid = keypoints2d[bn, ...
null
13,033
import os import json import numpy as np from os.path import join def merge_params(param_list, share_shape=True): output = {} for key in ['poses', 'shapes', 'Rh', 'Th', 'expression']: if key in param_list[0].keys(): output[key] = np.vstack([v[key] for v in param_list]) if share_shape: ...
null
13,034
import os import sys import collections import numpy as np import struct import cv2 def read_cameras_text(path): """ see: src/base/reconstruction.cc void Reconstruction::WriteCamerasText(const std::string& path) void Reconstruction::ReadCamerasText(const std::string& path) """ cameras = ...
null
13,035
import os import sys import collections import numpy as np import struct import cv2 def qvec2rotmat(qvec): return np.array([ [1 - 2 * qvec[2]**2 - 2 * qvec[3]**2, 2 * qvec[1] * qvec[2] - 2 * qvec[0] * qvec[3], 2 * qvec[3] * qvec[1] + 2 * qvec[0] * qvec[2]], [2 * qvec[1] * qvec[2] ...
null
13,036
import os import sys import collections import numpy as np import struct import cv2 The provided code snippet includes necessary dependencies for implementing the `write_cameras_text` function. Write a Python function `def write_cameras_text(cameras, path)` to solve the following problem: see: src/base/reconstruction....
see: src/base/reconstruction.cc void Reconstruction::WriteCamerasText(const std::string& path) void Reconstruction::ReadCamerasText(const std::string& path)
13,037
import os import sys import collections import numpy as np import struct import cv2 CAMERA_MODEL_NAMES = dict([(camera_model.model_name, camera_model) for camera_model in CAMERA_MODELS]) def write_next_bytes(fid, data, format_char_sequence, endian_character="<"): """pack and write to a bi...
see: src/base/reconstruction.cc void Reconstruction::WriteCamerasBinary(const std::string& path) void Reconstruction::ReadCamerasBinary(const std::string& path)
13,038
import os import sys import collections import numpy as np import struct import cv2 def write_next_bytes(fid, data, format_char_sequence, endian_character="<"): """pack and write to a binary file. :param fid: :param data: data to send, if multiple elements are sent at the same time, they should be encap...
see: src/base/reconstruction.cc void Reconstruction::ReadImagesBinary(const std::string& path) void Reconstruction::WriteImagesBinary(const std::string& path)
13,039
import os import sys import collections import numpy as np import struct import cv2 The provided code snippet includes necessary dependencies for implementing the `write_images_text` function. Write a Python function `def write_images_text(images, path)` to solve the following problem: see: src/base/reconstruction.cc ...
see: src/base/reconstruction.cc void Reconstruction::ReadImagesText(const std::string& path) void Reconstruction::WriteImagesText(const std::string& path)
13,040
import os import sys import collections import numpy as np import struct import cv2 The provided code snippet includes necessary dependencies for implementing the `write_points3D_text` function. Write a Python function `def write_points3D_text(points3D, path)` to solve the following problem: see: src/base/reconstructi...
see: src/base/reconstruction.cc void Reconstruction::ReadPoints3DText(const std::string& path) void Reconstruction::WritePoints3DText(const std::string& path)
13,041
import os import sys import collections import numpy as np import struct import cv2 def write_next_bytes(fid, data, format_char_sequence, endian_character="<"): """pack and write to a binary file. :param fid: :param data: data to send, if multiple elements are sent at the same time, they should be encap...
see: src/base/reconstruction.cc void Reconstruction::ReadPoints3DBinary(const std::string& path) void Reconstruction::WritePoints3DBinary(const std::string& path)
13,042
import os import argparse from os.path import join def load_parser(): parser = argparse.ArgumentParser('EasyMocap commond line tools') parser.add_argument('path', type=str) parser.add_argument('--out', type=str, default=None) parser.add_argument('--cfg', type=str, default=None) parser.add_argument(...
null
13,043
import os import argparse from os.path import join def save_parser(args): import yaml res = vars(args) os.makedirs(args.out, exist_ok=True) with open(join(args.out, 'exp.yml'), 'w') as f: yaml.dump(res, f) def parse_parser(parser): args = parser.parse_args() if args.out is None: ...
null
13,044
import cv2 import numpy as np import json def generate_colorbar(N = 20, cmap = 'jet', rand=True, ret_float=False, ret_array=False, ret_rgb=False): bar = ((np.arange(N)/(N-1))*255).astype(np.uint8).reshape(-1, 1) colorbar = cv2.applyColorMap(bar, cv2.COLORMAP_JET).squeeze() if False: colorbar =...
null
13,045
import cv2 import numpy as np import json def get_rgb(index): if isinstance(index, int): if index == -1: return (255, 255, 255) if index < -1: return (0, 0, 0) # elif index == 0: # return (245, 150, 150) col = list(colors_bar_rgb[index%len(colors_b...
null
13,046
import cv2 import numpy as np import json def plot_point(img, x, y, r, col, pid=-1, font_scale=-1, circle_type=-1): cv2.circle(img, (int(x+0.5), int(y+0.5)), r, col, circle_type) if font_scale == -1: font_scale = img.shape[0]/4000 if pid != -1: cv2.putText(img, '{}'.format(pid), (int(x+0.5)...
null
13,047
import cv2 import numpy as np import json def get_rgb(index): def plot_keypoints(img, points, pid, config, vis_conf=False, use_limb_color=True, lw=2, fliplr=False): lw = max(lw, 2) H, W = img.shape[:2] for ii, (i, j) in enumerate(config['kintree']): if i >= len(points) or j >= len(points): ...
null
13,048
import cv2 import numpy as np import json def plot_bbox(img, bbox, pid, scale=1, vis_id=True): # 画bbox: (l, t, r, b) x1, y1, x2, y2, c = bbox if c < 0.01:return img x1 = int(round(x1*scale)) x2 = int(round(x2*scale)) y1 = int(round(y1*scale)) y2 = int(round(y2*scale)) color = get_rgb(pid...
null
13,049
import cv2 import numpy as np import json def plot_line(img, pt1, pt2, lw, col): cv2.line(img, (int(pt1[0]+0.5), int(pt1[1]+0.5)), (int(pt2[0]+0.5), int(pt2[1]+0.5)), col, lw) def plot_cross(img, x, y, col, width=-1, lw=-1): if lw == -1: lw = max(1, int(round(img.shape[0]/1000))) width =...
null
13,050
import cv2 import numpy as np import json def get_row_col(l, square): def merge(images, row=-1, col=-1, resize=False, ret_range=False, square=False, **kwargs): if row == -1 and col == -1: row, col = get_row_col(len(images), square) height = images[0].shape[0] width = images[0].shape[1] # specia...
null
13,051
import numpy as np import os from os.path import join from glob import glob from .file_utils import read_json, read_annot def read_annot(annotname, mode='body25'): data = read_json(annotname) if not isinstance(data, list): data = data['annots'] for i in range(len(data)): if 'id' not in data...
null
13,052
import numpy as np import os from os.path import join from glob import glob from .file_utils import read_json, read_annot def read_json(path): def read_keypoints3d_dict(filename): data = read_json(filename) res_ = {} for d in data: pid = d['id'] if 'id' in d.keys() else d['personID'] pose3...
null
13,053
import numpy as np import os from os.path import join from glob import glob from .file_utils import read_json, read_annot def read_keypoints3d_a4d(outname): res_ = [] with open(outname, "r") as file: lines = file.readlines() if len(lines) < 2: return res_ nPerson, nJoints = ...
null
13,054
import time import tabulate def dummyfunc(): time.sleep(1)
null
13,055
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def make_Cnk(n, k): import itertools res = {} for n_ ...
null
13,056
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def batch_triangulate(keypoints_, Pall, min_view=2): """ trian...
null
13,057
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def skew_op(x): skew_op = lambda x: np.array([[0, -x[2], x[1]]...
null
13,058
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror The provided code snippet includes necessary dependencies for imp...
img1 - image on which we draw the epilines for the points in img2 lines - corresponding epilines
13,059
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def check_cluster(affinity, row, views, dimGroups, indices, p2dAs...
null
13,060
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def views_from_dimGroups(dimGroups): views = np.zeros(dimGrou...
null
13,061
import numpy as np import cv2 from easymocap.datasets.base import crop_image from easymocap.estimator.wrapper_base import bbox_from_keypoints from easymocap.mytools.vis_base import merge, plot_keypoints_auto from .debug_utils import log, mywarn, myerror def SimpleConstrain(dimGroups): class SimpleMatchAndTriangulator(S...
null
13,062
import cv2 import numpy as np from ..mytools.file_utils import write_common_results def write_common_results(dumpname=None, results=[], keys=[], fmt='%2.3f'): def encode_detect(data): res = write_common_results(None, data, ['keypoints3d']) res = res.replace('\r', '').replace('\n', '').replace(' ', '') ret...
null
13,063
import cv2 import numpy as np from ..mytools.file_utils import write_common_results def write_common_results(dumpname=None, results=[], keys=[], fmt='%2.3f'): format_out = {'float_kind':lambda x: fmt % x} out_text = [] out_text.append('[\n') for idata, data in enumerate(results): out_text.appen...
null
13,064
import cv2 import numpy as np from ..mytools.file_utils import write_common_results def encode_image(image): fourcc = [int(cv2.IMWRITE_JPEG_QUALITY), 90] #frame을 binary 형태로 변환 jpg로 decoding result, img_encode = cv2.imencode('.jpg', image, fourcc) data = np.array(img_encode) # numpy array로 안바꿔주면 ERROR ...
null
13,065
import socket import time from threading import Thread from queue import Queue def log(x): from datetime import datetime time_now = datetime.now().strftime("%m-%d-%H:%M:%S.%f ") print(time_now + x)
null
13,066
import open3d as o3d from ..config import load_object from ..visualize.o3dwrapper import Vector3dVector, create_mesh, load_mesh from ..mytools import Timer from ..mytools.vis_base import get_rgb_01 from .base import BaseSocket, log import json import numpy as np from os.path import join import os from ..assignment.crit...
null
13,067
import torch import torch.nn as nn from .lbs import batch_rodrigues from .lbs import lbs, dqs import os.path as osp import pickle import numpy as np import os def to_np(array, dtype=np.float32): if 'scipy.sparse' in str(type(array)): array = array.todense() return np.array(array, dtype=dtype)
null
13,068
import torch import torch.nn as nn from .lbs import batch_rodrigues from .lbs import lbs, dqs import os.path as osp import pickle import numpy as np import os def to_tensor(array, dtype=torch.float32, device=torch.device('cpu')): if 'torch.tensor' not in str(type(array)): return torch.tensor(array, dtype=dt...
null
13,069
import torch import torch.nn as nn from .lbs import batch_rodrigues from .lbs import lbs, dqs import os.path as osp import pickle import numpy as np import os def load_bodydata(model_type, model_path, gender): if osp.isdir(model_path): model_fn = '{}_{}.{ext}'.format(model_type.upper(), gender.upper(), ext...
null
13,070
import numpy as np from os.path import join def merge_params(param_list, share_shape=True): output = {} for key in ['poses', 'shapes', 'Rh', 'Th', 'expression']: if key in param_list[0].keys(): output[key] = np.vstack([v[key] for v in param_list]) if share_shape: output['shapes'...
null
13,071
import numpy as np from os.path import join def select_nf(params_all, nf): output = {} for key in ['poses', 'Rh', 'Th']: output[key] = params_all[key][nf:nf+1, :] if 'expression' in params_all.keys(): output['expression'] = params_all['expression'][nf:nf+1, :] if params_all['shapes'].sh...
null
13,072
import numpy as np from os.path import join class SMPLlayer(nn.Module): def __init__(self, model_path, model_type='smpl', gender='neutral', device=None, regressor_path=None, use_pose_blending=True, use_shape_blending=True, use_joints=True, with_color=False, use_lbs=True, **kwargs) -...
null
13,073
import numpy as np from os.path import join def check_keypoints(keypoints2d, WEIGHT_DEBUFF=1, min_conf=0.3): # keypoints2d: nFrames, nJoints, 3 # # wrong feet # if keypoints2d.shape[-2] > 25 + 42: # keypoints2d[..., 0, 2] = 0 # keypoints2d[..., [15, 16, 17, 18], -1] = 0 # keypoints2d[....
null
13,074
from __future__ import absolute_import from __future__ import print_function from __future__ import division import numpy as np import torch import torch.nn.functional as F def rot_mat_to_euler(rot_mats): # Calculates rotation matrix to euler angles # Careful for extreme cases of eular angles like [0.0, pi, 0.0...
Compute the faces, barycentric coordinates for the dynamic landmarks To do so, we first compute the rotation of the neck around the y-axis and then use a pre-computed look-up table to find the faces and the barycentric coordinates that will be used. Special thanks to Soubhik Sanyal (soubhik.sanyal@tuebingen.mpg.de) for...
13,075
from __future__ import absolute_import from __future__ import print_function from __future__ import division import numpy as np import torch import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `vertices2landmarks` function. Write a Python function `def vertice...
Calculates landmarks by barycentric interpolation Parameters ---------- vertices: torch.tensor BxVx3, dtype = torch.float32 The tensor of input vertices faces: torch.tensor Fx3, dtype = torch.long The faces of the mesh lmk_faces_idx: torch.tensor L, dtype = torch.long The tensor with the indices of the faces used to ca...
13,076
from __future__ import absolute_import from __future__ import print_function from __future__ import division import numpy as np import torch import torch.nn.functional as F def vertices2joints(J_regressor, vertices): ''' Calculates the 3D joint locations from the vertices Parameters ---------- J_regress...
Performs Linear Blend Skinning with the given shape and pose parameters Parameters ---------- betas : torch.tensor BxNB The tensor of shape parameters pose : torch.tensor Bx(J + 1) * 3 The pose parameters in axis-angle format v_template torch.tensor BxVx3 The template mesh that will be deformed shapedirs : torch.tensor...
13,077
from __future__ import absolute_import from __future__ import print_function from __future__ import division import numpy as np import torch import torch.nn.functional as F def vertices2joints(J_regressor, vertices): ''' Calculates the 3D joint locations from the vertices Parameters ---------- J_regress...
Performs Linear Blend Skinning with the given shape and pose parameters Parameters ---------- betas : torch.tensor BxNB The tensor of shape parameters pose : torch.tensor Bx(J + 1) * 3 The pose parameters in axis-angle format v_template torch.tensor BxVx3 The template mesh that will be deformed shapedirs : torch.tensor...
13,078
import numpy as np import cv2 from ..dataset.config import CONFIG from ..config import load_object from ..mytools.debug_utils import log, mywarn, myerror import torch from tqdm import tqdm, trange def svd_rot(src, tgt, reflection=False, debug=False): # optimum rotation matrix of Y A = np.matmul(src.transpose(0...
null
13,079
import numpy as np import cv2 from ..dataset.config import CONFIG from ..config import load_object from ..mytools.debug_utils import log, mywarn, myerror import torch from tqdm import tqdm, trange def batch_invRodrigues(rot): res = [] for r in rot: v = cv2.Rodrigues(r)[0] res.append(v) res ...
null
13,080
import numpy as np import torch.nn as nn import torch from ..bodymodel.lbs import batch_rodrigues class GMoF(nn.Module): def __init__(self, rho=1): def extra_repr(self): def forward(self, est, gt=None, conf=None): def make_loss(norm, norm_info, reduce='sum'): reduce = torch.sum if reduce=='sum' else...
null
13,081
import numpy as np import torch.nn as nn import torch from ..bodymodel.lbs import batch_rodrigues def select(value, ranges, index, dim): if len(ranges) > 0: if ranges[1] == -1: value = value[..., ranges[0]:] else: value = value[..., ranges[0]:ranges[1]] return value ...
null
13,082
import numpy as np import torch.nn as nn import torch from ..bodymodel.lbs import batch_rodrigues def print_table(header, contents): from tabulate import tabulate length = len(contents[0]) tables = [[] for _ in range(length)] mean = ['Mean'] for icnt, content in enumerate(contents): for i i...
null
13,083
import numpy as np import torch from ..dataset.mirror import flipPoint2D, flipSMPLPoses, flipSMPLParams from ..estimator.wrapper_base import bbox_from_keypoints from .lossbase import Keypoints2D The provided code snippet includes necessary dependencies for implementing the `calc_vanishpoint` function. Write a Python f...
keypoints2d: (2, N, 3)
13,084
import pickle import os from os.path import join import numpy as np import torch from .lossbase import LossBase The provided code snippet includes necessary dependencies for implementing the `create_prior_from_cmu` function. Write a Python function `def create_prior_from_cmu(n_gaussians, epsilon=1e-15)` to solve the f...
Load the gmm from the CMU motion database.
13,085
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
Calculates the rotation matrices for a batch of rotation vectors Parameters ---------- rot_vecs: torch.tensor Nx3 array of N axis-angle vectors Returns ------- R: torch.tensor Nx3x3 The rotation matrices for the given axis-angle parameters
13,086
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,087
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,088
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,089
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,090
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,091
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,092
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,093
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,094
from collections import namedtuple from time import time, sleep import numpy as np import cv2 import torch import copy from ..config.baseconfig import load_object_from_cmd from ..mytools.debug_utils import log, mywarn from ..mytools import Timer from ..config import Config from ..mytools.triangulator import iterative_t...
null
13,095
import torch from torch.nn import functional as F import numpy as np The provided code snippet includes necessary dependencies for implementing the `rot6d_to_rotation_matrix` function. Write a Python function `def rot6d_to_rotation_matrix(rot6d)` to solve the following problem: Convert 6D rotation representation to 3x...
Convert 6D rotation representation to 3x3 rotation matrix. Based on Zhou et al., "On the Continuity of Rotation Representations in Neural Networks", CVPR 2019 Args: rot6d: torch tensor of shape (batch_size, 6) of 6d rotation representations. Returns: rotation_matrix: torch tensor of shape (batch_size, 3, 3) of correspo...
13,096
import torch from torch.nn import functional as F import numpy as np The provided code snippet includes necessary dependencies for implementing the `rotation_matrix_to_rot6d` function. Write a Python function `def rotation_matrix_to_rot6d(rotation_matrix)` to solve the following problem: Convert 3x3 rotation matrix to...
Convert 3x3 rotation matrix to 6D rotation representation. Args: rotation_matrix: torch tensor of shape (batch_size, 3, 3) of corresponding rotation matrices. Returns: rot6d: torch tensor of shape (batch_size, 6) of 6d rotation representations.
13,097
import torch from torch.nn import functional as F import numpy as np def rotation_matrix_to_quaternion(rotation_matrix, eps=1e-6): """ Convert rotation matrix to corresponding quaternion Args: rotation_matrix: torch tensor of shape (batch_size, 3, 3) Returns: quaternion: torch tensor of ...
null
13,098
import torch from torch.nn import functional as F import numpy as np def rotation_matrix_to_quaternion(rotation_matrix, eps=1e-6): def quaternion_to_euler(quaternion, order, epsilon=0): def rotation_matrix_to_euler(rotation_matrix, order): quaternion = rotation_matrix_to_quaternion(rotation_matrix) return quat...
null
13,099
import torch from torch.nn import functional as F import numpy as np def quaternion_to_rotation_matrix(quaternion): """ Convert quaternion coefficients to rotation matrix. Args: quaternion: torch tensor of shape (batch_size, 4) in (w, x, y, z) representation. Returns: rotation matrix cor...
null
13,100
import torch from torch.nn import functional as F import numpy as np def quaternion_to_euler(quaternion, order, epsilon=0): """ Convert quaternion to euler angles. Args: quaternion: torch tensor of shape (batch_size, 4) in (w, x, y, z) representation. order: euler angle representation order,...
null
13,101
import torch from torch.nn import functional as F import numpy as np def euler_to_quaternion(euler, order): """ Convert euler angles to quaternion. Args: euler: torch tensor of shape (batch_size, 3) in order. order: Returns: quaternion: torch tensor of shape (batch_size, 4) in (w...
null
13,102
import torch from torch.nn import functional as F import numpy as np The provided code snippet includes necessary dependencies for implementing the `rotate_vec_by_quaternion` function. Write a Python function `def rotate_vec_by_quaternion(v, q)` to solve the following problem: Rotate vector(s) v about the rotation des...
Rotate vector(s) v about the rotation described by quaternion(s) q. Expects a tensor of shape (*, 4) for q and a tensor of shape (*, 3) for v, where * denotes any number of dimensions. Returns a tensor of shape (*, 3).
13,103
import torch from torch.nn import functional as F import numpy as np The provided code snippet includes necessary dependencies for implementing the `quaternion_fix` function. Write a Python function `def quaternion_fix(quaternion)` to solve the following problem: Enforce quaternion continuity across the time dimension...
Enforce quaternion continuity across the time dimension by selecting the representation (q or -q) with minimal distance (or, equivalently, maximal dot product) between two consecutive frames. Args: quaternion: torch tensor of shape (batch_size, 4) Returns: quaternion: torch tensor of shape (batch_size, 4)
13,104
import torch from torch.nn import functional as F import numpy as np def quaternion_inverse(quaternion): q_conjugate = quaternion.clone() q_conjugate[::, 1:] * -1 q_norm = quaternion[::, 1:].norm(dim=-1) + quaternion[::, 0]**2 return q_conjugate/q_norm.unsqueeze(-1)
null
13,105
import torch from torch.nn import functional as F import numpy as np def quaternion_lerp(q1, q2, t): q = (1-t)*q1 + t*q2 q = q/q.norm(dim=-1).unsqueeze(-1) return q
null