id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
13,206
import torch import torch.nn as nn from torch import searchsorted def sample_pdf(bins, weights, N_samples, det=False): # Get pdf weights = weights + 1e-5 # prevent nans pdf = weights / torch.sum(weights, -1, keepdim=True) cdf = torch.cumsum(pdf, -1) cdf = torch.cat([torch.zeros_like(cdf[...,:1]), c...
null
13,207
import torch import torch.nn as nn from torch import searchsorted def get_near_far(ray_o, ray_d, bounds): def get_near_far_RTBBox(ray_o, ray_d, bounds, R, T): # sample the near far in canonical coordinate ray_o_rt = (ray_o - T) @ R ray_d_rt = ray_d @ R near, far, mask_at_box = get_near_far(ray_o_rt, ra...
null
13,208
import torch import torch.nn as nn from torch import searchsorted def concat(retlist, dim=0, unsqueeze=True, mask=None): res = {} if len(retlist) == 0: return res for key in retlist[0].keys(): val = torch.cat([r[key] for r in retlist], dim=dim) if mask is not None and val.shape[0] !...
null
13,209
from .nerf import Nerf, EmbedMLP import torch import spconv import torch.nn as nn import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `pts_to_can_pts` function. Write a Python function `def pts_to_can_pts(pts, sp_input)` to solve the following problem: transfo...
transform pts from the world coordinate to the smpl coordinate
13,210
from .nerf import Nerf, EmbedMLP import torch import spconv import torch.nn as nn import torch.nn.functional as F def get_grid_coords(pts, sp_input, voxel_size): # convert xyz to the voxel coordinate dhw dhw = pts[..., [2, 1, 0]] # min_dhw = sp_input['bounds'][:, 0, [2, 1, 0]] min_dhw = sp_input['min_d...
null
13,211
from .nerf import Nerf, EmbedMLP import torch import spconv try: if spconv.__version__.split('.')[0] == '2': import spconv.pytorch as spconv except: pass import torch.nn as nn import torch.nn.functional as F def encode_sparse_voxels(xyzc_net, sp_input, code): coord = sp_input['coord'] out_sh = ...
null
13,212
from .nerf import Nerf, EmbedMLP import torch import spconv import torch.nn as nn import torch.nn.functional as F def my_grid_sample(feat, grid, mode='bilinear', align_corners=True, padding_mode='border'): B, C, ID, IH, IW = feat.shape assert(B==1) feat = feat[0] grid = grid[0, 0, 0] N_g, _ = grid....
null
13,213
from .nerf import Nerf, EmbedMLP import torch import spconv import torch.nn as nn import torch.nn.functional as F def interpolate_features(grid_coords, feature_volume, padding_mode): features = [] for volume in feature_volume: feature = F.grid_sample(volume, grid_coords,...
null
13,214
from .nerf import Nerf, EmbedMLP import torch import spconv import torch.nn as nn import torch.nn.functional as F def prepare_sp_input(batch, voxel_pad, voxel_size): vertices = batch['vertices'][0] R, Th = batch['R'][0], batch['Th'][0] # Here: R^-1 @ (X - T) => (X - T) @ R^-1.T can_xyz = torch.matmul(v...
null
13,215
from .nerf import Nerf, EmbedMLP import torch import spconv try: if spconv.__version__.split('.')[0] == '2': import spconv.pytorch as spconv except: pass import torch.nn as nn import torch.nn.functional as F def single_conv(in_channels, out_channels, indice_key=None): return spconv.SparseSequential...
null
13,216
from .nerf import Nerf, EmbedMLP import torch import spconv try: if spconv.__version__.split('.')[0] == '2': import spconv.pytorch as spconv except: pass import torch.nn as nn import torch.nn.functional as F def double_conv(in_channels, out_channels, indice_key=None): return spconv.SparseSequential...
null
13,217
from .nerf import Nerf, EmbedMLP import torch import spconv try: if spconv.__version__.split('.')[0] == '2': import spconv.pytorch as spconv except: pass import torch.nn as nn import torch.nn.functional as F def triple_conv(in_channels, out_channels, indice_key=None): return spconv.SparseSequential...
null
13,218
from .nerf import Nerf, EmbedMLP import torch import spconv try: if spconv.__version__.split('.')[0] == '2': import spconv.pytorch as spconv except: pass import torch.nn as nn import torch.nn.functional as F def stride_conv(in_channels, out_channels, indice_key=None): return spconv.SparseSequential...
null
13,219
import torch import torch.nn as nn from .nerf import Nerf, EmbedMLP, MultiLinear from os.path import join from ...mytools.file_utils import read_json import numpy as np class EmbedMLP(nn.Module): def __init__(self, input_ch, output_ch, multi_res, W, D, bounds) -> None: super().__init__() self.embed...
null
13,220
import numpy as np import cv2 import os from os.path import join from ..mytools import plot_cross, plot_line, plot_bbox, plot_keypoints, get_rgb, merge from ..mytools.file_utils import get_bbox_from_pose from ..dataset import CONFIG def plot_bbox_body(img, annots, **kwargs): annots = annots['annots'] for data ...
null
13,221
import os import json import numpy as np from os.path import join import shutil from ..mytools.file_utils import myarray2string def read_json(path): with open(path, 'r') as f: data = json.load(f) return data def load_annot_to_tmp(annotname): if annotname is None: return {} if not os.pat...
null
13,222
import cv2 The provided code snippet includes necessary dependencies for implementing the `point_callback` function. Write a Python function `def point_callback(event, x, y, flags, param)` to solve the following problem: OpenCV使用的简单的回调函数,主要实现两个基础功能: 1. 对于按住拖动的情况,记录起始点与终止点(当前点) 2. 对于点击的情况,记录选择的点 3. 记录当前是否按住了键 Here is ...
OpenCV使用的简单的回调函数,主要实现两个基础功能: 1. 对于按住拖动的情况,记录起始点与终止点(当前点) 2. 对于点击的情况,记录选择的点 3. 记录当前是否按住了键
13,223
import numpy as np import cv2 from func_timeout import func_set_timeout colors_chessboard_bar = [ [0, 0, 255], [0, 128, 255], [0, 200, 200], [0, 255, 0], [200, 200, 0], [255, 0, 0], [255, 0, 250] ] def get_lines_chessboard(pattern=(9, 6)): w, h = pattern[0], pattern[1] lines = [] ...
null
13,224
import numpy as np import cv2 from func_timeout import func_set_timeout def detect_charuco(image, aruco_type, long, short, squareLength, aruco_len): ARUCO_DICT = { "4X4_50": cv2.aruco.DICT_4X4_50, "4X4_100": cv2.aruco.DICT_4X4_100, "5X5_100": cv2.aruco.DICT_5X5_100, "5X5_250": cv2.a...
null
13,225
from glob import glob from tqdm import tqdm from .basic_callback import get_key def print_help(annotator, **kwargs): """print the help""" print('Here is the help:') print( '------------------') for key, val in annotator.register_keys.items(): if isinstance(val, list): print(' {}:...
null
13,226
from glob import glob from tqdm import tqdm from .basic_callback import get_key The provided code snippet includes necessary dependencies for implementing the `close` function. Write a Python function `def close(annotator, **kwargs)` to solve the following problem: quit the annotation Here is the function: def close...
quit the annotation
13,227
from glob import glob from tqdm import tqdm from .basic_callback import get_key for key in 'wasdfg': register_keys[key] = get_move(key) The provided code snippet includes necessary dependencies for implementing the `close_wo_save` function. Write a Python function `def close_wo_save(annotator, **kwargs)` to solve ...
quit the annotation without saving
13,228
from glob import glob from tqdm import tqdm from .basic_callback import get_key for key in 'wasdfg': register_keys[key] = get_move(key) The provided code snippet includes necessary dependencies for implementing the `skip` function. Write a Python function `def skip(annotator, **kwargs)` to solve the following prob...
skip the annotation
13,229
from glob import glob from tqdm import tqdm from .basic_callback import get_key def get_move(wasd): get_frame = { 'a': lambda x, f: f - 1, 'd': lambda x, f: f + 1, 'w': lambda x, f: f - 10, 's': lambda x, f: f + 10, 'f': lambda x, f: f + 100, 'g': lambda x, f: f - 10...
null
13,230
from glob import glob from tqdm import tqdm from .basic_callback import get_key def set_personID(i): def func(self, param, **kwargs): active = param['select']['bbox'] if active == -1 and active >= len(param['annots']['annots']): return 0 else: param['annots']['annots...
null
13,231
from glob import glob from tqdm import tqdm from .basic_callback import get_key def choose_personID(i): def func(self, param, **kwargs): for idata, data in enumerate(param['annots']['annots']): if data['personID'] == i: param['select']['bbox'] = idata return 0 func._...
null
13,232
from glob import glob from tqdm import tqdm from .basic_callback import get_key remain = 0 keys_pre = [] for key in 'wasdfg': register_keys[key] = get_move(key) def get_key(): k = cv2.waitKey(10) & 0xFF if k == CV_KEY.LSHIFT: key1 = cv2.waitKey(500) & 0xFF if key1 == CV_KEY.NONE: ...
continue automatic
13,233
from glob import glob from tqdm import tqdm from .basic_callback import get_key remain = 0 keys_pre = [] for key in 'wasdfg': register_keys[key] = get_move(key) def get_key(): k = cv2.waitKey(10) & 0xFF if k == CV_KEY.LSHIFT: key1 = cv2.waitKey(500) & 0xFF if key1 == CV_KEY.NONE: ...
Automatic running
13,234
from glob import glob from tqdm import tqdm from .basic_callback import get_key The provided code snippet includes necessary dependencies for implementing the `set_keyframe` function. Write a Python function `def set_keyframe(self, param)` to solve the following problem: set/unset the key-frame Here is the function: ...
set/unset the key-frame
13,235
import numpy as np from ..dataset.config import CONFIG def findNearestPoint(points, click): def callback_select_bbox_corner(start, end, annots, select, bbox_name, **kwargs): if start is None or end is None: select['corner'] = -1 return 0 if start[0] == end[0] and start[1] == end[1]: ret...
null
13,236
import numpy as np from ..dataset.config import CONFIG def get_auto_track(mode='kpts'): MAX_SPEED = 100 if mode == 'bbox': MAX_SPEED = 0.2 def auto_track(self, param, **kwargs): if self.frame == 0: return 0 previous = self.previous() annots = param['annots']['ann...
null
13,237
import numpy as np from ..dataset.config import CONFIG The provided code snippet includes necessary dependencies for implementing the `copy_previous_missing` function. Write a Python function `def copy_previous_missing(self, param, **kwargs)` to solve the following problem: copy the missing person of previous frame H...
copy the missing person of previous frame
13,238
import numpy as np from ..dataset.config import CONFIG The provided code snippet includes necessary dependencies for implementing the `copy_previous_bbox` function. Write a Python function `def copy_previous_bbox(self, param, **kwargs)` to solve the following problem: copy the annots of previous frame Here is the fun...
copy the annots of previous frame
13,239
import numpy as np from ..dataset.config import CONFIG The provided code snippet includes necessary dependencies for implementing the `create_bbox` function. Write a Python function `def create_bbox(self, param, **kwargs)` to solve the following problem: add new boundbox Here is the function: def create_bbox(self, p...
add new boundbox
13,240
import numpy as np from ..dataset.config import CONFIG CONFIG = { 'points': { 'nJoints': 1, 'kintree': [] } } CONFIG['smpl'] = {'nJoints': 24, 'kintree': [ [ 0, 1 ], [ 0, 2 ], [ 0, 3 ], [ 1, 4 ], [ 2, 5 ], [ 3, 6 ], [ 4, 7 ], ...
add new boundbox
13,241
import numpy as np from ..dataset.config import CONFIG The provided code snippet includes necessary dependencies for implementing the `delete_bbox` function. Write a Python function `def delete_bbox(self, param, **kwargs)` to solve the following problem: delete the person Here is the function: def delete_bbox(self, ...
delete the person
13,242
import numpy as np from ..dataset.config import CONFIG The provided code snippet includes necessary dependencies for implementing the `delete_all_bbox` function. Write a Python function `def delete_all_bbox(self, param, **kwargs)` to solve the following problem: delete the person Here is the function: def delete_all...
delete the person
13,243
import numpy as np from ..dataset.config import CONFIG def callback_select_image(click, select, ranges, **kwargs): if click is None: return 0 ranges = np.array(ranges) click = np.array(click).reshape(1, -1) res = (click[:, 0]>ranges[:, 0])&(click[:, 0]<ranges[:, 2])&(click[:, 1]>ranges[:, 1])&(...
null
13,244
import numpy as np from ..dataset.config import CONFIG MIN_PIXEL = 50 def callback_select_bbox_center(click, annots, select, bbox_name, min_pixel=-1, **kwargs): def callback_select_image_bbox(click, start, end, select, ranges, annots, bbox_name='bbox', **kwargs): if click is None: return 0 ranges = np....
null
13,245
import numpy as np from ..dataset.config import CONFIG def findNearestPoint(points, click): # points: (N, 2) # click : [x, y] click = np.array(click) if len(points.shape) == 2: click = click[None, :] elif len(points.shape) == 3: click = click[None, None, :] dist = np.linalg.norm(...
null
13,246
import numpy as np The provided code snippet includes necessary dependencies for implementing the `set_face_unvisible` function. Write a Python function `def set_face_unvisible(self, param, **kwargs)` to solve the following problem: set the face unvisible Here is the function: def set_face_unvisible(self, param, **k...
set the face unvisible
13,247
import shutil import cv2 import os from tqdm import tqdm from .basic_keyboard import print_help, register_keys from .basic_visualize import plot_text, resize_to_screen, merge from .basic_callback import point_callback, CV_KEY, get_key from .bbox_callback import callback_select_image from .file_utils import load_annot_t...
null
13,248
import shutil import cv2 import os from tqdm import tqdm from .basic_keyboard import print_help, register_keys from .basic_visualize import plot_text, resize_to_screen, merge from .basic_callback import point_callback, CV_KEY, get_key from .bbox_callback import callback_select_image from .file_utils import load_annot_t...
null
13,249
import shutil import cv2 import os from tqdm import tqdm from .basic_keyboard import print_help, register_keys from .basic_visualize import plot_text, resize_to_screen, merge from .basic_callback import point_callback, CV_KEY, get_key from .bbox_callback import callback_select_image from .file_utils import load_annot_t...
null
13,250
from os.path import join import os from glob import glob import numpy as np from easymocap.dataset.config import coco17tobody25 from ..mytools.vis_base import merge, plot_keypoints_auto, plot_keypoints_total from ..mytools.camera_utils import Undistort, unproj, read_cameras from ..mytools.file_utils import read_json, w...
null
13,251
from os.path import join import os from glob import glob import numpy as np from easymocap.dataset.config import coco17tobody25 from ..mytools.vis_base import merge, plot_keypoints_auto, plot_keypoints_total from ..mytools.camera_utils import Undistort, unproj, read_cameras from ..mytools.file_utils import read_json, w...
null
13,252
from os.path import join import os from glob import glob import numpy as np from easymocap.dataset.config import coco17tobody25 from ..mytools.vis_base import merge, plot_keypoints_auto, plot_keypoints_total from ..mytools.camera_utils import Undistort, unproj, read_cameras from ..mytools.file_utils import read_json, w...
null
13,253
from os.path import join import os from glob import glob import numpy as np from easymocap.dataset.config import coco17tobody25 from ..mytools.vis_base import merge, plot_keypoints_auto, plot_keypoints_total from ..mytools.camera_utils import Undistort, unproj, read_cameras from ..mytools.file_utils import read_json, w...
null
13,254
from os.path import join import os from glob import glob import numpy as np from easymocap.dataset.config import coco17tobody25 from ..mytools.vis_base import merge, plot_keypoints_auto, plot_keypoints_total from ..mytools.camera_utils import Undistort, unproj, read_cameras from ..mytools.file_utils import read_json, w...
null
13,255
from ..annotator.file_utils import read_json from .wrapper_base import check_result, create_annot_file, save_annot from glob import glob from os.path import join from tqdm import tqdm import os import cv2 import numpy as np def detect_frame(detector, img, pid=0, only_bbox=False): lDetections = detector.detect([img...
null
13,256
from ..annotator.file_utils import read_json from .wrapper_base import check_result, create_annot_file, save_annot from glob import glob from os.path import join from tqdm import tqdm import os import cv2 import numpy as np def check_result(image_root, annot_root): if os.path.exists(annot_root): # check th...
null
13,257
from ..annotator.file_utils import read_json from .wrapper_base import check_result, create_annot_file, save_annot from glob import glob from os.path import join from tqdm import tqdm import os import cv2 import numpy as np def read_json(path): with open(path, 'r') as f: data = json.load(f) return data...
null
13,258
from ..annotator.file_utils import read_json from .wrapper_base import check_result, create_annot_file, save_annot from glob import glob from os.path import join from tqdm import tqdm import os import cv2 import numpy as np def create_annot_file(annotname, imgname): assert os.path.exists(imgname), imgname img ...
null
13,259
import torch import torch.nn as nn import torchvision.models.resnet as resnet import numpy as np import math 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 foll...
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
13,260
import torch import torch.nn as nn import torchvision.models.resnet as resnet import numpy as np import math from torch.nn import functional as F class Bottleneck(nn.Module): """ Redefinition of Bottleneck residual block Adapted from the official PyTorch implementation """ expansion = 4 def __in...
Constructs an HMR model with ResNet50 backbone. Args: pretrained (bool): If True, returns a model pre-trained on ImageNet
13,261
import torch import numpy as np import cv2 from .models import hmr The provided code snippet includes necessary dependencies for implementing the `normalize` function. Write a Python function `def normalize(tensor, mean, std, inplace: bool = False)` to solve the following problem: Normalize a tensor image with mean an...
Normalize a tensor image with mean and standard deviation. .. note:: This transform acts out of place by default, i.e., it does not mutates the input tensor. See :class:`~torchvision.transforms.Normalize` for more details. Args: tensor (Tensor): Tensor image of size (C, H, W) or (B, C, H, W) to be normalized. mean (seq...
13,262
import torch import numpy as np import cv2 from .models import hmr class constants: FOCAL_LENGTH = 5000. IMG_RES = 224 # Mean and standard deviation for normalizing input image IMG_NORM_MEAN = [0.485, 0.456, 0.406] IMG_NORM_STD = [0.229, 0.224, 0.225] class Normalize(torch.nn.Module): """Normali...
Read image, do preprocessing and possibly crop it according to the bounding box. If there are bounding box annotations, use them to crop the image. If no bounding box is specified but openpose detections are available, use them to get the bounding box.
13,263
import torch import numpy as np import cv2 from .models import hmr 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 A[2*nj + 1, 1] = 1 ...
null
13,264
import torch import numpy as np import cv2 from .models import hmr def estimate_translation_np(S, joints_2d, joints_conf, K): def init_with_spin(body_model, spin_model, img, bbox, kpts, camera): body_params = spin_model.forward(img.copy(), bbox) body_params = body_model.check_params(body_params) # only use...
null
13,265
import numpy as np import cv2 import mediapipe as mp from ..mytools import Timer The provided code snippet includes necessary dependencies for implementing the `bbox_from_keypoints` function. Write a Python function `def bbox_from_keypoints(keypoints, rescale=1.2, detection_thresh=0.05, MIN_PIXEL=5)` to solve the foll...
Get center and scale for bounding box from openpose detections.
13,266
import numpy as np import cv2 import mediapipe as mp from ..mytools import Timer class Detector: def __init__(self, nViews, to_openpose, model_type, show=False, **cfg) -> None: def to_array(pose, W, H, start=0): def get_body(self, pose, W, H): def get_hand(self, pose, W, H): def get_face(self, ...
null
13,267
import sys import os import time import math import numpy as np import itertools import struct import imghdr def sigmoid(x): return 1.0 / (np.exp(-x) + 1.)
null
13,268
import sys import os import time import math import numpy as np import itertools import struct import imghdr def softmax(x): x = np.exp(x - np.expand_dims(np.max(x, axis=1), axis=1)) x = x / np.expand_dims(x.sum(axis=1), axis=1) return x
null
13,269
import sys import os import time import math import numpy as np import itertools import struct import imghdr def bbox_iou(box1, box2, x1y1x2y2=True): # print('iou box1:', box1) # print('iou box2:', box2) if x1y1x2y2: mx = min(box1[0], box2[0]) Mx = max(box1[2], box2[2]) my = ...
null
13,270
import sys import os import time import math import numpy as np import itertools import struct import imghdr def plot_boxes_cv2(img, boxes, savename=None, class_names=None, color=None): import cv2 img = np.copy(img) colors = np.array([[1, 0, 1], [0, 0, 1], [0, 1, 1], [0, 1, 0], [1, 1, 0], [1, 0, 0]], dtyp...
null
13,271
import sys import os import time import math import numpy as np import itertools import struct import imghdr def read_truths(lab_path): if not os.path.exists(lab_path): return np.array([]) if os.path.getsize(lab_path): truths = np.loadtxt(lab_path) truths = truths.reshape(truths.size /...
null
13,272
import sys import os import time import math import numpy as np import itertools import struct import imghdr def nms_cpu(boxes, confs, nms_thresh=0.5, min_mode=False): # print(boxes.shape) x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] y2 = boxes[:, 3] areas = (x2 - x1) * (y2 - y1) ord...
null
13,273
import sys import os import time import math import torch import numpy as np from torch.autograd import Variable def get_region_boxes(boxes_and_confs): # print('Getting boxes from boxes and confs ...') boxes_list = [] confs_list = [] for item in boxes_and_confs: boxes_list.append(item[0]) ...
null
13,274
import sys import os import time import math import torch import numpy as np from torch.autograd import Variable def convert2cpu_long(gpu_matrix): return torch.LongTensor(gpu_matrix.size()).copy_(gpu_matrix)
null
13,275
import sys import os import time import math import torch import numpy as np from torch.autograd import Variable def do_detect(model, img, conf_thresh, nms_thresh, use_cuda=1): model.eval() t0 = time.time() if type(img) == np.ndarray and len(img.shape) == 3: # cv2 image img = torch.from_numpy(img...
null
13,276
import torch from .torch_utils import convert2cpu def parse_cfg(cfgfile): blocks = [] fp = open(cfgfile, 'r') block = None line = fp.readline() while line != '': line = line.rstrip() if line == '' or line[0] == '#': line = fp.readline() continue elif ...
null
13,277
import torch from .torch_utils import convert2cpu def print_cfg(blocks): print('layer filters size input output'); prev_width = 416 prev_height = 416 prev_filters = 3 out_filters = [] out_widths = [] out_heights = [] ind = -2 for block in blocks: ...
null
13,278
import torch from .torch_utils import convert2cpu def load_conv(buf, start, conv_model): num_w = conv_model.weight.numel() num_b = conv_model.bias.numel() conv_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b])); start = start + num_b conv_model.weight.data.copy_(torch.from_numpy(buf[...
null
13,279
import torch from .torch_utils import convert2cpu def convert2cpu(gpu_matrix): return torch.FloatTensor(gpu_matrix.size()).copy_(gpu_matrix) def save_conv(fp, conv_model): if conv_model.bias.is_cuda: convert2cpu(conv_model.bias.data).numpy().tofile(fp) convert2cpu(conv_model.weight.data).numpy...
null
13,280
import torch from .torch_utils import convert2cpu def load_conv_bn(buf, start, conv_model, bn_model): num_w = conv_model.weight.numel() num_b = bn_model.bias.numel() bn_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b])); start = start + num_b bn_model.weight.data.copy_(torch.from_num...
null
13,281
import torch from .torch_utils import convert2cpu def convert2cpu(gpu_matrix): return torch.FloatTensor(gpu_matrix.size()).copy_(gpu_matrix) def save_conv_bn(fp, conv_model, bn_model): if bn_model.bias.is_cuda: convert2cpu(bn_model.bias.data).numpy().tofile(fp) convert2cpu(bn_model.weight.data...
null
13,282
import torch from .torch_utils import convert2cpu def load_fc(buf, start, fc_model): num_w = fc_model.weight.numel() num_b = fc_model.bias.numel() fc_model.bias.data.copy_(torch.from_numpy(buf[start:start + num_b])); start = start + num_b fc_model.weight.data.copy_(torch.from_numpy(buf[start:start ...
null
13,283
import torch from .torch_utils import convert2cpu def save_fc(fp, fc_model): fc_model.bias.data.numpy().tofile(fp) fc_model.weight.data.numpy().tofile(fp)
null
13,284
import torch.nn as nn import torch.nn.functional as F from .torch_utils import * import math import torch from torch.autograd import Variable def bbox_ious(boxes1, boxes2, x1y1x2y2=True): def build_targets(pred_boxes, target, anchors, num_anchors, num_classes, nH, nW, noobject_scale, object_scale, ...
null
13,285
from .darknet2pytorch import Darknet import cv2 import torch from os.path import join import os import numpy as np def load_class_names(namesfile): class_names = [] with open(namesfile, 'r') as fp: lines = fp.readlines() for line in lines: line = line.rstrip() class_names.append(lin...
null
13,286
from .darknet2pytorch import Darknet import cv2 import torch from os.path import join import os import numpy as np def nms_cpu(boxes, confs, nms_thresh=0.5, min_mode=False): # print(boxes.shape) x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] y2 = boxes[:, 3] areas = (x2 - x1) * (y2 - y1) ...
null
13,287
import torch.nn as nn import torch.nn.functional as F from .torch_utils import * import torch from torch.autograd import Variable def yolo_forward(output, conf_thresh, num_classes, anchors, num_anchors, scale_x_y, only_objectness=1, validation=False): # Output would be invalid if it ...
null
13,288
import torch.nn as nn import torch.nn.functional as F from .torch_utils import * import torch from torch.autograd import Variable def yolo_forward_dynamic(output, conf_thresh, num_classes, anchors, num_anchors, scale_x_y, only_objectness=1, validation=False): # Output would be invali...
null
13,289
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet COCO17_IN_BODY25 = [0,16,15,18,17,5,2,6,3,7,4,12,9,13,10,14,11] import math def coco17tobody25(points2d): kpts = np.zeros((points2d.shape[0], 25, 3)) kpts[:, COCO17_IN_BODY...
null
13,290
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet tmp_size = sigma * 3 size = 2 * tmp_size + 1 x = np.arange(0, size, 1, np.float32) y = x[:, np.newaxis] x0 = y0 = size // 2 g = np.exp(- ((x - x0) ** 2 + (y ...
null
13,291
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet import math The provided code snippet includes necessary dependencies for implementing the `box_to_center_scale` function. Write a Python function `def box_to_center_scale(box, mod...
convert a box to center,scale information required for pose transformation Parameters ---------- box : list of tuple list of length 2 with two tuples of floats representing bottom left and top right corner of a box model_image_width : int model_image_height : int Returns ------- (numpy array, numpy array) Two numpy arr...
13,292
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet import math def affine_transform(pt, t): new_pt = np.array([pt[0], pt[1], 1.]).T new_pt = np.dot(t, new_pt) return new_pt[:2]
null
13,293
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet size = 2 * tmp_size + 1 def get_max_preds(batch_heatmaps): ''' get predictions from score maps heatmaps: numpy.ndarray([batch_size, num_joints, height, width]) '...
batch_image: [batch_size, channel, height, width] batch_heatmaps: ['batch_size, num_joints, height, width] file_name: saved file name
13,294
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet def get_max_preds(batch_heatmaps): def transform_preds(coords, center, scale, rot, output_size): import math def get_final_preds(batch_heatmaps, center, scale, rot=None, flip=None)...
null
13,295
from os.path import join import cv2 import numpy as np import torch from torchvision.transforms import transforms from .hrnet import HRNet gauss = import math def get_gaussian_maps(net_out, keypoints, sigma): radius, kernel = gauss[sigma]['radius'], gauss[sigma]['kernel'] weights = np.ones(net_out.shape, dtype...
null
13,296
import os import shutil from tqdm import tqdm from .wrapper_base import bbox_from_keypoints, create_annot_file, check_result from ..mytools import read_json from ..annotator.file_utils import save_annot from os.path import join import numpy as np import cv2 from glob import glob from multiprocessing import Process def ...
null
13,297
import os import shutil from tqdm import tqdm from .wrapper_base import bbox_from_keypoints, create_annot_file, check_result from ..mytools import read_json from ..annotator.file_utils import save_annot from os.path import join import numpy as np import cv2 from glob import glob from multiprocessing import Process def...
null
13,298
import os import shutil from tqdm import tqdm from .wrapper_base import bbox_from_keypoints, create_annot_file, check_result from ..mytools import read_json from ..annotator.file_utils import save_annot from os.path import join import numpy as np import cv2 from glob import glob from multiprocessing import Process def...
null
13,299
import os import shutil from tqdm import tqdm from .wrapper_base import bbox_from_keypoints, create_annot_file, check_result from ..mytools import read_json from ..annotator.file_utils import save_annot from os.path import join import numpy as np import cv2 from glob import glob from multiprocessing import Process def...
null
13,300
import numpy as np def dist_pl(query_points, line, moment): moment_q = moment - np.cross(query_points, line) dist = np.linalg.norm(moment_q, axis=1) return dist
null
13,301
import numpy as np def reciprocal_product(l1, m1, l2, m2): l1 = l1[:, None] m1 = m1[:, None] l2 = l2[None, :] m2 = m2[None, :] product = np.sum(l1*m2, axis=2) + np.sum(l2*m1, axis=2) return np.abs(product)
null
13,302
import numpy as np def dist_pl_pointwise(p0, p1): moment_q = p1[..., 3:6] - np.cross(p0[..., :3], p1[..., :3]) dist = np.linalg.norm(moment_q, axis=-1) return dist
null
13,303
import numpy as np def dist_ll_pointwise(p0, p1): product = np.sum(p0[..., :3] * p1[..., 3:6], axis=-1) + np.sum(p1[..., :3] * p0[..., 3:6], axis=-1) return np.abs(product) def dist_ll_pointwise_conf(p0, p1): dist = dist_ll_pointwise(p0, p1) conf = np.sqrt(p0[..., -1] * p1[..., -1]) dist = np.sum(d...
null
13,304
import numpy as np def plucker_from_pp(point1, point2): line = point2 - point1 return plucker_from_pl(point1, line) def computeRay(keypoints2d, invK, R, T): # 将点转为世界坐标系下plucker坐标 # points: (nJoints, 3) # invK: (3, 3) # R: (3, 3) # T: (3, 1) # cam_center: (3, 1) if len(keypoints2d.sh...
null
13,305
import numpy as np def plucker_from_pp(point1, point2): def computeRaynd(keypoints2d, invK, R, T): # keypoints2d: (..., 3) conf = keypoints2d[..., 2:] # cam_center: (1, 3) cam_center = - (R.T @ T).T kp_pixel = np.concatenate([keypoints2d[..., :2], np.ones_like(conf)], axis=-1) kp_all_3d = (kp_p...
null