id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
15,751 | import numpy as np
from scipy import interpolate
import torch
import torch.nn as nn
import torch.utils.checkpoint as checkpoint
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
The provided code snippet includes necessary dependencies for implementing the `window_reverse` function. Write a Python func... | Args: windows: (num_windows*B, window_size, window_size, C) window_size (int): Window size H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C) |
15,752 | import os
from collections import OrderedDict
from timm.models.layers import DropPath
import torch
from torch import nn
from torch.nn import MultiheadAttention
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
_MODELS = {
"ViT-B/16": os.path.join(MODEL_PATH, "vit_b16.pth"),
"ViT-L/14":... | null |
15,753 | import os
from collections import OrderedDict
from timm.models.layers import DropPath
import torch
from torch import nn
from torch.nn import MultiheadAttention
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
_MODELS = {
"ViT-B/16": os.path.join(MODEL_PATH, "vit_b16.pth"),
"ViT-L/14":... | null |
15,754 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,755 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,756 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,757 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,758 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,759 | import abc
from typing import Optional
import os
import requests
from PIL import Image
from io import BytesIO
import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from torchvision.transforms.functional import InterpolationMode
from transfor... | null |
15,761 | import logging
import os
from fvcore.common.timer import Timer
from detectron2.structures import BoxMode
from fvcore.common.file_io import PathManager
from detectron2.data import DatasetCatalog, MetadataCatalog
from lvis import LVIS
def load_GRiTcoco_json(json_file, image_root, dataset_name=None):
def register_GRiTcoc... | null |
15,765 | import logging
import os
from fvcore.common.timer import Timer
from detectron2.structures import BoxMode
from fvcore.common.file_io import PathManager
from detectron2.data import DatasetCatalog, MetadataCatalog
from lvis import LVIS
def load_o365_json(json_file, image_root, dataset_name=None):
'''
Load Object36... | null |
15,773 | import logging
import math
import fvcore.nn.weight_init as weight_init
import torch
import torch.nn as nn
from functools import partial
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
from detectron2.modeling.backbone.build import BACKBONE_REGISTRY
from detectron2.layers import ShapeSpec
from centernet.mod... | null |
15,774 | import logging
import math
import fvcore.nn.weight_init as weight_init
import torch
import torch.nn as nn
from functools import partial
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
from detectron2.modeling.backbone.build import BACKBONE_REGISTRY
from detectron2.layers import ShapeSpec
from centernet.mod... | null |
15,775 | import logging
import math
import fvcore.nn.weight_init as weight_init
import torch
import torch.nn as nn
from functools import partial
from detectron2.layers import CNNBlockBase, Conv2d, get_norm
from detectron2.modeling.backbone.build import BACKBONE_REGISTRY
from detectron2.layers import ShapeSpec
from centernet.mod... | null |
15,785 | import argparse
import multiprocessing as mp
import os
import time
import cv2
import tqdm
import sys
from detectron2.config import get_cfg
from detectron2.data.detection_utils import read_image
from detectron2.utils.logger import setup_logger
from centernet.config import add_centernet_config
from ..grit_src.grit.config... | null |
15,786 | import argparse
import multiprocessing as mp
import os
import time
import cv2
import tqdm
import sys
from detectron2.config import get_cfg
from detectron2.data.detection_utils import read_image
from detectron2.utils.logger import setup_logger
from centernet.config import add_centernet_config
from ..grit_src.grit.config... | null |
15,787 | import argparse
import multiprocessing as mp
import os
import time
import cv2
import tqdm
import sys
from detectron2.config import get_cfg
from detectron2.data.detection_utils import read_image
from detectron2.utils.logger import setup_logger
from centernet.config import add_centernet_config
from ..grit_src.grit.config... | null |
15,806 | import contextlib
from unittest import mock
import torch
from detectron2.modeling import poolers
from detectron2.modeling.proposal_generator import rpn
from detectron2.modeling.roi_heads import keypoint_head, mask_head
from detectron2.modeling.roi_heads.fast_rcnn import FastRCNNOutputLayers
from .c10 import (
Caffe... | null |
15,816 | import collections
import contextlib
import copy
import functools
import logging
import numpy as np
import os
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from unittest import mock
import caffe2.python.utils as putils
import torch
import torch.nn.functional as F
from caffe2.proto import caffe2_p... | null |
15,856 | import os
from detectron2.data import DatasetCatalog, MetadataCatalog
from .builtin_meta import ADE20K_SEM_SEG_CATEGORIES, _get_builtin_metadata
from .cityscapes import load_cityscapes_instances, load_cityscapes_semantic
from .cityscapes_panoptic import register_all_cityscapes_panoptic
from .coco import load_sem_seg, r... | null |
15,942 | import logging
import os
from collections import OrderedDict
import torch
from torch.nn.parallel import DistributedDataParallel
import time
import datetime
import json
from fvcore.common.timer import Timer
import detectron2.utils.comm as comm
from detectron2.checkpoint import DetectionCheckpointer, PeriodicCheckpointer... | null |
16,002 | import logging
import os
import time
import weakref
from collections import OrderedDict
from typing import Any, Dict, List
import detectron2.utils.comm as comm
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import get_cfg
from detectron2.data import build_detection_test_loader, build_det... | null |
16,015 | import itertools
import logging
import psutil
import torch
import tqdm
from fvcore.common.timer import Timer
from torch.nn.parallel import DistributedDataParallel
from detectron2.checkpoint import DetectionCheckpointer
from detectron2.config import LazyConfig, get_cfg, instantiate
from detectron2.data import (
Data... | null |
16,020 | import torch
import os
import sys
import argparse
import importlib
from tensorboardX import SummaryWriter
from data_loader import get_dataloader
from itertools import cycle
from py_utils import write_loss, print_composite, to_float
from probe.latent_plot_utils import get_all_plots
from trainer import Trainer
def parse... | null |
16,021 | import torch
import os
import sys
import argparse
import importlib
import numpy as np
from os.path import join as pjoin
from data_loader import get_dataloader
from latent_plot_utils import get_all_plots, get_demo_plots
from trainer import Trainer
from py_utils import to_float, ensure_dirs
def get_all_codes(cfg, output_... | null |
16,022 | import torch
import os
import sys
import argparse
import importlib
import numpy as np
from os.path import join as pjoin
BASEPATH = os.path.dirname(__file__)
from data_loader import get_dataloader
from latent_plot_utils import get_all_plots, get_demo_plots
from trainer import Trainer
from py_utils import to_float, ensur... | null |
16,023 | import torch
import os
import sys
import argparse
import importlib
import numpy as np
from os.path import join as pjoin
from data_loader import get_dataloader
from latent_plot_utils import get_all_plots, get_demo_plots
from trainer import Trainer
from py_utils import to_float, ensure_dirs
def parse_args():
parser... | null |
16,024 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
def init_2d... | null |
16,025 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
def init_3d... | null |
16,026 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
limb_colors ... | null |
16,027 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
joint_sizes ... | null |
16,028 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
parents = np... | null |
16,029 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
joint_foot_i... | null |
16,030 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
The provide... | input: positions - glb [T, J, (3/2)] -- single clip! output: motion with average root (x(, z)) = (0(, 0)) |
16,031 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
def to_nump... | null |
16,032 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
def parse_a... | null |
16,033 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patheffects as pe
from matplotlib import cm
import torch
import argparse
import sys
from os.path import join as pjoin
from py_utils import to_float
def load_ou... | null |
16,034 | import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from matplotlib import cm
from matplotlib.legend_handler import HandlerLine2D, HandlerTuple
import tikzplotlib
from os.path import join as pjoin
from py_utils impo... | null |
16,035 | import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from matplotlib import cm
from matplotlib.legend_handler import HandlerLine2D, HandlerTuple
import tikzplotlib
from os.path import join as pjoin
from py_utils impo... | null |
16,036 | import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from matplotlib import cm
from matplotlib.legend_handler import HandlerLine2D, HandlerTuple
import tikzplotlib
from os.path import join as pjoin
from py_utils impo... | null |
16,037 | import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
from matplotlib import cm
from matplotlib.legend_handler import HandlerLine2D, HandlerTuple
import tikzplotlib
from os.path import join as pjoin
from py_utils impo... | null |
16,038 | import os
import math
import torch
import torch.nn as nn
import torch.nn.init as init
from torch.optim import lr_scheduler
from model import Model
from py_utils import update_dict
def get_model_list(dirname, key):
if os.path.exists(dirname) is False:
return None
gen_models = [os.path.join(dirname, f) f... | null |
16,039 | import os
import math
import torch
import torch.nn as nn
import torch.nn.init as init
from torch.optim import lr_scheduler
from model import Model
from py_utils import update_dict
def get_scheduler(optimizer, config, it=-1):
lr_policy = config.lr_policy
if lr_policy is None or lr_policy == 'constant':
... | null |
16,040 | import os
import math
import torch
import torch.nn as nn
import torch.nn.init as init
from torch.optim import lr_scheduler
from model import Model
from py_utils import update_dict
def weights_init(init_type='gaussian'):
def init_fun(m):
classname = m.__class__.__name__
if (classname.find('Conv') ==... | null |
16,041 | import os
import sys
import random
import torch
import numpy as np
import argparse
BASEPATH = os.path.dirname(__file__)
from os.path import join as pjoin
from torch.utils.data import Dataset, DataLoader
from utils.animation_data import AnimationData
from utils.animation_2d_data import AnimationData2D
from utils.load_sk... | null |
16,042 | import os
import sys
import random
import torch
import numpy as np
import argparse
from os.path import join as pjoin
from torch.utils.data import Dataset, DataLoader
from utils.animation_data import AnimationData
from utils.animation_2d_data import AnimationData2D
from utils.load_skeleton import Skel
from config import... | null |
16,043 | import os
import sys
import random
import torch
import numpy as np
import argparse
from os.path import join as pjoin
from torch.utils.data import Dataset, DataLoader
from utils.animation_data import AnimationData
from utils.animation_2d_data import AnimationData2D
from utils.load_skeleton import Skel
from config import... | train_dataset = MotionNorm(config, "train") print_composite(train_dataset[0]) data_loader = DataLoader(train_dataset, batch_size=2, shuffle=False) for batch in data_loader: print_composite(batch) break |
16,044 | import os
import sys
import numpy as np
import yaml
import argparse
import shutil
from copy import deepcopy
from os.path import join as pjoin
from utils.animation_data import AnimationData
from utils.load_skeleton import Skel
def divide_clip_xia(input, window, window_step, divide):
if not divide: # return the whol... | null |
16,045 | import os
import sys
import numpy as np
import yaml
import argparse
import shutil
from copy import deepcopy
from os.path import join as pjoin
from utils.animation_data import AnimationData
from utils.load_skeleton import Skel
def bvh_to_motion_and_phase(filename, downsample, skel):
def divide_clip_bfa(input, window, wi... | null |
16,046 | import os
import sys
import numpy as np
import yaml
import argparse
import shutil
from copy import deepcopy
from os.path import join as pjoin
from utils.animation_data import AnimationData
from utils.load_skeleton import Skel
def parse_args():
parser = argparse.ArgumentParser("export_train")
parser.add_argumen... | null |
16,047 | import os
import sys
import numpy as np
import torch
import argparse
from tqdm import tqdm
from os.path import join as pjoin
import utils.BVH as BVH
from utils.InverseKinematics import JacobianInverseKinematics
from utils.animation_data import AnimationData
def parse_args():
parser = argparse.ArgumentParser()
... | null |
16,048 | import os
import sys
import numpy as np
import torch
import argparse
from tqdm import tqdm
from os.path import join as pjoin
import utils.BVH as BVH
from utils.InverseKinematics import JacobianInverseKinematics
from utils.animation_data import AnimationData
def save_bvh_from_network_output(nrot, output_path):
anim ... | null |
16,049 | import os
import numpy as np
import torch
def merge_dict(dict_list):
ret = {}
for dict in dict_list:
for key, value in dict.items():
try:
ret[key]
except KeyError:
ret[key] = 0.0
ret[key] += value
return ret | null |
16,050 | import os
import numpy as np
import torch
def update_dict(old_dict, new_dict):
for key, value in new_dict.items():
old_dict[key] = value | null |
16,051 | import os
import numpy as np
import torch
def write_loss(iterations, trainer, train_writer):
for key, value in trainer.loss_dict.items():
train_writer.add_scalar(key, value, iterations + 1) | null |
16,052 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import autograd
import numpy as np
from kinematics import ForwardKinematics
from blocks import ConvBlock, ResBlock, LinearBlock, \
BottleNeckResBlock, Upsample, ConvLayers, ActiFirstResBlock, \
get_conv_pad, get_norm_layer
def assign... | null |
16,053 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import autograd
import numpy as np
from kinematics import ForwardKinematics
from blocks import ConvBlock, ResBlock, LinearBlock, \
BottleNeckResBlock, Upsample, ConvLayers, ActiFirstResBlock, \
get_conv_pad, get_norm_layer
def get_nu... | null |
16,054 | import torch
import torch.nn as nn
import torch.nn.functional as F
def get_conv_pad(kernel_size, stride, padding=nn.ReflectionPad1d):
pad_l = (kernel_size - stride) // 2
pad_r = (kernel_size - stride) - pad_l
return padding((pad_l, pad_r)) | null |
16,055 | import torch
import torch.nn as nn
import torch.nn.functional as F
def ConvLayers(kernel_size, in_channels, out_channels, stride=1, pad_type='reflect', use_bias=True):
"""
returns a list of [pad, conv] => should be += to some list, then apply sequential
"""
if pad_type == 'reflect':
pad = nn.Ref... | returns a list of [pad, conv, norm, acti] or [acti, pad, conv, norm] |
16,056 | import torch
import torch.nn as nn
import torch.nn.functional as F
def get_acti_layer(acti='relu', inplace=True):
if acti == 'relu':
return [nn.ReLU(inplace=inplace)]
elif acti == 'lrelu':
return [nn.LeakyReLU(0.2, inplace=inplace)]
elif acti == 'tanh':
return [nn.Tanh()]
elif ac... | null |
16,057 | import sys
import os
from option_parser import get_std_bvh
import BVH as BVH
import numpy as np
from datasets.bvh_parser import BVH_file
import Animation
def batch(char, suffix, prefix):
input_path = os.path.join(prefix, 'results/bvh')
all_err = []
ref_file = get_std_bvh(dataset=char)
ref_file = BVH_fil... | null |
16,058 | import os
import torch
from models import create_model
from datasets import create_dataset
import option_parser
def eval_prepare(args):
character = []
file_id = []
character_names = []
character_names.append(args.input_bvh.split('/')[-2])
character_names.append(args.target_bvh.split('/')[-2])
i... | null |
16,059 | import os
import torch
from models import create_model
from datasets import create_dataset
import option_parser
def recover_space(file):
l = file.split('/')
l[-1] = l[-1].replace('_', ' ')
return '/'.join(l) | null |
16,060 | import os
from datasets.bvh_parser import BVH_file
from datasets.bvh_writer import BVH_writer
from models.IK import fix_foot_contact
from os.path import join as pjoin
def copy_ref_file(src, dst):
file = BVH_file(src)
writer = BVH_writer(file.edges, file.names)
writer.write_raw(file.to_tensor(quater=True)[..... | null |
16,061 | import os
from models import create_model
from datasets import create_dataset, get_character_names
import option_parser
import torch
from tqdm import tqdm
def create_model(args, character_names, dataset):
if args.model == 'mul_top_mul_ske':
args.skeleton_info = 'concat'
import models.architecture
... | null |
16,062 | import sys
import os
from option_parser import try_mkdir
import numpy as np
from tqdm import tqdm
from datasets.bvh_parser import BVH_file
import BVH_mod as BVH
def split_joint(file_name, save_file=None):
if save_file is None:
save_file = file_name
target_joints = ['Spine1', 'LeftShoulder', 'RightShould... | null |
16,063 | import os
import numpy as np
import copy
from datasets.bvh_parser import BVH_file
from datasets.motion_dataset import MotionData
from option_parser import get_args, try_mkdir
class BVH_file:
def __init__(self, file_path=None, args=None, dataset=None, new_root=None):
if file_path is None:
file_p... | null |
16,064 | import os
import numpy as np
import copy
from datasets.bvh_parser import BVH_file
from datasets.motion_dataset import MotionData
from option_parser import get_args, try_mkdir
class MotionData(Dataset):
"""
Clip long dataset into fixed length window for batched training
each data is a 2d tensor with shape (... | null |
16,065 | import os
import numpy as np
import copy
from datasets.bvh_parser import BVH_file
from datasets.motion_dataset import MotionData
from option_parser import get_args, try_mkdir
The provided code snippet includes necessary dependencies for implementing the `copy_std_bvh` function. Write a Python function `def copy_std_bv... | copy an arbitrary bvh file as a static information (skeleton's offset) reference |
16,066 | import sys
import numpy as np
from Quaternions import Quaternions
from models.skeleton import build_joint_topology
def write_bvh(parent, offset, rotation, position, names, frametime, order, path, endsite=None):
file = open(path, 'w')
frame = rotation.shape[0]
joint_num = rotation.shape[1]
order = order... | null |
16,067 | from torch import optim
from torch import nn
import torch
import random
from torch.optim import lr_scheduler
The provided code snippet includes necessary dependencies for implementing the `get_scheduler` function. Write a Python function `def get_scheduler(optimizer, opt)` to solve the following problem:
Return a lear... | Return a learning rate scheduler Parameters: optimizer -- the optimizer of the network opt (option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions. opt.lr_policy is the name of learning rate policy: linear | step | plateau | cosine For 'linear', we keep the same learning rate for the fi... |
16,068 | from torch import optim
from torch import nn
import torch
import random
from torch.optim import lr_scheduler
def get_ee(pos, pa, ees, velo=False, from_root=False):
pos = pos.clone()
for i, fa in enumerate(pa):
if i == 0: continue
if not from_root and fa == 0: continue
pos[:, :, i, :] +=... | null |
16,069 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
def dfs(x, fa, vis, dist):
vis[x] = 1
for y in range(len(fa)):
if (fa[y] == x or fa[x] == y) and vis[y] == 0:
dist[y] = dist[x] + 1
dfs(y, fa, vis, dist) | null |
16,070 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
def build_edge_topology(topology, offset):
# get all edges (pa, child, offset)
edges = []
joint_num = len(topology)
for i in range(1, joint_num):
edges.append((topology[i], i, offset[i]))
retur... | null |
16,071 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
def build_joint_topology(edges, origin_names):
parent = []
offset = []
names = []
edge2joint = []
joint_from_edge = [] # -1 means virtual joint
joint_cnt = 0
out_degree = [0] * (len(edges) + 1... | null |
16,072 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
def calc_edge_mat(edges):
edge_num = len(edges)
# edge_mat[i][j] = distance between edge(i) and edge(j)
edge_mat = [[100000] * edge_num for _ in range(edge_num)]
for i in range(edge_num):
edge_mat[i... | Line #373 is buggy. Thanks @crissallan!! See issue #30 (https://github.com/DeepMotionEditing/deep-motion-editing/issues/30) However, fixing this bug will make it unable to load the pretrained model and affect the reproducibility of quantitative error reported in the paper. It is not a fatal bug so we didn't touch it an... |
16,073 | import sys
import torch
from models.Kinematics import InverseKinematics
from datasets.bvh_parser import BVH_file
from tqdm import tqdm
import BVH as BVH
import Animation as Animation
from Quaternions_old import Quaternions
class BVH_file:
def __init__(self, file_path=None, args=None, dataset=None, new_root=None):
... | null |
16,074 | import bpy
def add_floor(size):
def add_camera(location, rotation):
def add_light(location):
def make_scene(floor_size=1000, camera_position=(37.54, -28.87, 16.34), camera_rotation=(1.30473, 0.0109881, 0.896417),
light_position=(0, 0, 20)):
floor = add_floor(floor_size)
camera = add_camera(camer... | null |
16,075 | import bpy
def add_rendering_parameters(scene, args, camera):
scene.render.resolution_x = args.resX
scene.render.resolution_y = args.resY
scene.frame_end = args.frame_end
scene.camera = camera
scene.render.filepath = args.save_path
if args.render_engine == 'cycles':
scene.render.engine... | null |
16,076 | import bpy
def add_material_for_character(objs):
char_mat = bpy.data.materials.new(name="characterMaterial")
char_mat.use_nodes = True
bsdf = char_mat.node_tree.nodes["Principled BSDF"]
bsdf.inputs[0].default_value = (0.021219, 0.278894, 1, 1) # character material color
for obj in objs:
o... | null |
16,077 | import bpy
import sys
import numpy as np
import argparse
import os
def clean_scene():
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete() | null |
16,078 | import bpy
import sys
import numpy as np
import argparse
import os
def load_fbx(source):
bpy.ops.import_scene.fbx(filepath=source, use_anim=False) | null |
16,079 | import bpy
import sys
import numpy as np
import argparse
import os
def load_bvh(source):
bpy.ops.import_anim.bvh(filepath=source)
return source.split('/')[-1][:-4] | null |
16,080 | import bpy
import sys
import numpy as np
import argparse
import os
The provided code snippet includes necessary dependencies for implementing the `set_rest_pose_bvh` function. Write a Python function `def set_rest_pose_bvh(filename, source_arm)` to solve the following problem:
This helps recover the rest pose position... | This helps recover the rest pose position from the rest pose of fbx reference file |
16,081 | import bpy
import sys
import numpy as np
import argparse
import os
The provided code snippet includes necessary dependencies for implementing the `extract_weight` function. Write a Python function `def extract_weight(me)` to solve the following problem:
Extract skinning weight from a given mesh
Here is the function:
... | Extract skinning weight from a given mesh |
16,082 | import bpy
import sys
import numpy as np
import argparse
import os
def clean_vgrps(me):
def load_weight(me, label, weight):
clean_vgrps(me)
verts = me.data.vertices
vgrps = me.vertex_groups
for name in label:
vgrps.new(name=name)
for j in range(weight.shape[1]):
idx = vgrps.find(l... | null |
16,083 | import bpy
import sys
import numpy as np
import argparse
import os
def set_modifier(me, arm):
modifiers = me.modifiers
for modifier in modifiers:
if modifier.type == 'ARMATURE':
modifier.object = arm
modifier.use_vertex_groups = True
modifier.use_deform_preserve_volu... | null |
16,084 | import bpy
import sys
import numpy as np
import argparse
import os
The provided code snippet includes necessary dependencies for implementing the `adapt_weight` function. Write a Python function `def adapt_weight(source_weight, source_label, source_arm, dest_arm)` to solve the following problem:
The targeted armature ... | The targeted armature could be a reduced one, e.g. no fingers. So move the skinning weight of each reduced armature to its nearest ancestor. |
16,085 | import sys
import os
import BVH
import numpy as np
import bpy
import mathutils
import pdb
class BVH_file:
def __init__(self, file_path):
self.anim, self.names, self.frametime = BVH.load(file_path)
#permute (x, y, z) to (z, x, y)
tmp = self.anim.offsets.copy()
self.anim.offsets[..., 0... | null |
16,086 | import bpy
import numpy as np
from os import listdir, path
def fbx2bvh(data_path, file):
sourcepath = data_path+"/"+file
bvh_path = data_path+"/"+file.split(".fbx")[0]+".bvh"
bpy.ops.import_scene.fbx(filepath=sourcepath)
frame_start = 9999
frame_end = -9999
action = bpy.data.actions[-1]
i... | null |
16,087 | import re
import numpy as np
import sys
from Animation import Animation
from Quaternions_old import Quaternions
channelmap = {
'Xrotation' : 'x',
'Yrotation' : 'y',
'Zrotation' : 'z'
}
class Animation:
"""
Animation is a numpy-like wrapper for animation data
Animation data consists of s... | Reads a BVH file and constructs an animation !!! Read from bfa, will replace the end sites of arms by two joints (w/ unit rotation) Parameters ---------- filename: str File to be opened start : int Optional Starting Frame end : int Optional Ending Frame order : str Optional Specifier for joint order. Given as string E.... |
16,088 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
The provided code snippet includes necessary dependencies for implementing the `load_from_maya` function. Write a Python function `def load_from_maya(root)` to solve the following problem:
Load joint parents and names from maya Parameters -... | Load joint parents and names from maya Parameters ---------- root : PyNode Root Maya Node Returns ------- (names, parents) : ([str], (J) ndarray) List of joint names and array of indices representing the parent joint for each joint J. Joint index -1 is used to represent that there is no parent joint |
16,089 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def joints(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
joints : (J) ndarray
Array of joint indices
"""
return np.arange(len(parents), dtype=int)
... | Parameters ---------- parents : (J) ndarray parents array Returns ------- joints : [ndarray] List of arrays of joint idices for each joint |
16,090 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def joints_mask(parents): return np.eye(len(parents)).astype(bool) | null |
16,091 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def children_list(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
children : [ndarray]
List of arrays of joint indices for
the children of each joint... | null |
16,092 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def parents_list(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
parents : [ndarray]
List of arrays of joint idices for
the parents of each joint
... | null |
16,093 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def descendants_list(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
descendants : [ndarray]
List of arrays of joint idices for
the descendants of ea... | null |
16,094 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def ancestors_list(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
ancestors : [ndarray]
List of arrays of joint idices for
the ancestors of each joi... | null |
16,095 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def joint_chain_ascend(parents, start, end):
chain = []
while start != end:
chain.append(start)
start = parents[start]
chain.append(end)
return np.array(chain, dtype=int) | null |
16,096 | import numpy as np
import scipy.sparse as sparse
import Animation as Animation
def children_list(parents):
"""
Parameters
----------
parents : (J) ndarray
parents array
Returns
-------
children : [ndarray]
List of arrays of joint indices for
the children of each joint... | Constraint list for Animation This constraint list can be used in the VerletParticle solver to constrain a animation global joint positions. Parameters ---------- anim : Animation Input animation masses : (F, J) ndarray Optional list of masses for joints J across frames F defaults to weighting by vertical height Return... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.