repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
filter-pruning-geometric-median
filter-pruning-geometric-median-master/original_train.py
# https://github.com/pytorch/vision/blob/master/torchvision/models/__init__.py import argparse import os, sys import shutil import time import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data import torchvision.transforms as transforms...
11,668
36.641935
139
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/functions/infer_pruned.py
# https://github.com/pytorch/vision/blob/master/torchvision/models/__init__.py import argparse import os import shutil import pdb, time from collections import OrderedDict import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.o...
8,795
38.981818
124
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnet_small.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init #from .res_utils import DownsampleA, DownsampleC, DownsampleD import math,time class DownsampleA(nn.Module): def __init__(self, nIn, nOut, stride): super(DownsampleA, self).__init__() self.avg = nn.AvgPool2d(kern...
7,399
34.238095
132
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/preresnet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from .res_utils import DownsampleA, DownsampleC import math class ResNetBasicblock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride, downsample, Type): super(ResNetBasicblock, self).__init__() ...
4,698
29.914474
98
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/imagenet_resnet.py
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytorch.org/models/res...
6,941
31.591549
78
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/imagenet_resnet_small.py
import torch.nn as nn import math import torch.utils.model_zoo as model_zoo from torch.autograd import Variable import torch import time __all__ = ['ResNet_small', 'resnet18_small', 'resnet34_small', 'resnet50_small', 'resnet101_small', 'resnet152_small'] model_urls = { 'resnet18': 'https://download.pytorch.org/m...
12,267
37.578616
129
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnet.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from .res_utils import DownsampleA, DownsampleC, DownsampleD import math class ResNetBasicblock(nn.Module): expansion = 1 """ RexNet basicblock (https://github.com/facebook/fb.resnet.torch/blob/master/models/resnet.lua)...
4,484
29.931034
98
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/vgg.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo import math __all__ = [ 'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn', 'vgg19_bn', 'vgg19', ] model_urls = { 'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30ac9.pth', 'vgg13': 'https://download.pytorch.or...
5,756
31.162011
113
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/densenet.py
import math, torch import torch.nn as nn import torch.nn.functional as F class Bottleneck(nn.Module): def __init__(self, nChannels, growthRate): super(Bottleneck, self).__init__() interChannels = 4*growthRate self.bn1 = nn.BatchNorm2d(nChannels) self.conv1 = nn.Conv2d(nChannels, interChannels, kernel...
3,518
33.5
91
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/vgg_cifar.py
import math import torch import torch.nn as nn from torch.autograd import Variable __all__ = ['vgg'] defaultcfg = { 11 : [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 13 : [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 16 : [64, 64, 'M', 128, 128, 'M', 256, 256, 256...
2,607
31.6
108
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnext.py
import torch.nn as nn import torch.nn.functional as F from torch.nn import init import math class ResNeXtBottleneck(nn.Module): expansion = 4 """ RexNeXt bottleneck type C (https://github.com/facebookresearch/ResNeXt/blob/master/models/resnext.lua) """ def __init__(self, inplanes, planes, cardinality, base_w...
4,180
31.92126
113
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnet_feature.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from .res_utils import DownsampleA, DownsampleC, DownsampleD import math class ResNetBasicblock(nn.Module): expansion = 1 """ RexNet basicblock (https://github.com/facebook/fb.resnet.torch/blob/master/models/resnet.lua)...
4,484
29.931034
98
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/caffe_cifar.py
from __future__ import division import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init import math ## http://torch.ch/blog/2015/07/30/cifar.html class CifarCaffeNet(nn.Module): def __init__(self, num_classes): super(CifarCaffeNet, self).__init__() self.num_classes = nu...
1,750
28.183333
64
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnet_small_V3.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init #from .res_utils import DownsampleA, DownsampleC, DownsampleD import math class DownsampleA(nn.Module): def __init__(self, nIn, nOut, stride): super(DownsampleA, self).__init__() self.avg = nn.AvgPool2d(kernel_si...
5,825
31.915254
133
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/resnet_mod.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import init from .res_utils import DownsampleA, DownsampleC, DownsampleD import math class ResNetBasicblock(nn.Module): expansion = 1 """ RexNet basicblock (https://github.com/facebook/fb.resnet.torch/blob/master/models/resnet.lua)...
5,027
28.928571
98
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/__init__.py
"""The models subpackage contains definitions for the following model architectures: - `ResNeXt` for CIFAR10 CIFAR100 You can construct a model with random weights by calling its constructor: .. code:: python import models resnext29_16_64 = models.ResNeXt29_16_64(num_classes) resnext29_8_64 = models.ResNeX...
1,486
38.131579
117
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/res_utils.py
import torch import torch.nn as nn class DownsampleA(nn.Module): def __init__(self, nIn, nOut, stride): super(DownsampleA, self).__init__() self.avg = nn.AvgPool2d(kernel_size=1, stride=stride) def forward(self, x): x = self.avg(x) return torch.cat((x, x.mul(0)), 1) class Downsample...
3,941
28.41791
89
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/models/vgg_cifar10.py
import math import torch import torch.nn as nn from torch.autograd import Variable __all__ = ['vgg'] defaultcfg = { 11: [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 13: [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 16: [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M...
6,395
37.53012
107
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/VGG_cifar/main_cifar_vgg.py
from __future__ import print_function import argparse import numpy as np import os import shutil import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.autograd import Variable sys.path.append(os.path.dirname(os.path.dirnam...
8,019
43.804469
115
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/VGG_cifar/pruning_cifar_vgg.py
from __future__ import print_function import argparse import numpy as np import os import shutil import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.autograd import Variable import os, sys, shutil, time, random from scip...
29,830
48.470978
120
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/VGG_cifar/main_cifar_vgg_log.py
from __future__ import print_function import argparse import numpy as np import os import shutil import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.autograd import Variable import os, sys, shutil, time, random sys.path....
10,842
44.179167
121
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/VGG_cifar/PFEC_vggprune.py
import argparse import numpy as np import os import torch import torch.nn as nn from torch.autograd import Variable from torchvision import datasets, transforms sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from models import * # Prune settings parser = argparse.ArgumentParser(descrip...
6,938
40.550898
104
py
filter-pruning-geometric-median
filter-pruning-geometric-median-master/VGG_cifar/PFEC_finetune.py
from __future__ import print_function import argparse import numpy as np import os import shutil import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torchvision import datasets, transforms from torch.autograd import Variable sys.path.append(os.path.dirname(os.path.dirnam...
8,193
44.021978
115
py
Im2Hands
Im2Hands-main/init_occ_train.py
import warnings warnings.filterwarnings('ignore',category=FutureWarning) import os import sys import time import argparse import torch import torch.nn as nn import torch.optim as optim import numpy as np import matplotlib; matplotlib.use('Agg') from torch.utils.tensorboard import SummaryWriter from artihand import co...
6,151
32.98895
112
py
Im2Hands
Im2Hands-main/ref_occ_train.py
import warnings warnings.filterwarnings('ignore',category=FutureWarning) import os import sys import time import argparse import torch import torch.optim as optim import numpy as np import matplotlib; matplotlib.use('Agg') from torch.utils.tensorboard import SummaryWriter from artihand import config, data from artiha...
5,904
33.735294
117
py
Im2Hands
Im2Hands-main/kpts_ref_generate.py
import os import sys import time import torch import shutil import trimesh import argparse import pandas as pd import numpy as np import open3d as o3d from tqdm import tqdm from collections import defaultdict from artihand import config, data from artihand.checkpoints import CheckpointIO from artihand.nasa.kpts_ref_t...
4,947
37.96063
143
py
Im2Hands
Im2Hands-main/kpts_ref_train.py
import warnings warnings.filterwarnings('ignore',category=FutureWarning) import os import sys import time import argparse import torch import torch.nn as nn import torch.optim as optim import numpy as np import matplotlib; matplotlib.use('Agg') from torch.utils.tensorboard import SummaryWriter from artihand import co...
6,214
33.148352
112
py
Im2Hands
Im2Hands-main/init_occ_generate.py
import os import sys import time import torch import shutil import trimesh import argparse import pandas as pd import numpy as np import open3d as o3d from tqdm import tqdm from collections import defaultdict from artihand import config, data from artihand.checkpoints import CheckpointIO from dependencies.halo.halo_...
4,640
35.543307
174
py
Im2Hands
Im2Hands-main/ref_occ_generate.py
import os import sys import time import torch import shutil import trimesh import argparse import pandas as pd import numpy as np from tqdm import tqdm from collections import defaultdict from artihand import config, data from artihand.checkpoints import CheckpointIO from dependencies.halo.halo_adapter.transform_uti...
5,374
39.11194
199
py
Im2Hands
Im2Hands-main/dependencies/intaghand/dataset/interhand.py
import json import os.path as osp from tqdm import tqdm import cv2 as cv import numpy as np import torch import pickle from glob import glob import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from models.manolayer import ManoLayer, rodrigues_batch from dataset.dat...
13,958
43.597444
138
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model.py
import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import torch import torch.nn as nn import torch.nn.functional as F import pickle import numpy as np from dataset.dataset_utils import IMG_SIZE from models.encoder import load_encoder from models.decoder import load...
1,863
29.557377
89
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/encoder.py
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import torch import torch.nn as nn import torch.nn.functional as F import pickle import numpy as np from dataset.dataset_utils import IMG_SIZE from utils.utils import projection_batch from models.manolayer import M...
14,103
36.610667
127
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/decoder.py
import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) import torch import torch.nn as nn import torch.nn.functional as F import pickle import numpy as np from dataset.dataset_utils import IMG_SIZE, BONE_LENGTH from utils.utils import projection_batch, get_dense_color_...
8,780
40.814286
146
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/manolayer.py
import pickle import numpy as np import torch from torch.nn import Module def convert_mano_pkl(loadPath, savePath): # in original MANO pkl file, 'shapedirs' component is a chumpy object, convert it to a numpy array manoData = pickle.load(open(loadPath, 'rb'), encoding='latin1') output = {} manoData['s...
13,352
38.158358
122
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_zoo/fc.py
import torch.nn as nn class noop(nn.Module): def forward(self, x): return x def build_activate_layer(actType): if actType == 'relu': return nn.ReLU(inplace=True) elif actType == 'lrelu': return nn.LeakyReLU(0.1, inplace=True) elif actType == 'elu': return nn.ELU(inpla...
946
25.305556
85
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_zoo/hrnet.py
# ------------------------------------------------------------------------------ # Copyright (c) Microsoft # Licensed under the MIT License. # Written by Bin Xiao (Bin.Xiao@microsoft.com) # Modified by Ke Sun (sunk@mail.ustc.edu.cn) # ------------------------------------------------------------------------------ from ...
30,039
39.430686
121
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_zoo/graph_utils.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F # forked from https://github.com/3d-hand-shape/hand-graph-cnn def sparse_python_to_torch(sp_python): L = sp_python.tocoo() indices = np.column_stack((L.row, L.col)).T indices = indices.astype(np.int64) indices = tor...
7,647
31.824034
108
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_zoo/__init__.py
import torch.nn as nn from .fc import build_fc_layer from .hrnet import get_hrnet, Bottleneck from .coarsening import build_graph from .graph_utils import graph_upsample, graph_avg_pool __all__ = ['build_fc_layer', 'get_hrnet', 'Bottleneck', 'build_graph', 'GCN_vert_convert', 'graph_upsample', 'graph_avg_p...
3,086
30.824742
104
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_zoo/coarsening.py
import numpy as np import scipy.sparse from scipy.sparse.linalg import eigsh import torch # forked from https://github.com/3d-hand-shape/hand-graph-cnn def laplacian(W, normalized=True): """Return graph Laplacian""" # Degree matrix. d = W.sum(axis=0) # Laplacian matrix. if not normalized: ...
12,729
28.67366
120
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_attn/DualGraph.py
import torch import torch.nn as nn import torch.nn.functional as F from .gcn import GraphLayer from .img_attn import img_ex from .inter_attn import inter_attn def graph_upsample(x, p): if p > 1: x = x.permute(0, 2, 1).contiguous() # x = B x F x V x = nn.Upsample(scale_factor=p)(x) # B x F x (V...
5,266
36.621429
87
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_attn/inter_attn.py
import torch import torch.nn as nn import torch.nn.functional as F from .self_attn import SelfAttn def weights_init(layer): classname = layer.__class__.__name__ # print(classname) if classname.find('Conv2d') != -1: nn.init.xavier_uniform_(layer.weight.data) elif classname.find('Linear') != -1...
4,522
34.896825
97
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_attn/gcn.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np def weights_init(layer): classname = layer.__class__.__name__ # print(classname) if classname.find('Conv2d') != -1: nn.init.xavier_uniform_(layer.weight.data) elif classname.find('Linear') != -1: nn.i...
4,537
31.647482
103
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_attn/img_attn.py
import torch import torch.nn as nn import torch.nn.functional as F from .self_attn import SelfAttn def weights_init(layer): classname = layer.__class__.__name__ # print(classname) if classname.find('Conv2d') != -1: nn.init.xavier_uniform_(layer.weight.data) elif classname.find('Linear') != -1...
4,292
33.071429
105
py
Im2Hands
Im2Hands-main/dependencies/intaghand/models/model_attn/self_attn.py
import torch import torch.nn as nn import torch.nn.functional as F def weights_init(layer): classname = layer.__class__.__name__ # print(classname) if classname.find('Conv2d') != -1: nn.init.xavier_uniform_(layer.weight.data) elif classname.find('Linear') != -1: nn.init.xavier_uniform_...
3,346
31.813725
95
py
Im2Hands
Im2Hands-main/dependencies/intaghand/utils/utils.py
import numpy as np import random import math import cv2 as cv import pickle import torch import os import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from utils.config import get_cfg_defaults from models.model_zoo import build_graph def projection(scale, trans2d, label3d,...
8,999
33.090909
106
py
Im2Hands
Im2Hands-main/dependencies/intaghand/utils/vis_utils.py
import pickle import numpy as np import torch import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from models.manolayer import ManoLayer from utils.config import get_cfg_defaults from utils.utils import projection_batch, get_mano_path, get_dense_color_path # Data ...
10,221
39.563492
116
py
Im2Hands
Im2Hands-main/dependencies/halo/checkpoints.py
import os import urllib import torch from torch.utils import model_zoo class CheckpointIO(object): ''' CheckpointIO class. It handles saving and loading checkpoints. Args: checkpoint_dir (str): path where checkpoints are saved ''' def __init__(self, checkpoint_dir='./chkpts', initialize_fr...
4,467
33.90625
93
py
Im2Hands
Im2Hands-main/dependencies/halo/training.py
# from im2mesh import icp import numpy as np from collections import defaultdict from tqdm import tqdm class BaseTrainer(object): ''' Base trainer class. ''' def evaluate(self, val_loader): ''' Performs an evaluation. Args: val_loader (dataloader): pytorch dataloader '...
1,014
23.756098
65
py
Im2Hands
Im2Hands-main/dependencies/halo/config.py
from models.data.input_helpers import random_rotate import yaml from torchvision import transforms from models import naive from models import data method_dict = { 'naive': naive } # General config def load_config(path, default_path=None): ''' Loads config file. Args: path (str): path to confi...
5,471
25.955665
76
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/training.py
import os from tqdm import trange import torch from torch.nn import functional as F from torch import distributions as dist # from im2mesh.common import ( # compute_iou, make_3d_grid # ) from models.utils import visualize as vis from models.training import BaseTrainer from models.naive.loss.loss import (BoneLength...
20,600
41.476289
143
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/config.py
import torch import torch.distributions as dist from torch import nn import os # from im2mesh.encoder import encoder_dict # from im2mesh.onet import models, training, generation # from im2mesh import data # from im2mesh import config from models import data from models import config from models.naive import models, tr...
8,530
29.90942
100
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/generation.py
import torch import torch.optim as optim from torch import autograd import numpy as np import os from tqdm import trange import trimesh from trimesh.base import Trimesh from im2mesh.utils import libmcubes from im2mesh.common import make_3d_grid from im2mesh.utils.libsimplify import simplify_mesh from im2mesh.utils.libm...
26,592
42.24065
148
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/models/refine.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class RefineNet(nn.Module): ''' RefineNet class. Takes noisy joints and object latent vector as input and output the refined joints Args: out_dim (int): dimension of output code z c_dim (int): dimension o...
1,660
31.568627
86
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/models/core.py
import torch import torch.nn as nn from torch import distributions as dist from models.halo_adapter.adapter import HaloAdapter class HaloVAE(nn.Module): ''' HALO VAE Network class. Args: decoder (nn.Module): decoder network encoder (nn.Module): encoder network encoder_latent (nn.Modul...
16,286
36.876744
118
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/models/encoder.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out class SimpleEncoder(torch.nn.Module): def __init__(self, D_in, H, D_out): """ Crate a two-layers networks with ...
5,962
29.269036
90
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/models/decoder.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class SimpleDecoder(torch.nn.Module): def __init__(self, D_in, H, D_out, mano_params_out=False): """ Crate a simple feed-forward networks with relu activation. """ super(SimpleDecoder, self).__ini...
4,897
31.437086
82
py
Im2Hands
Im2Hands-main/dependencies/halo/naive/loss/loss.py
import numpy as np import torch import torch.nn as nn from models.halo_adapter.converter import PoseConverter, transform_to_canonical, angle2, signed_angle from models.halo_adapter.interface import convert_joints def kp3D_to_bones(kp_3D, joint_parent, normalize_length=False): """ Converts from joints to bone...
9,610
37.138889
128
py
Im2Hands
Im2Hands-main/dependencies/halo/mano_converter/mano_converter.py
import torch import torch.nn as nn import numpy as np import sys sys.path.insert(0, "/home/korrawe/halo_vae") from models.halo_adapter.converter import transform_to_canonical from models.halo_adapter.interface import convert_joints, change_axes def rot_mat_to_axis_angle(R): """ Taken from http://www.eucl...
10,931
33.269592
111
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/adapter.py
import sys import torch import torch.nn as nn import numpy as np from torch.nn.modules import loss from models.halo_adapter.converter import PoseConverter, transform_to_canonical from models.halo_adapter.interface import (get_halo_model, convert_joints, change_axes, get_bone_...
13,414
44.941781
148
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/trans_mat_model.py
import torch from torch._C import device import torch.nn as nn import numpy as np class TransformationModel(nn.Module): def __init__(self, D_in=21 * 3, H=256, D_out=15 * 3, device="cpu"): """ Crate a two-layers networks with relu activation. """ super(TransformationModel, self).__i...
1,438
29.617021
71
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/transform_utils.py
import torch def xyz_to_xyz1(xyz): """ Convert xyz vectors from [BS, ..., 3] to [BS, ..., 4] for matrix multiplication """ ones = torch.ones([*xyz.shape[:-1], 1], device=xyz.device) # print("xyz shape", xyz.shape) # print("one", ones.shape) return torch.cat([xyz, ones], dim=-1) def pad34_to_...
483
31.266667
108
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/projection.py
import torch import torch.nn as nn import numpy as np class JointProjectionLayer(nn.Module): def __init__(self, D_in=21 * 3, H=256, D_out=21 * 3, device="cpu", fix_root=True): """ Crate a two-layers networks with relu activation. """ super(JointProjectionLayer, self).__init__() ...
1,415
30.466667
86
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/converter_ref.py
# ------------------------------------------------------------------------------ # Copyright (c) 2019 Adrian Spurr # Licensed under the GPL License. # Written by Adrian Spurr # ------------------------------------------------------------------------------ import numpy as np import torch import torch.nn as nn import ma...
54,446
40.753834
130
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/converter.py
# ------------------------------------------------------------------------------ # Copyright (c) 2019 Adrian Spurr # Licensed under the GPL License. # Written by Adrian Spurr # ------------------------------------------------------------------------------ import numpy as np import torch import torch.nn as nn import mat...
56,863
40.9042
130
py
Im2Hands
Im2Hands-main/dependencies/halo/halo_adapter/interface.py
# For interfacing with the HALO mesh model code import argparse import trimesh import numpy as np import os import torch import sys sys.path.insert(0, "../../halo_base") #from artihand import config #, data from artihand.checkpoints import CheckpointIO def get_halo_model(config_file): ''' Args: confi...
4,857
35.253731
127
py
Im2Hands
Im2Hands-main/dependencies/halo/utils/visualize.py
import numpy as np from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection # from torchvision.utils import save_image # import im2mesh.common as common # def visualize_data(data, data_type, out_file): # r''' Visualizes the data with rega...
11,311
34.684543
106
py
Im2Hands
Im2Hands-main/dependencies/halo/data/inference.py
import os import logging from torch.utils import data import numpy as np import yaml import pickle import torch import trimesh from models.data.input_helpers import random_rotate, rot_mat_by_angle logger = logging.getLogger(__name__) class InferenceDataset(data.Dataset): ''' Dataset class for inference. Only ob...
7,009
38.382022
133
py
Im2Hands
Im2Hands-main/dependencies/halo/data/utils.py
import os import numpy as np from torch.utils import data def collate_remove_none(batch): ''' Collater that puts each data field into a tensor with outer dimension batch size. Args: batch: batch ''' batch = list(filter(lambda x: x is not None, batch)) return data.dataloader.defaul...
568
24.863636
77
py
Im2Hands
Im2Hands-main/dependencies/halo/data/obman.py
import os import logging from matplotlib.pyplot import axis from torch.utils import data import numpy as np import yaml import pickle import torch from scipy.spatial import distance from models.data.input_helpers import random_rotate from models.utils import visualize as vis from matplotlib import pyplot as plt from m...
7,466
38.094241
135
py
Im2Hands
Im2Hands-main/dependencies/airnets/AIRnet.py
''' AIR-Nets Author: Simon Giebenhain Code: https://github.com/SimonGiebenhain/AIR-Nets ''' import torch import torch.nn as nn import torch.nn.functional as functional import numpy as np from time import time import torch.nn.functional as F import os import math import dependencies.airnets.pointnet2_ops_lib.pointnet2_...
38,269
35.692234
143
py
Im2Hands
Im2Hands-main/dependencies/airnets/pointnet2_ops_lib/setup.py
import glob import os import os.path as osp from setuptools import find_packages, setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension this_dir = osp.dirname(osp.abspath(__file__)) _ext_src_root = osp.join("pointnet2_ops", "_ext-src") _ext_sources = glob.glob(osp.join(_ext_src_root, "src", "*.cpp...
1,185
28.65
78
py
Im2Hands
Im2Hands-main/dependencies/airnets/pointnet2_ops_lib/pointnet2_ops/pointnet2_utils.py
import torch import torch.nn as nn import warnings from torch.autograd import Function from typing import * try: import pointnet2_ops._ext as _ext except ImportError: from torch.utils.cpp_extension import load import glob import os.path as osp import os warnings.warn("Unable to load pointnet2_...
10,396
26.360526
103
py
Im2Hands
Im2Hands-main/dependencies/airnets/pointnet2_ops_lib/pointnet2_ops/pointnet2_modules.py
from typing import List, Optional, Tuple import torch import torch.nn as nn import torch.nn.functional as F from pointnet2_ops import pointnet2_utils def build_shared_mlp(mlp_spec: List[int], bn: bool = True): layers = [] for i in range(1, len(mlp_spec)): layers.append( nn.Conv2d(mlp_spec...
6,530
30.1
106
py
Im2Hands
Im2Hands-main/dependencies/airnets/pointnet2_ops_lib/build/lib.linux-x86_64-3.8/pointnet2_ops/pointnet2_utils.py
import torch import torch.nn as nn import warnings from torch.autograd import Function from typing import * try: import pointnet2_ops._ext as _ext except ImportError: from torch.utils.cpp_extension import load import glob import os.path as osp import os warnings.warn("Unable to load pointnet2_...
10,396
26.360526
103
py
Im2Hands
Im2Hands-main/dependencies/airnets/pointnet2_ops_lib/build/lib.linux-x86_64-3.8/pointnet2_ops/pointnet2_modules.py
from typing import List, Optional, Tuple import torch import torch.nn as nn import torch.nn.functional as F from pointnet2_ops import pointnet2_utils def build_shared_mlp(mlp_spec: List[int], bn: bool = True): layers = [] for i in range(1, len(mlp_spec)): layers.append( nn.Conv2d(mlp_spec...
6,530
30.1
106
py
Im2Hands
Im2Hands-main/artihand/checkpoints.py
import os import urllib import torch from torch.utils import model_zoo class CheckpointIO(object): ''' CheckpointIO class. It handles saving and loading checkpoints. Args: checkpoint_dir (str): path where checkpoints are saved ''' def __init__(self, checkpoint_dir='./chkpts', initialize_fr...
6,735
37.056497
140
py
Im2Hands
Im2Hands-main/artihand/training.py
# from im2mesh import icp import numpy as np from collections import defaultdict from tqdm import tqdm class BaseTrainer(object): ''' Base trainer class. ''' def evaluate(self, val_loader, subset=1): ''' Performs an evaluation. Args: val_loader (dataloader): pytorch dataloader...
1,025
23.428571
65
py
Im2Hands
Im2Hands-main/artihand/config.py
import yaml from torchvision import transforms from artihand import data from artihand import nasa method_dict = { 'nasa': nasa } # General config def load_config(path, default_path=None): ''' Loads config file. Args: path (str): path to config file default_path (bool): whether to use ...
7,339
27.449612
84
py
Im2Hands
Im2Hands-main/artihand/checkpoints_legacy.py
import os import urllib import torch from torch.utils import model_zoo class CheckpointIO(object): ''' CheckpointIO class. It handles saving and loading checkpoints. Args: checkpoint_dir (str): path where checkpoints are saved ''' def __init__(self, checkpoint_dir='./chkpts', **kwargs): ...
2,962
28.63
70
py
Im2Hands
Im2Hands-main/artihand/diff_operators.py
import torch from torch.autograd import grad def hessian(y, x): ''' hessian of y wrt x y: shape (meta_batch_size, num_observations, channels) x: shape (meta_batch_size, num_observations, 2) ''' meta_batch_size, num_observations = y.shape[:2] grad_y = torch.ones_like(y[..., 0]).to(y.device) ...
1,892
30.55
132
py
Im2Hands
Im2Hands-main/artihand/nasa/training.py
import os from tqdm import trange import torch from torch.nn import functional as F from torch import distributions as dist from im2mesh.common import ( compute_iou, make_3d_grid ) from artihand.utils import visualize as vis from artihand.training import BaseTrainer from artihand import diff_operators # For dubugg...
14,705
37.904762
121
py
Im2Hands
Im2Hands-main/artihand/nasa/config.py
import os import torch import torch.distributions as dist from torch import nn from artihand import data from artihand import config from artihand.nasa import models, training, generation from artihand.nasa import init_occ_training, ref_occ_training, kpts_ref_training def get_model(cfg, device=None, dataset=None, **...
8,082
32.127049
115
py
Im2Hands
Im2Hands-main/artihand/nasa/ref_occ_training.py
import os import sys import torch import torch.nn as nn import numpy as np from torch.nn import functional as F from torch import distributions as dist from tqdm import trange from im2mesh.common import ( compute_iou, make_3d_grid ) from artihand.utils import visualize as vis from artihand.training import BaseTr...
5,242
32.825806
193
py
Im2Hands
Im2Hands-main/artihand/nasa/generation.py
import torch import torch.nn as nn import torch.optim as optim from torch import autograd import numpy as np from tqdm import trange import trimesh from im2mesh.utils import libmcubes from im2mesh.common import make_3d_grid from im2mesh.utils.libsimplify import simplify_mesh from im2mesh.utils.libmise import MISE impor...
25,868
38.494656
203
py
Im2Hands
Im2Hands-main/artihand/nasa/kpts_ref_training.py
import os import sys import torch import torch.nn as nn import numpy as np from torch.nn import functional as F from torch import distributions as dist from tqdm import trange from im2mesh.common import ( compute_iou, make_3d_grid ) from artihand.utils import visualize as vis from artihand.training import BaseTr...
8,788
38.236607
143
py
Im2Hands
Im2Hands-main/artihand/nasa/init_occ_training.py
import os import sys import torch import torch.nn as nn import numpy as np from torch.nn import functional as F from torch import distributions as dist from tqdm import trange from im2mesh.common import ( compute_iou, make_3d_grid ) from artihand.utils import visualize as vis from artihand.training import BaseTr...
5,651
31.113636
143
py
Im2Hands
Im2Hands-main/artihand/nasa/models/core_init_occ.py
import sys import torch import torch.nn as nn from torch import distributions as dist from dependencies.halo.halo_adapter.converter import PoseConverter, transform_to_canonical from dependencies.halo.halo_adapter.interface import (get_halo_model, convert_joints, change_axes, scale_halo_trans_mat) from dependencies.hal...
7,445
41.067797
159
py
Im2Hands
Im2Hands-main/artihand/nasa/models/core_ref_occ.py
import sys import torch import torch.nn as nn from torch import distributions as dist from torch.nn.functional import grid_sample from im2mesh.common import make_3d_grid from dependencies.halo.halo_adapter.transform_utils import xyz_to_xyz1 from dependencies.intaghand.models.encoder import ResNetSimple from depende...
9,465
42.824074
211
py
Im2Hands
Im2Hands-main/artihand/nasa/models/decoder.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class SimpleDecoder(nn.Module): def __init__( self, latent_size, dims, dropout=None, dropout_prob=0.0, norm_layers=(), latent_in=(), weight_norm=False, # xy...
44,495
37.259673
128
py
Im2Hands
Im2Hands-main/artihand/nasa/models/core_kpts_ref.py
import sys import torch import torch.nn as nn from torch import distributions as dist from dependencies.intaghand.models.encoder import ResNetSimple from dependencies.intaghand.models.model_attn.img_attn import * from dependencies.intaghand.models.model_attn.self_attn import * from dependencies.intaghand.models.m...
9,607
37.432
104
py
Im2Hands
Im2Hands-main/artihand/utils/visualize.py
import numpy as np from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from torchvision.utils import save_image import im2mesh.common as common def visualize_data(data, data_type, out_file): r''' Visualizes the data with regard to its type. Args: data (tensor): batch of data ...
4,668
30.33557
98
py
Im2Hands
Im2Hands-main/artihand/data/ref_occ_sample_hands.py
import os import sys import json import pickle import logging import trimesh import torch import torchvision.transforms import numpy as np import cv2 as cv import open3d as o3d from glob import glob from torch.utils import data from manopth.manolayer import ManoLayer from dependencies.halo.halo_adapter.converter impo...
8,986
38.244541
151
py
Im2Hands
Im2Hands-main/artihand/data/init_occ_sample_hands.py
import os import sys import json import pickle import logging import torch import torchvision.transforms import numpy as np import cv2 as cv import open3d as o3d from glob import glob from torch.utils import data from manopth.manolayer import ManoLayer from dependencies.halo.halo_adapter.converter import PoseConverte...
7,874
35.971831
151
py
Im2Hands
Im2Hands-main/artihand/data/utils.py
import os import numpy as np from torch.utils import data def collate_remove_none(batch): ''' Collater that puts each data field into a tensor with outer dimension batch size. Args: batch: batch ''' batch = list(filter(lambda x: x is not None, batch)) return data.dataloader.defaul...
568
24.863636
77
py
Im2Hands
Im2Hands-main/artihand/data/kpts_ref_sample_hands.py
import os import sys import json import pickle import logging import torch import torchvision.transforms import numpy as np import cv2 as cv import open3d as o3d from glob import glob from torch.utils import data from manopth.manolayer import ManoLayer from dependencies.halo.halo_adapter.converter import PoseConvert...
8,990
37.75431
162
py
Im2Hands
Im2Hands-main/artihand/data/transforms.py
import numpy as np import torch # Transforms class PointcloudNoise(object): ''' Point cloud noise transformation class. It adds noise to point cloud data. Args: stddev (int): standard deviation ''' def __init__(self, stddev): self.stddev = stddev def __call__(self, data): ...
5,631
24.6
84
py
Im2Hands
Im2Hands-main/im2mesh/checkpoints.py
import os import urllib import torch from torch.utils import model_zoo class CheckpointIO(object): ''' CheckpointIO class. It handles saving and loading checkpoints. Args: checkpoint_dir (str): path where checkpoints are saved ''' def __init__(self, checkpoint_dir='./chkpts', **kwargs): ...
2,963
28.346535
70
py
Im2Hands
Im2Hands-main/im2mesh/training.py
# from im2mesh import icp import numpy as np from collections import defaultdict from tqdm import tqdm class BaseTrainer(object): ''' Base trainer class. ''' def evaluate(self, val_loader): ''' Performs an evaluation. Args: val_loader (dataloader): pytorch dataloader '...
1,014
23.756098
65
py
Im2Hands
Im2Hands-main/im2mesh/layers.py
import torch import torch.nn as nn # Resnet Blocks class ResnetBlockFC(nn.Module): ''' Fully connected ResNet Block class. Args: size_in (int): input dimension size_out (int): output dimension size_h (int): hidden dimension ''' def __init__(self, size_in, size_out=None, size_...
8,471
28.213793
71
py
Im2Hands
Im2Hands-main/im2mesh/config.py
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess method_dict = { 'onet': onet, 'r2n2': r2n2, 'psgn': psgn, 'pix2mesh': pix2mesh, 'dmc': dmc, } # General config def load_config(path, default_...
7,343
27.355212
76
py