id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
14,331
import numpy as np import trimesh from trimesh.proximity import closest_point from .mesh_eval import compute_similarity_transform The provided code snippet includes necessary dependencies for implementing the `keypoint_accel_error` function. Write a Python function `def keypoint_accel_error(gt, pred, mask=None)` to so...
Computes acceleration error: Note that for each frame that is not visible, three entries in the acceleration error should be zero'd out. Args: gt (Nx14x3). pred (Nx14x3). mask (N). Returns: error_accel (N-2).
14,332
import numpy as np import trimesh from trimesh.proximity import closest_point from .mesh_eval import compute_similarity_transform def compute_similarity_transform(source_points, target_points, return_tform=False): """Computes a similarity transform ...
Computes per vertex error (PVE). Args: verts_gt (N x verts_num x 3). verts_pred (N x verts_num x 3). alignment (str, optional): method to align the prediction with the groundtruth. Supported options are: - ``'none'``: no alignment will be applied - ``'scale'``: align in the least-square sense in scale - ``'procrustes'`...
14,333
import numpy as np import trimesh from trimesh.proximity import closest_point from .mesh_eval import compute_similarity_transform def compute_similarity_transform(source_points, target_points, return_tform=False): """Computes a similarity transform ...
Calculate the Percentage of Correct Keypoints (3DPCK) w. or w/o rigid alignment. Paper ref: `Monocular 3D Human Pose Estimation In The Wild Using Improved CNN Supervision' 3DV'2017. <https://arxiv.org/pdf/1611.09813>`__ . Note: - batch_size: N - num_keypoints: K - keypoint_dims: C Args: pred (np.ndarray[N, K, C]): Pred...
14,334
import numpy as np import trimesh from trimesh.proximity import closest_point from .mesh_eval import compute_similarity_transform def compute_similarity_transform(source_points, target_points, return_tform=False): """Computes a similarity transform ...
Calculate the Area Under the Curve (3DAUC) computed for a range of 3DPCK thresholds. Paper ref: `Monocular 3D Human Pose Estimation In The Wild Using Improved CNN Supervision' 3DV'2017. <https://arxiv.org/pdf/1611.09813>`__ . This implementation is derived from mpii_compute_3d_pck.m, which is provided as part of the MP...
14,335
import numpy as np import trimesh from trimesh.proximity import closest_point from .mesh_eval import compute_similarity_transform def compute_similarity_transform(source_points, target_points, return_tform=False): """Computes a similarity transform ...
This script computes the reconstruction error between an input mesh and a ground truth mesh. Args: groundtruth_vertices (np.ndarray[N,3]): Ground truth vertices. grundtruth_landmark_points (np.ndarray[7,3]): Ground truth annotations. predicted_mesh_vertices (np.ndarray[M,3]): Predicted vertices. predicted_mesh_faces (n...
14,336
from mmcv.utils import Registry POST_PROCESSING = Registry('post_processing') The provided code snippet includes necessary dependencies for implementing the `build_post_processing` function. Write a Python function `def build_post_processing(cfg)` to solve the following problem: Build post processing function. Here i...
Build post processing function.
14,337
import math import warnings import numpy as np import torch from ..builder import POST_PROCESSING def smoothing_factor(t_e, cutoff): r = 2 * math.pi * cutoff * t_e return r / (r + 1)
null
14,338
import math import warnings import numpy as np import torch from ..builder import POST_PROCESSING def exponential_smoothing(a, x, x_prev): return a * x + (1 - a) * x_prev
null
14,339
import copy import math from typing import Optional import numpy as np import torch import torch.nn.functional as F from mmcv.runner import load_checkpoint from torch import Tensor, nn from mmhuman3d.utils.transforms import ( aa_to_rotmat, rot6d_to_rotmat, rotmat_to_aa, rotmat_to_rot6d, ) from ..builder...
null
14,340
import copy import math from typing import Optional import numpy as np import torch import torch.nn.functional as F from mmcv.runner import load_checkpoint from torch import Tensor, nn from mmhuman3d.utils.transforms import ( aa_to_rotmat, rot6d_to_rotmat, rotmat_to_aa, rotmat_to_rot6d, ) from ..builder...
null
14,341
import copy import math from typing import Optional import numpy as np import torch import torch.nn.functional as F from mmcv.runner import load_checkpoint from torch import Tensor, nn from mmhuman3d.utils.transforms import ( aa_to_rotmat, rot6d_to_rotmat, rotmat_to_aa, rotmat_to_rot6d, ) from ..builder...
Return an activation function given a string.
14,342
import warnings from typing import Iterable, List, Optional, Tuple, Union import numpy as np import torch from mmhuman3d.utils.transforms import ee_to_rotmat, rotmat_to_ee The provided code snippet includes necessary dependencies for implementing the `convert_K_4x4_to_3x3` function. Write a Python function `def conver...
Convert opencv 4x4 intrinsic matrix to 3x3. Args: K (Union[torch.Tensor, np.ndarray]): Input 4x4 intrinsic matrix, left mm defined. for perspective: [[fx, 0, px, 0], [0, fy, py, 0], [0, 0, 0, 1], [0, 0, 1, 0]] for orthographics: [[fx, 0, 0, px], [0, fy, 0, py], [0, 0, 1, 0], [0, 0, 0, 1]] is_perspective (bool, optional...
14,343
from typing import Tuple, Union import numpy as np import torch from .convert_convention import convert_camera_matrix def convert_camera_matrix( K: Optional[Union[torch.Tensor, np.ndarray]] = None, R: Optional[Union[torch.Tensor, np.ndarray]] = None, T: Optional[Union[torch.Tensor, np.ndarray]] = None, ...
Convert perspective to weakperspective intrinsic matrix. Args: K (Union[torch.Tensor, np.ndarray]): input intrinsic matrix, shape should be (batch, 4, 4) or (batch, 3, 3). zmean (Union[torch.Tensor, np.ndarray, int, float]): zmean for object. shape should be (batch, ) or singleton number. resolution (Union[int, Tuple[i...
14,344
import numpy as np from mmhuman3d.utils.transforms import aa_to_rotmat, rotmat_to_aa def aa_to_rotmat( axis_angle: Union[torch.Tensor, numpy.ndarray] ) -> Union[torch.Tensor, numpy.ndarray]: """ Convert axis_angle to rotation matrixs. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input...
Transform body model parameters to camera frame. Args: global_orient (numpy.ndarray): shape (3, ). Only global_orient and transl needs to be updated in the rigid transformation transl (numpy.ndarray): shape (3, ). pelvis (numpy.ndarray): shape (3, ). 3D joint location of pelvis This is necessary to eliminate the offset...
14,345
import numpy as np from mmhuman3d.utils.transforms import aa_to_rotmat, rotmat_to_aa def aa_to_rotmat( axis_angle: Union[torch.Tensor, numpy.ndarray] ) -> Union[torch.Tensor, numpy.ndarray]: """ Convert axis_angle to rotation matrixs. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input...
Transform body model parameters to camera frame by batch. Args: global_orient (np.ndarray): shape (N, 3). Only global_orient and transl needs to be updated in the rigid transformation transl (np.ndarray): shape (N, 3). pelvis (np.ndarray): shape (N, 3). 3D joint location of pelvis This is necessary to eliminate the off...
14,346
from typing import Optional import numpy as np import torch from smplx import SMPL as _SMPL from smplx.lbs import ( batch_rigid_transform, blend_shapes, transform_mat, vertices2joints, ) from mmhuman3d.core.conventions.keypoints_mapping import ( convert_kps, get_keypoint_num, ) from mmhuman3d.co...
null
14,347
from typing import Optional import numpy as np import torch from smplx import SMPL as _SMPL from smplx.lbs import ( batch_rigid_transform, blend_shapes, transform_mat, vertices2joints, ) from mmhuman3d.core.conventions.keypoints_mapping import ( convert_kps, get_keypoint_num, ) from mmhuman3d.co...
null
14,348
import torch import torch.nn as nn from .utils import weighted_loss The provided code snippet includes necessary dependencies for implementing the `smooth_l1_loss` function. Write a Python function `def smooth_l1_loss(pred, target, beta=1.0)` to solve the following problem: Smooth L1 loss. Args: pred (torch.Tensor): T...
Smooth L1 loss. Args: pred (torch.Tensor): The prediction. target (torch.Tensor): The learning target of the prediction. beta (float, optional): The threshold in the piecewise function. Defaults to 1.0. Returns: torch.Tensor: Calculated loss
14,349
import torch import torch.nn as nn from .utils import weighted_loss The provided code snippet includes necessary dependencies for implementing the `l1_loss` function. Write a Python function `def l1_loss(pred, target)` to solve the following problem: L1 loss. Args: pred (torch.Tensor): The prediction. target (torch.Te...
L1 loss. Args: pred (torch.Tensor): The prediction. target (torch.Tensor): The learning target of the prediction. Returns: torch.Tensor: Calculated loss
14,350
import functools import torch import torch.nn.functional as F def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): """Apply element-wise weight and reduce loss. Args: loss (Tensor): Element-wise loss. weight (Tensor): Element-wise weights. reduction (str): Same a...
Create a weighted version of a given loss function. To use this decorator, the loss function must have the signature like `loss_func(pred, target, **kwargs)`. The function only needs to compute element-wise loss without any reduction. This decorator will add weight and reduction arguments to the function. The decorated...
14,351
import functools import torch import torch.nn.functional as F The provided code snippet includes necessary dependencies for implementing the `convert_to_one_hot` function. Write a Python function `def convert_to_one_hot(targets: torch.Tensor, classes) -> torch.Tensor` to solve the following problem: This function conv...
This function converts target class indices to one-hot vectors, given the number of classes. Args: targets (Tensor): The ground truth label of the prediction with shape (N, 1) classes (int): the number of classes. Returns: Tensor: Processed loss values.
14,352
import torch import torch.nn as nn import torch.nn.functional as F from .utils import weighted_loss def gmof(x, sigma): """Geman-McClure error function.""" x_squared = x**2 sigma_squared = sigma**2 return (sigma_squared * x_squared) / (sigma_squared + x_squared) def mse_loss(pred, target): """Warppe...
Extended MSE Loss with GMOF.
14,353
from typing import Optional, Union import torch import torch.distributed as dist import torch.nn.functional as F from mmcv.runner import get_dist_info from torch.nn.modules.loss import _Loss from .utils import weighted_loss The provided code snippet includes necessary dependencies for implementing the `bmc_loss_md` fu...
Args: pred (torch.Tensor): The prediction. Shape should be (N, L). target (torch.Tensor): The learning target of the prediction. noise_var (torch.Tensor): Noise var of ground truth distribution. all_gather (bool): Whether gather tensors across all sub-processes. Only used in DDP training scheme. loss_mse_weight (float,...
14,354
from mmcv.utils import Registry from .balanced_mse_loss import BMCLossMD from .cross_entropy_loss import CrossEntropyLoss from .gan_loss import GANLoss from .mse_loss import KeypointMSELoss, MSELoss from .prior_loss import ( CameraPriorLoss, JointPriorLoss, LimbLengthLoss, MaxMixturePrior, PoseRegLo...
Build loss.
14,355
import torch import torch.nn as nn import torch.nn.functional as F from .utils import weight_reduce_loss def weight_reduce_loss(loss, weight=None, reduction='mean', avg_factor=None): """Apply element-wise weight and reduce loss. Args: loss (Tensor): Element-wise loss. weight (Tensor): Element-...
Calculate the CrossEntropy loss. Args: pred (torch.Tensor): The prediction with shape (N, C), C is the number of classes. label (torch.Tensor): The learning label of the prediction. weight (torch.Tensor, optional): Sample-wise loss weight. reduction (str, optional): The method used to reduce the loss. avg_factor (int, ...
14,356
import torch import torch.nn as nn import torch.nn.functional as F from .utils import weight_reduce_loss def _expand_onehot_labels(labels, label_weights, label_channels, ignore_index): """Expand onehot labels to match the size of prediction.""" bin_labels = labels.new_full((labels.size(0), label_channels), 0) ...
Calculate the binary CrossEntropy loss. Args: pred (torch.Tensor): The prediction with shape (N, 1). label (torch.Tensor): The learning label of the prediction. weight (torch.Tensor, optional): Sample-wise loss weight. reduction (str, optional): The method used to reduce the loss. Options are "none", "mean" and "sum". ...
14,357
import torch import torch.nn as nn import torch.nn.functional as F from .utils import weight_reduce_loss The provided code snippet includes necessary dependencies for implementing the `mask_cross_entropy` function. Write a Python function `def mask_cross_entropy(pred, target, ...
Calculate the CrossEntropy loss for masks. Args: pred (torch.Tensor): The prediction with shape (N, C, *), C is the number of classes. The trailing * indicates arbitrary shape. target (torch.Tensor): The learning label of the prediction. label (torch.Tensor): ``label`` indicates the class label of the mask correspondin...
14,358
import torch import torch.nn as nn The provided code snippet includes necessary dependencies for implementing the `rotation_distance_loss` function. Write a Python function `def rotation_distance_loss(pred, target, epsilon)` to solve the following problem: Warpper of rotation distance loss. Here is the function: def...
Warpper of rotation distance loss.
14,359
from mmcv.utils import Registry from .temporal_encoder import TemporalGRUEncoder NECKS = Registry('necks') NECKS.register_module(name='TemporalGRUEncoder', module=TemporalGRUEncoder) The provided code snippet includes necessary dependencies for implementing the `build_neck` function. Write a Python function `def build...
Build neck.
14,360
from mmcv.utils import Registry from .pose_discriminator import ( FullPoseDiscriminator, PoseDiscriminator, ShapeDiscriminator, SMPLDiscriminator, ) DISCRIMINATORS = Registry('discriminators') DISCRIMINATORS.register_module( name='ShapeDiscriminator', module=ShapeDiscriminator) DISCRIMINATORS.regist...
Build discriminator.
14,361
from mmcv.utils import Registry from .smplify import SMPLify from .smplifyx import SMPLifyX REGISTRANTS = Registry('registrants') REGISTRANTS.register_module(name='SMPLify', module=SMPLify) REGISTRANTS.register_module(name='SMPLifyX', module=SMPLifyX) The provided code snippet includes necessary dependencies for imple...
Build registrant.
14,362
import numpy as np import torch import torch.cuda.comm import torch.nn as nn from mmcv.runner.base_module import BaseModule from torch.nn import functional as F from mmhuman3d.core.conventions.keypoints_mapping import get_flip_pairs The provided code snippet includes necessary dependencies for implementing the `norm_h...
Normalize heatmap. Args: norm_type (str): type of normalization. Currently only 'softmax' is supported heatmap (torch.Tensor): model output heatmap with shape (Bx29xF^2) where F^2 refers to number of squared feature channels F Returns: heatmap (torch.Tensor): normalized heatmap according to specified type with shape (B...
14,363
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner.base_module import BaseModule from torch.nn.modules.utils import _pair from mmhuman3d.utils.geometry import rot6d_to_rotmat The provided code snippet includes necessary dependencies for implementing the `interpolate`...
Args: feat (torch.Tensor): [B, C, H, W] image features uv (torch.Tensor): [B, 2, N] uv coordinates in the image plane, range [-1, 1] Returns: samples[:, :, :, 0] (torch.Tensor): [B, C, N] image features at the uv coordinates
14,364
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner.base_module import BaseModule from torch.nn.modules.utils import _pair from mmhuman3d.utils.geometry import rot6d_to_rotmat def _softmax(tensor, temperature, dim=-1): return F.softmax(tensor * temperature, dim=dim...
Softargmax layer for heatmaps.
14,365
import math import numpy as np import scipy import torch import torch.cuda.comm import torch.nn as nn from mmcv.runner.base_module import BaseModule from torch.nn import functional as F from mmhuman3d.core.conventions.keypoints_mapping.flame import ( FLAME_73_KEYPOINTS, ) from mmhuman3d.core.conventions.keypoints_m...
Get attention modules. Args: config_path (str): Attention config path. module_keys (list): Model name. img_feature_dim (dict): Image feature dimension. hidden_feat_dim (int): Attention feature dimension. n_iter (int): Number of iterations. num_attention_heads (int, optional): Defaults to 1. Returns: Attention modules
14,366
from mmcv.utils import Registry from .cliff_head import CliffHead from .expose_head import ExPoseBodyHead, ExPoseFaceHead, ExPoseHandHead from .hmr_head import HMRHead from .hybrik_head import HybrIKHead from .pare_head import PareHead from .pymafx_head import PyMAFXHead, Regressor HEADS = Registry('heads') HEADS.regis...
Build head.
14,367
import json import math import sys from io import open import torch from torch import nn from .modeling_utils import PretrainedConfig, PreTrainedModel The provided code snippet includes necessary dependencies for implementing the `gelu` function. Write a Python function `def gelu(x)` to solve the following problem: Im...
Implementation of the gelu activation function. For information: OpenAI GPT's gelu is slightly different (and gives slightly different results): 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * ( x + 0.044715 * torch.pow(x, 3)))) Also see https://arxiv.org/abs/1606.08415
14,368
import json import math import sys from io import open import torch from torch import nn from .modeling_utils import PretrainedConfig, PreTrainedModel def swish(x): return x * torch.sigmoid(x)
null
14,369
from abc import ABCMeta, abstractmethod from typing import Optional, Tuple, Union import torch import torch.nn.functional as F import mmhuman3d.core.visualization.visualize_smpl as visualize_smpl from mmhuman3d.core.conventions.keypoints_mapping import get_keypoint_idx from mmhuman3d.models.utils import FitsDict from m...
Set requies_grad for all the networks. Args: nets (nn.Module | list[nn.Module]): A list of networks or a single network. requires_grad (bool): Whether the networks require gradients or not
14,370
from abc import ABCMeta from typing import Optional, Union import torch import torch.nn as nn from mmhuman3d.core.conventions.keypoints_mapping.flame import ( FLAME_73_KEYPOINTS, ) from mmhuman3d.core.conventions.keypoints_mapping.mano import ( MANO_RIGHT_REORDER_KEYPOINTS, ) from mmhuman3d.models.body_models.s...
null
14,371
from abc import ABCMeta, abstractmethod from typing import Optional, Tuple, Union import torch import torch.nn.functional as F import mmhuman3d.core.visualization.visualize_smpl as visualize_smpl from mmhuman3d.core.conventions.keypoints_mapping import get_keypoint_idx from mmhuman3d.models.utils import FitsDict from m...
Set requies_grad for all the networks. Args: nets (nn.Module | list[nn.Module]): A list of networks or a single network. requires_grad (bool): Whether the networks require gradients or not
14,372
from abc import ABCMeta, abstractmethod from typing import Optional, Union import torch import torch.nn as nn import torch.nn.functional as F from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import ( batch_rodrigues, ...
Set requies_grad for all the networks. Args: nets (nn.Module | list[nn.Module]): A list of networks or a single network. requires_grad (bool): Whether the networks require gradients or not
14,373
from abc import ABCMeta, abstractmethod from typing import Optional, Union import torch import torch.nn as nn import torch.nn.functional as F from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import ( batch_rodrigues, ...
aa2rotmat.
14,374
from mmcv.cnn import MODELS as MMCV_MODELS from mmcv.utils import Registry from .cliff_mesh_estimator import CliffImageBodyModelEstimator from .expressive_mesh_estimator import SMPLXImageBodyModelEstimator from .hybrik import HybrIK_trainer from .mesh_estimator import ImageBodyModelEstimator, VideoBodyModelEstimator fr...
null
14,375
from abc import ABCMeta import torch from mmhuman3d.data.datasets.pipelines.hybrik_transforms import heatmap2coord from mmhuman3d.utils.transforms import rotmat_to_quat from ..backbones.builder import build_backbone from ..body_models.builder import build_body_model from ..heads.builder import build_head from ..losses....
Set requies_grad for all the networks. Args: nets (nn.Module | list[nn.Module]): A list of networks or a single network. requires_grad (bool): Whether the networks require gradients or not
14,376
import os from typing import List import numpy as np import torch import torch.nn.functional as F from smplx.utils import find_joint_kin_chain from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import weak_perspective_projectio...
Get the transformation of points on the cropped image to the points on the original image.
14,377
import os from typing import List import numpy as np import torch import torch.nn.functional as F from smplx.utils import find_joint_kin_chain from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import weak_perspective_projectio...
Concat images of different size.
14,378
import os from typing import List import numpy as np import torch import torch.nn.functional as F from smplx.utils import find_joint_kin_chain from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import weak_perspective_projectio...
Flip function. Flip rotmat.
14,379
import os from typing import List import numpy as np import torch import torch.nn.functional as F from smplx.utils import find_joint_kin_chain from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import weak_perspective_projectio...
Computes the absolute rotation of a joint from the kinematic chain.
14,380
import os from typing import List import numpy as np import torch import torch.nn.functional as F from smplx.utils import find_joint_kin_chain from mmhuman3d.core.conventions.keypoints_mapping import ( get_keypoint_idx, get_keypoint_idxs_by_part, ) from mmhuman3d.utils.geometry import weak_perspective_projectio...
Get partial mesh of SMPL. Returns: part_vert_faces
14,381
from __future__ import absolute_import, division, print_function import torch from mmhuman3d.utils.transforms import aa_to_rotmat def batch_get_pelvis_orient_svd(rel_pose_skeleton, rel_rest_pose, parents, children, dtype): """Get pelvis orientation svd for batch data. Args: ...
Applies inverse kinematics transform to joints in a batch. Args: pose_skeleton (torch.tensor): Locations of estimated pose skeleton with shape (Bx29x3) global_orient (torch.tensor|none): Tensor of global rotation matrices with shape (Bx1x3x3) phis (torch.tensor): Rotation on bone axis parameters with shape (Bx23x2) res...
14,382
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert axis_angle to quaternions. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 4).
14,383
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation matrixs to quaternions. Args: matrix (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3, 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 4).
14,384
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation matrixs to rotation 6d representations. Args: matrix (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3, 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 6). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotat...
14,385
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert quaternions to axis angles. Args: quaternions (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3).
14,386
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert quaternions to rotation matrixs. Args: quaternions (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3, 3).
14,387
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation 6d representations to rotation matrixs. Args: rotation_6d (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 6). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3, 3). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of ...
14,388
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert axis angles to euler angle. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Defaults to 'xyz'. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (...
14,389
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert axis angles to rotation 6d representations. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 6). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotation ...
14,390
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert euler angles to axis angles. Args: euler_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Defaults to 'xyz'. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be...
14,391
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert euler angles to quaternions. Args: euler_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Defaults to 'xyz'. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be...
14,392
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert euler angles to rotation 6d representation. Args: euler_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 3). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Defaults to 'xyz'. Returns: Union[torch.Tensor, numpy.ndarray]:...
14,393
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert quaternions to euler angles. Args: quaternions (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 4). ndim of input is unlimited. convention (str, optional): Convention string of three letters from {“x”, “y”, and “z”}. Defaults to 'xyz'. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be...
14,394
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert quaternions to rotation 6d representations. Args: quaternions (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 4). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 6). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotation...
14,395
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation 6d representations to axis angles. Args: rotation_6d (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 6). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotation...
14,396
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation 6d representations to euler angles. Args: rotation_6d (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 6). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 3). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotatio...
14,397
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert rotation 6d representations to quaternions. Args: rotation (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 6). ndim of input is unlimited. Returns: Union[torch.Tensor, numpy.ndarray]: shape would be (..., 4). [1] Zhou, Y., Barnes, C., Lu, J., Yang, J., & Li, H. On the Continuity of Rotation Re...
14,398
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert axis-angles to standard joint angles. Args: axis_angle (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 21, 3), ndim of input is unlimited. R_t (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 21, 3, 3). Transformation matrices from original axis-angle coordinate system to stan...
14,399
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger class Compose: def __init__(self, transforms: list): """Composes several transfor...
Convert standard joint angles to axis angles. Args: sja (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 21, 3). ndim of input is unlimited. R_t (Union[torch.Tensor, numpy.ndarray]): input shape should be (..., 21, 3, 3). Transformation matrices from original axis-angle coordinate system to standard jo...
14,400
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger The provided code snippet includes necessary dependencies for implementing the `make_homegen...
Appends a row of [0,0,0,1] to a batch size x 3 x 4 Tensor. Parameters ---------- :param input: A tensor of dimensions batch size x 3 x 4 :return: A tensor batch size x 4 x 4 (appended with 0,0,0,1)
14,401
from typing import Union import numpy import torch from mmhuman3d.core.conventions.joints_mapping.standard_joint_angles import ( TRANSFORMATION_AA_TO_SJA, TRANSFORMATION_SJA_TO_AA, ) from .logger import get_root_logger The provided code snippet includes necessary dependencies for implementing the `make_homegen...
Appends a row of [0,0,0,1] to a 3 x 4 Tensor. Parameters ---------- :param input: A tensor of dimensions 3 x 4 :return: A tensor batch size x 4 x 4 (appended with 0,0,0,1)
14,402
import copy import os from typing import Iterable, Optional, Union import numpy as np import torch from pytorch3d.renderer.cameras import CamerasBase from mmhuman3d.core.cameras import build_cameras from mmhuman3d.core.conventions.cameras.convert_convention import ( convert_camera_matrix, convert_world_view, ) ...
Convert opencv calibration smpl poses&transl parameters to model based poses&transl or verts. Args: R (Union[np.ndarray, torch.Tensor]): (frame, 3, 3) T (Union[np.ndarray, torch.Tensor]): [(frame, 3) K (Optional[Union[np.ndarray, torch.Tensor]], optional): (frame, 3, 3) or (frame, 4, 4). Defaults to None. resolution (O...
14,403
import copy import os from typing import Iterable, Optional, Union import numpy as np import torch from pytorch3d.renderer.cameras import CamerasBase from mmhuman3d.core.cameras import build_cameras from mmhuman3d.core.conventions.cameras.convert_convention import ( convert_camera_matrix, convert_world_view, ) ...
Project 3d points to image. Args: points3d (Union[np.ndarray, torch.Tensor]): shape could be (..., 3). cameras (CamerasBase): pytorch3d cameras or mmhuman3d cameras. resolution (Iterable[int]): (height, width) for rectangle or width for square. K (Union[torch.Tensor, np.ndarray], optional): intrinsic matrix. Defaults t...
14,404
import copy import os from typing import Iterable, Optional, Union import numpy as np import torch from pytorch3d.renderer.cameras import CamerasBase from mmhuman3d.core.cameras import build_cameras from mmhuman3d.core.conventions.cameras.convert_convention import ( convert_camera_matrix, convert_world_view, ) ...
vector: B x N x C h_vector: B x N x (C + 1)
14,405
from mmcv.utils import collect_env as collect_base_env from mmcv.utils import get_git_hash import mmhuman3d The provided code snippet includes necessary dependencies for implementing the `collect_env` function. Write a Python function `def collect_env()` to solve the following problem: Collect the information of the r...
Collect the information of the running environments.
14,406
import warnings from typing import List, Optional, Union import torch from pytorch3d.io import IO from pytorch3d.io import load_objs_as_meshes as _load_objs_as_meshes from pytorch3d.io import save_obj from pytorch3d.renderer import TexturesUV, TexturesVertex from pytorch3d.structures import ( Meshes, Pointcloud...
Join `meshes` as a scene each batch. Only for Pytorch3D `meshes`. The Meshes must share the same batch size, and topology could be different. They must all be on the same device. If `include_textures` is true, the textures should be the same type, all be None is not accepted. If `include_textures` is False, textures ar...
14,407
import warnings from typing import List, Optional, Union import torch from pytorch3d.io import IO from pytorch3d.io import load_objs_as_meshes as _load_objs_as_meshes from pytorch3d.io import save_obj from pytorch3d.renderer import TexturesUV, TexturesVertex from pytorch3d.structures import ( Meshes, Pointcloud...
Convert PyTorch3D vertex color `Meshes` to `PointClouds`. Args: meshes (Meshes): input meshes. include_textures (bool, optional): Whether include colors. Require the texture of input meshes is vertex color. Defaults to True. alpha (float, optional): transparency. Defaults to 1.0. Returns: Pointclouds: output pointcloud...
14,408
import warnings from typing import List, Optional, Union import torch from pytorch3d.io import IO from pytorch3d.io import load_objs_as_meshes as _load_objs_as_meshes from pytorch3d.io import save_obj from pytorch3d.renderer import TexturesUV, TexturesVertex from pytorch3d.structures import ( Meshes, Pointcloud...
Convert a Pytorch3D meshes's textures from TexturesUV to TexturesVertex. Args: meshes (Meshes): input Meshes. Returns: Meshes: converted Meshes.
14,409
import warnings from typing import List, Optional, Union import torch from pytorch3d.io import IO from pytorch3d.io import load_objs_as_meshes as _load_objs_as_meshes from pytorch3d.io import save_obj from pytorch3d.renderer import TexturesUV, TexturesVertex from pytorch3d.structures import ( Meshes, Pointcloud...
null
14,410
import warnings from typing import List, Optional, Union import torch from pytorch3d.io import IO from pytorch3d.io import load_objs_as_meshes as _load_objs_as_meshes from pytorch3d.io import save_obj from pytorch3d.renderer import TexturesUV, TexturesVertex from pytorch3d.structures import ( Meshes, Pointcloud...
null
14,411
import colorsys import os from collections import defaultdict from contextlib import contextmanager from functools import partial from pathlib import Path import mmcv import numpy as np from mmcv import Timer from scipy import interpolate from mmhuman3d.core.post_processing import build_post_processing The provided co...
Prepare frames from input_path. Args: input_path (str, optional): Defaults to None. Raises: ValueError: check the input path. Returns: List[np.ndarray]: prepared frames
14,412
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def pad_for_libx264(image_array): """Pad zeros...
Convert an array to a video directly, gif not supported. Args: image_array (np.ndarray): shape should be (f * h * w * 3). output_path (str): output video file path. fps (Union[int, float, optional): fps. Defaults to 30. resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]], optional): (height, width) of the...
14,413
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path class vid_info_reader(object): def __init__(se...
Convert a video to a gif file. Args: input_path (str): video file path. output_path (str): gif file path. resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]], optional): (height, width) of the output video. Defaults to None. fps (Union[float, int], optional): frames per second. Defaults to 15. disable_log...
14,414
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def prepare_output_path(output_path: str, ...
Convert series of images to a video, similar to images_to_video, but provide more suitable parameters. Args: input_folder (str): input image folder. output_path (str): output gif file path. remove_raw_file (bool, optional): whether remove raw images. Defaults to False. img_format (str, optional): format to name the ima...
14,415
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def prepare_output_path(output_path: str, ...
Convert a gif file to a video. Args: input_path (str): input gif file path. output_path (str): output video file path. fps (int, optional): fps. Defaults to 30. remove_raw_file (bool, optional): whether remove original input file. Defaults to False. down_sample_scale (Union[int, float], optional): down sample scale. De...
14,416
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def prepare_output_path(output_path: str, ...
Convert a gif file to a folder of images. Args: input_path (str): input gif file path. output_folder (str): output folder to save the images. fps (int, optional): fps. Defaults to 30. img_format (str, optional): output image name format. Defaults to '%06d.png'. resolution (Optional[Union[Tuple[int, int], Tuple[float, f...
14,417
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path class vid_info_reader(object): def __init__(se...
Spatially or temporally crop a video or gif file. Args: input_path (str): input video or gif file path. output_path (str): output video or gif file path. box (Iterable[int], optional): [x, y of the crop region left. corner and width and height]. Defaults to [0, 0, 100, 100]. resolution (Optional[Union[Tuple[int, int], ...
14,418
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path class vid_info_reader(object): def __init__(se...
Temporally crop a video/gif into another video/gif. Args: input_path (str): input video or gif file path. output_path (str): output video of gif file path. start (int, optional): start frame index. Defaults to 0. end (int, optional): end frame index. Exclusive. Could be positive int or negative int or None. If None, al...
14,419
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def prepare_output_path(output_path: str, ...
Spatially concat some videos as an array video. Args: input_path_list (list): input video or gif file list. output_path (str): output video or gif file path. array (List[int], optional): line number and column number of the video array]. Defaults to [1, 1]. direction (str, optional): [choose in 'h' or 'v', represent ho...
14,420
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path def prepare_output_path(output_path: str, ...
Concat no matter videos or gifs into a temporal sequence, and save as a new video or gif file. Args: input_path_list (List[str]): list of input video paths. output_path (str): output video file path. resolution (Optional[Union[Tuple[int, int], Tuple[float, float]]] , optional): (height, width) of output]. Defaults to (...
14,421
import glob import json import os import shutil import string import subprocess import sys from pathlib import Path from typing import Iterable, List, Optional, Tuple, Union import numpy as np from mmhuman3d.utils.path_utils import check_input_path, prepare_output_path class vid_info_reader(object): def __init__(se...
Compress a video file. Args: input_path (str): input video file path. output_path (str): output video file path. compress_rate (int, optional): compress rate, influents the bit rate. Defaults to 1. down_sample_scale (Union[float, int], optional): spatial down sample scale. Defaults to 1. fps (int, optional): Frames per...
14,422
from collections import OrderedDict import torch.distributed as dist from mmcv.runner import OptimizerHook from torch._utils import ( _flatten_dense_tensors, _take_tensors, _unflatten_dense_tensors, ) def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): if bucket_size_mb > 0: bucket...
null
14,423
from functools import partial import torch def multi_apply(func, *args, **kwargs): pfunc = partial(func, **kwargs) if kwargs else func map_results = map(pfunc, *args) return tuple(map(list, zip(*map_results)))
null
14,424
from functools import partial import torch def torch_to_numpy(x): assert isinstance(x, torch.Tensor) return x.detach().cpu().numpy()
null
14,425
from typing import Optional, Tuple, Union import numpy as np import torch from mmhuman3d.core.conventions.keypoints_mapping import KEYPOINTS_FACTORY from mmhuman3d.core.conventions.keypoints_mapping.human_data import ( HUMAN_DATA_LIMBS_INDEX, HUMAN_DATA_PALETTE, ) The provided code snippet includes necessary d...
Process gt 2D keypoints and apply transforms.
14,426
import numpy as np import torch from einops.einops import rearrange 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 repres...
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
14,427
import numpy as np import torch from einops.einops import rearrange 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. Adapte...
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) # Nx3x4 >...
14,428
import numpy as np import torch from einops.einops import rearrange from torch.nn import functional as F def estimate_translation_np(S, joints_2d, joints_conf, focal_length=5000, img_size=224): """Find ca...
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
14,429
import numpy as np import torch from einops.einops import rearrange from torch.nn import functional as F def perspective_projection(points, rotation, translation, focal_length, camera_center): """This function computes the perspective projection of a set of points. Input: poin...
Perform orthographic projection of 3D points using the camera parameters, return projected 2D points in image plane. Notes: batch size: B point number: N Args: points_3d (Tensor([B, N, 3])): 3D points. camera (Tensor([B, 3])): camera parameters with the 3 channel as (scale, translation_x, translation_y) Returns: points...
14,430
import numpy as np import torch from einops.einops import rearrange from torch.nn import functional as F The provided code snippet includes necessary dependencies for implementing the `weak_perspective_projection` function. Write a Python function `def weak_perspective_projection(points, scale, translation)` to solve ...
This function computes the weak perspective projection of a set of points. Input: points (bs, N, 3): 3D points scale (bs,1): scalar translation (bs, 2): point 2D translation