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
Im2Hands
Im2Hands-main/im2mesh/common.py
# import multiprocessing import torch from im2mesh.utils.libkdtree import KDTree import numpy as np def compute_iou(occ1, occ2): ''' Computes the Intersection over Union (IoU) value for two sets of occupancy values. Args: occ1 (tensor): first set of occupancy values occ2 (tensor): second ...
9,273
28.163522
78
py
Im2Hands
Im2Hands-main/im2mesh/preprocess.py
import torch from im2mesh import config from im2mesh.checkpoints import CheckpointIO from im2mesh.utils.io import export_pointcloud class PSGNPreprocessor: ''' Point Set Generation Networks (PSGN) preprocessor class. Args: cfg_path (str): path to config file pointcloud_n (int): number of outp...
1,773
31.254545
74
py
Im2Hands
Im2Hands-main/im2mesh/r2n2/training.py
import os from tqdm import trange import numpy as np import torch import torch.nn.functional as F from im2mesh.training import BaseTrainer from im2mesh.common import compute_iou from im2mesh.utils import visualize as vis from im2mesh.utils.voxels import VoxelGrid class Trainer(BaseTrainer): ''' Trainer class for ...
4,360
31.066176
76
py
Im2Hands
Im2Hands-main/im2mesh/r2n2/config.py
import os from im2mesh.encoder import encoder_dict from im2mesh.r2n2 import models, training, generation from im2mesh import data def get_model(cfg, device=None, **kwargs): ''' Return the model. Args: cfg (dict): loaded yaml config device (device): pytorch device ''' decoder = cfg['mo...
2,505
24.571429
57
py
Im2Hands
Im2Hands-main/im2mesh/r2n2/generation.py
import torch import numpy as np from im2mesh.utils.voxels import VoxelGrid class VoxelGenerator3D(object): ''' Generator class for R2N2 model. The output of the model is transformed to a voxel grid and returned as a mesh. Args: model (nn.Module): (trained) R2N2 model threshold (float...
1,414
24.267857
76
py
Im2Hands
Im2Hands-main/im2mesh/r2n2/models/decoder.py
import torch.nn as nn import torch.nn.functional as F class Decoder(nn.Module): ''' Decoder network class for the R2N2 model. It consists of 4 transposed 3D-convolutional layers. Args: dim (int): input dimension c_dim (int): dimension of latent conditioned code c ''' def __init_...
1,260
31.333333
72
py
Im2Hands
Im2Hands-main/im2mesh/r2n2/models/__init__.py
import torch.nn as nn from im2mesh.r2n2.models.decoder import Decoder # Decoder dictionary decoder_dict = { 'simple': Decoder, } class R2N2(nn.Module): ''' The 3D Recurrent Reconstruction Neural Network (3D-R2N2) model. For details regarding the model, please see https://arxiv.org/abs/1604.00449 ...
757
21.294118
72
py
Im2Hands
Im2Hands-main/im2mesh/dmc/training.py
import os from tqdm import trange import torch from im2mesh.common import chamfer_distance from im2mesh.training import BaseTrainer from im2mesh.utils import visualize as vis import numpy as np import torch.nn.functional as F import scipy.ndimage from im2mesh.dmc.utils.util import gaussian_kernel, offset_to_normal fro...
9,194
35.78
153
py
Im2Hands
Im2Hands-main/im2mesh/dmc/generation.py
import torch import numpy as np import trimesh from im2mesh.dmc.utils.pred2mesh import pred_to_mesh_max from im2mesh.dmc.ops.occupancy_to_topology import OccupancyToTopology from im2mesh.dmc.ops.table import get_accept_topology class Generator3D(object): def __init__(self, model, device=None, num_voxels=32): ...
1,182
29.333333
77
py
Im2Hands
Im2Hands-main/im2mesh/dmc/models/encoder.py
import torch.nn as nn import torch from im2mesh.dmc.ops.grid_pooling import GridPooling class PointNetLocal(nn.Module): ''' Point Net Local Conditional Network from the Deep Marching Cubes paper. It applies two fully connected layers to the input points (dim 3) in a 1D Convolutional Layer fashio...
2,574
35.785714
83
py
Im2Hands
Im2Hands-main/im2mesh/dmc/models/decoder.py
import torch.nn as nn import torch from im2mesh.dmc.ops.occupancy_to_topology import OccupancyToTopology class UNetDecoder(nn.Module): def __init__(self, input_dim=16, T=256, W=32, H=32, D=32, skip_connection=True): super().__init__() self.skip_connection = skip_connection self.decoder = S...
6,730
37.028249
102
py
Im2Hands
Im2Hands-main/im2mesh/dmc/models/__init__.py
import torch.nn as nn from im2mesh.dmc.models import encoder, decoder decoder_dict = { 'unet': decoder.UNetDecoder } encoder_dict = { 'pointnet_local': encoder.PointNetLocal, } class DMC(nn.Module): def __init__(self, decoder, encoder): super().__init__() self.decoder = decoder s...
495
19.666667
53
py
Im2Hands
Im2Hands-main/im2mesh/dmc/utils/pointTriangleDistance.py
#!/usr/bin/env python # # Tests distance between point and triangle in 3D. Aligns and uses 2D technique. # # Was originally some code on mathworks # # Implemented for pytorch Variable # Adapted from https://gist.github.com/joshuashaffer/99d58e4ccbd37ca5d96e import numpy as np import torch from torch.autograd import Va...
11,593
32.031339
112
py
Im2Hands
Im2Hands-main/im2mesh/dmc/utils/util.py
import numpy as np #import os #import json import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location #from mpl_toolkits.mplot3d.art...
8,274
36.274775
115
py
Im2Hands
Im2Hands-main/im2mesh/dmc/utils/pred2mesh.py
import torch import numpy as np from im2mesh.dmc.ops.cpp_modules import pred2mesh def unique_rows(a): """ Return the matrix with unique rows """ rowtype = np.dtype((np.void, a.dtype.itemsize * a.shape[1])) b = np.ascontiguousarray(a).view(rowtype) _, idx, inverse = np.unique(b, return_index=True, retu...
2,159
29.857143
103
py
Im2Hands
Im2Hands-main/im2mesh/dmc/utils/visualize.py
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import torch import os import numpy as np from utils.util import write_to_off, unique_rows from _ext import eval_util def save_mesh_fig(pts_rnd_, offset, topology, x_grids, y_grids, z_grids, ind, args, phase): """ save the estimated mesh with...
4,919
33.893617
101
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/setup.py
from setuptools import setup import torch from torch.utils.cpp_extension import BuildExtension, CUDAExtension setup( name='_cuda_ext', ext_modules=[ CUDAExtension('_cuda_ext', [ 'src/extension.cpp', 'src/curvature_constraint_kernel.cu', 'src/grid_pooling_kernel.cu', ...
553
26.7
67
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/occupancy_connectivity.py
import torch import math from torch import nn from torch.autograd import Function from torch.autograd import Variable from ._cuda_ext import occupancy_connectivity_forward, occupancy_connectivity_backward class OccupancyConnectivityFunction(Function): @staticmethod def forward(ctx, occ): loss = occup...
1,268
23.882353
86
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/occupancy_to_topology.py
import math from torch import nn from torch.autograd import Function import torch from ._cuda_ext import occupancy_to_topology_forward, occupancy_to_topology_backward class OccupancyToTopologyFunction(Function): @staticmethod def forward(ctx, occupancy): W = occupancy.size()[0] - 1 H = occupa...
1,505
26.381818
97
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/grid_pooling.py
import torch import math from torch import nn from torch.autograd import Function from torch.autograd import Variable from ._cuda_ext import grid_pooling_forward, grid_pooling_backward class GridPoolingFunction(Function): """ Perform max-pooling in every cell over the point features see ../src/extension.c...
2,244
27.782051
82
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/point_triangle_distance.py
import torch import math from torch import nn from torch.autograd import Function from torch.autograd import Variable from im2mesh.dmc.ops.table import get_connected_pairs from ._cuda_ext import point_topology_distance_forward, point_topology_distance_backward class PointTriangleDistanceFunction(Function): @stati...
1,940
28.861538
88
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/curvature_constraint.py
import torch import math from torch import nn from torch.autograd import Function from torch.autograd import Variable from im2mesh.dmc.ops.table import get_connected_pairs from ._cuda_ext import curvature_constraint_forward, curvature_constraint_backward ######### TEST FAILS ######### # return connected pairs in x,...
2,271
29.702703
104
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_distance.py
import sys sys.path.append('../../../..') import torch import torch.nn as nn from torch.autograd import Variable import time import numpy as np import resource from im2mesh.dmc.ops.tests.loss_autograd import LossAutoGrad from im2mesh.dmc.ops.point_triangle_distance import PointTriangleDistance print("Testing CUDA ...
2,446
30.371795
119
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/loss_autograd.py
import torch from torch.autograd import Variable import torch.nn.functional as F import numpy as np #import settings from im2mesh.dmc.utils.util import ( offset_to_normal, offset_to_vertices, pts_in_cell, dis_to_meshs) from im2mesh.dmc.ops.table import ( get_connected_pairs, get_accept_topology) import scipy.nd...
11,473
47.210084
155
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_gridpooling.py
import torch import torch.nn as nn from torch.autograd import Variable from torch.autograd import Function import time import numpy as np import sys sys.path.append('../../../..') from im2mesh.dmc.utils.util import pts_in_cell from torch.autograd import gradcheck from im2mesh.dmc.ops.grid_pooling import GridPoolingF...
4,507
32.894737
138
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_curvature.py
import torch import torch.nn as nn from torch.autograd import Variable import sys sys.path.append('../../../..') from im2mesh.dmc.ops.tests.loss_autograd import LossAutoGrad from im2mesh.dmc.ops.curvature_constraint import CurvatureConstraint import torch.nn.functional as F import numpy as np import time # check the...
2,983
30.083333
100
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_occupancy_connectivity_yiyi.py
import torch import torch.nn as nn from torch.autograd import Variable import sys sys.path.append('../../../..') import time import numpy as np from .loss import Loss from .loss_autograd import LossAutoGrad # check the cuda extension or c extension print "Testing CUDA extension..." dtype = torch.cuda.FloatTensor #...
2,586
29.797619
124
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_occupancy_connectivity.py
import sys sys.path.append('../../../..') import torch import torch.nn as nn from torch.autograd import Variable import time import numpy as np from im2mesh.dmc.ops.occupancy_connectivity import OccupancyConnectivity #from loss import Loss #from loss_autograd import LossAutoGrad #from parse_args import parse_args ...
3,106
27.245455
136
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/tests/test_occupancy_to_topology.py
import sys sys.path.append('../../../..') import numpy as np import torch import torch.nn as nn from torch.autograd import Variable import time import torch.nn.functional as F from im2mesh.dmc.ops.occupancy_to_topology import OccupancyToTopology def get_occupancy_table(): """Return binary occupancy status of 8 ve...
4,022
32.247934
127
py
Im2Hands
Im2Hands-main/im2mesh/dmc/ops/cpp_modules/setup.py
from setuptools import setup import torch from torch.utils.cpp_extension import BuildExtension, CppExtension setup( name='pred2mesh', ext_modules=[ CppExtension('pred2mesh', [ 'pred_to_mesh_.cpp', # 'commons.cpp' ]), ], cmdclass={ 'build_ext': BuildExtensi...
329
21
66
py
Im2Hands
Im2Hands-main/im2mesh/encoder/r2n2.py
import torch.nn as nn # import torch.nn.functional as F from im2mesh.common import normalize_imagenet class SimpleConv(nn.Module): ''' 3D Recurrent Reconstruction Neural Network (3D-R2-N2) encoder network. Args: c_dim: output dimension ''' def __init__(self, c_dim=1024): super().__i...
2,857
25.220183
79
py
Im2Hands
Im2Hands-main/im2mesh/encoder/pointnet.py
import torch import torch.nn as nn from im2mesh.layers import ResnetBlockFC def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out class SimplePointnet(nn.Module): ''' PointNet-based encoder network. Args: c_dim (int): dimension of latent code c d...
3,420
29.008772
71
py
Im2Hands
Im2Hands-main/im2mesh/encoder/conv.py
import torch.nn as nn # import torch.nn.functional as F from torchvision import models from im2mesh.common import normalize_imagenet class ConvEncoder(nn.Module): r''' Simple convolutional encoder network. It consists of 5 convolutional layers, each downsampling the input by a factor of 2, and a final fu...
5,021
30.78481
75
py
Im2Hands
Im2Hands-main/im2mesh/encoder/voxels.py
import torch import torch.nn as nn import torch.nn.functional as F class VoxelEncoder(nn.Module): ''' 3D-convolutional encoder network for voxel input. Args: dim (int): input dimension c_dim (int): output dimension ''' def __init__(self, dim=3, c_dim=128): super().__init__() ...
2,726
29.3
65
py
Im2Hands
Im2Hands-main/im2mesh/encoder/psgn_cond.py
import torch.nn as nn class PCGN_Cond(nn.Module): r''' Point Set Generation Network encoding network. The PSGN conditioning network from the original publication consists of several 2D convolution layers. The intermediate outputs from some layers are used as additional input to the encoder network, s...
2,930
36.576923
76
py
Im2Hands
Im2Hands-main/im2mesh/encoder/pix2mesh_cond.py
import torch.nn as nn class Pix2mesh_Cond(nn.Module): r''' Conditioning Network proposed in the authors' Pixel2Mesh implementation. The network consists of several 2D convolution layers, and several of the intermediate feature maps are returned to features for the image projection layer of the encode...
2,701
41.888889
81
py
Im2Hands
Im2Hands-main/im2mesh/onet/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 im2mesh.utils import visualize as vis from im2mesh.training import BaseTrainer class Trainer(BaseTrainer): ''' Trainer objec...
5,479
30.494253
78
py
Im2Hands
Im2Hands-main/im2mesh/onet/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 def get_model(cfg, device=None, dataset=None, **kwargs): ''' Return the Occupancy Networ...
4,466
28.006494
76
py
Im2Hands
Im2Hands-main/im2mesh/onet/generation.py
import torch 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 import time class Generat...
10,942
33.850318
79
py
Im2Hands
Im2Hands-main/im2mesh/onet/models/legacy.py
import torch import torch.nn as nn import torch.nn.functional as F from im2mesh.layers import ResnetBlockFC, AffineLayer class VoxelDecoder(nn.Module): def __init__(self, dim=3, z_dim=128, c_dim=128, hidden_size=128): super().__init__() self.c_dim = c_dim self.z_dim = z_dim # Submo...
4,001
31.016
72
py
Im2Hands
Im2Hands-main/im2mesh/onet/models/encoder_latent.py
import torch import torch.nn as nn import torch.nn.functional as F # Max Pooling operation def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out class Encoder(nn.Module): ''' Latent encoder class. It encodes the input points and returns mean and standard deviati...
2,112
26.802632
79
py
Im2Hands
Im2Hands-main/im2mesh/onet/models/decoder.py
import torch.nn as nn import torch.nn.functional as F from im2mesh.layers import ( ResnetBlockFC, CResnetBlockConv1d, CBatchNorm1d, CBatchNorm1d_legacy, ResnetBlockConv1d ) class Decoder(nn.Module): ''' Decoder class. It does not perform any form of normalization. Args: dim (int): i...
9,357
29.090032
75
py
Im2Hands
Im2Hands-main/im2mesh/onet/models/__init__.py
import torch import torch.nn as nn from torch import distributions as dist from im2mesh.onet.models import encoder_latent, decoder # Encoder latent dictionary encoder_latent_dict = { 'simple': encoder_latent.Encoder, } # Decoder dictionary decoder_dict = { 'simple': decoder.Decoder, 'cbatchnorm': decoder....
4,453
27.551282
77
py
Im2Hands
Im2Hands-main/im2mesh/psgn/training.py
import os from tqdm import trange import torch from im2mesh.common import chamfer_distance from im2mesh.training import BaseTrainer from im2mesh.utils import visualize as vis class Trainer(BaseTrainer): r''' Trainer object for the Point Set Generation Network. The PSGN network is trained on Chamfer distance....
3,775
30.466667
76
py
Im2Hands
Im2Hands-main/im2mesh/psgn/generation.py
import torch from im2mesh.utils.io import export_pointcloud import tempfile import subprocess import os import trimesh class Generator3D(object): r''' Generator Class for Point Set Generation Network. While for point cloud generation the output of the network if used, for mesh generation, we perform surf...
4,097
37.660377
348
py
Im2Hands
Im2Hands-main/im2mesh/psgn/models/psgn_2branch.py
import torch.nn as nn import torch class PCGN_2Branch(nn.Module): r''' The 2-Branch decoder of the Point Set Generation Network. The latent embedding of the image is passed through a fully-connected branch as well as a convolution-based branch which receives additional input from the conditioning net...
2,700
37.042254
79
py
Im2Hands
Im2Hands-main/im2mesh/psgn/models/decoder.py
import torch.nn as nn import torch.nn.functional as F class Decoder(nn.Module): r''' Simple decoder for the Point Set Generation Network. The simple decoder consists of 4 fully-connected layers, resulting in an output of 3D coordinates for a fixed number of points. Args: dim (int): The outpu...
1,176
28.425
76
py
Im2Hands
Im2Hands-main/im2mesh/psgn/models/__init__.py
import torch.nn as nn from im2mesh.psgn.models.decoder import Decoder from im2mesh.psgn.models.psgn_2branch import PCGN_2Branch decoder_dict = { 'simple': Decoder, 'psgn_2branch': PCGN_2Branch } class PCGN(nn.Module): r''' The Point Set Generation Network. For the PSGN, the input image is first pass...
900
26.30303
76
py
Im2Hands
Im2Hands-main/im2mesh/pix2mesh/training.py
import torch.nn.functional as F import torch from im2mesh.common import chamfer_distance import os from torchvision.utils import save_image from im2mesh.training import BaseTrainer from im2mesh.utils import visualize as vis import im2mesh.common as common class Trainer(BaseTrainer): r''' Trainer object for the pi...
14,112
40.026163
85
py
Im2Hands
Im2Hands-main/im2mesh/pix2mesh/layers.py
import torch import torch.nn as nn import torch.nn.functional as F import im2mesh.common as common from matplotlib import pyplot as plt class GraphUnpooling(nn.Module): ''' Graph Unpooling Layer. Unpools additional vertices following the helper file and uses the average feature vector from the tw...
5,588
35.529412
79
py
Im2Hands
Im2Hands-main/im2mesh/pix2mesh/generation.py
import torch import trimesh import im2mesh.common as common class Generator3D(object): ''' Mesh Generator Class for the Pixel2Mesh model. A forward pass is made with the image and camera matrices to obtain the predicted vertex locations for the mesh. Subsequently, the faces of the base mesh of an ell...
2,604
35.180556
78
py
Im2Hands
Im2Hands-main/im2mesh/pix2mesh/models/decoder.py
import torch import torch.nn as nn from im2mesh.pix2mesh.layers import ( GraphConvolution, GraphProjection, GraphUnpooling) class Decoder(nn.Module): r""" Decoder class for Pixel2Mesh Model. Args: ellipsoid (list): list of helper matrices for the graph convolution and pooling laye...
7,640
43.684211
79
py
Im2Hands
Im2Hands-main/im2mesh/pix2mesh/models/__init__.py
import torch.nn as nn from im2mesh.pix2mesh.models.decoder import Decoder decoder_dict = { 'simple': Decoder, } class Pix2Mesh(nn.Module): ''' Pixel2Mesh model. First, the input image is passed through a CNN to extract several feature maps. These feature maps as well as camera matrices are passed t...
904
25.617647
77
py
Im2Hands
Im2Hands-main/im2mesh/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 ...
3,747
30.762712
76
py
Im2Hands
Im2Hands-main/im2mesh/data/core.py
import os import logging from torch.utils import data import numpy as np import yaml logger = logging.getLogger(__name__) # Fields class Field(object): ''' Data fields class. ''' def load(self, data_path, idx, category): ''' Loads a data point. Args: data_path (str): path t...
5,182
28.282486
77
py
Im2Hands
Im2Hands-main/im2mesh/data/real.py
import os from PIL import Image import numpy as np import torch from torch.utils import data from torchvision import transforms class KittiDataset(data.Dataset): r""" Kitti Instance dataset. Args: dataset_folder (str): path to the KITTI dataset img_size (int): size of the cropped images ...
7,357
27.51938
87
py
Im2Hands
Im2Hands-main/manopth/tensutils.py
import torch from manopth import rodrigues_layer def th_posemap_axisang(pose_vectors): rot_nb = int(pose_vectors.shape[1] / 3) pose_vec_reshaped = pose_vectors.contiguous().view(-1, 3) rot_mats = rodrigues_layer.batch_rodrigues(pose_vec_reshaped) rot_mats = rot_mats.view(pose_vectors.shape[0], rot_nb...
1,341
26.958333
75
py
Im2Hands
Im2Hands-main/manopth/manolayer_backup.py
''' This manolayer.py is a modified version of Yana's Hasson pytorch implementation of the MANO model (https://github.com/hassony2/manopth). We made the following changes to the original file to get the transformation matrices necessary for training the HALO model. - No logical change has been made to the way the t...
14,017
44.219355
116
py
Im2Hands
Im2Hands-main/manopth/rot6d.py
import torch def compute_rotation_matrix_from_ortho6d(poses): """ Code from https://github.com/papagina/RotationContinuity On the Continuity of Rotation Representations in Neural Networks Zhou et al. CVPR19 https://zhouyisjtu.github.io/project_rotation/rotation.html """ x_raw = poses[:...
2,212
29.736111
78
py
Im2Hands
Im2Hands-main/manopth/demo.py
from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import numpy as np import torch from manopth.manolayer import ManoLayer def generate_random_hand(batch_size=1, ncomps=6, mano_root='mano/models'): nfull_comps = ncomps + 3 # Add g...
2,832
35.320513
105
py
Im2Hands
Im2Hands-main/manopth/rodrigues_layer.py
""" This part reuses code from https://github.com/MandyMo/pytorch_HMR/blob/master/src/util.py which is part of a PyTorch port of SMPL. Thanks to Zhang Xiong (MandyMo) for making this great code available on github ! """ import argparse from torch.autograd import gradcheck import torch from torch.autograd import Variab...
2,920
31.455556
89
py
Im2Hands
Im2Hands-main/manopth/manolayer.py
''' This manolayer.py is a modified version of Yana's Hasson pytorch implementation of the MANO model (https://github.com/hassony2/manopth). We made the following changes to the original file to get the transformation matrices necessary for training the HALO model. - No logical change has been made to the way the t...
13,870
44.18241
116
py
Im2Hands
Im2Hands-main/manopth/rotproj.py
import torch def batch_rotprojs(batches_rotmats): proj_rotmats = [] for batch_idx, batch_rotmats in enumerate(batches_rotmats): proj_batch_rotmats = [] for rot_idx, rotmat in enumerate(batch_rotmats): # GPU implementation of svd is VERY slow # ~ 2 10^-3 per hit vs 5 10^...
753
33.272727
63
py
GANterfactual
GANterfactual-main/GANterfactual/discriminator.py
from keras.layers import Input from keras.layers.advanced_activations import LeakyReLU from keras.layers.convolutional import Conv2D from keras.models import Model from keras_contrib.layers.normalization.instancenormalization import InstanceNormalization def build_discriminator(img_shape, df): def d_layer(layer_i...
883
33
90
py
GANterfactual
GANterfactual-main/GANterfactual/cyclegan.py
from __future__ import print_function, division import datetime import os import keras import matplotlib.pyplot as plt import numpy as np from skimage.transform import resize from keras.layers import Input, Dropout, Concatenate from keras.models import Model from keras.optimizers import Adam from keras_contrib.laye...
14,019
42.949843
166
py
GANterfactual
GANterfactual-main/GANterfactual/dataloader.py
from __future__ import print_function, division import os import keras import numpy as np class DataLoader(): def __init__(self, dataset_name=None, img_res=(128, 128)): self.dataset_name = dataset_name self.img_res = img_res self.image_gen_config = { "horizontal_flip": False...
1,872
31.859649
104
py
GANterfactual
GANterfactual-main/GANterfactual/classifier.py
from __future__ import print_function, division from keras.layers import Input, Dense, Reshape, Flatten, Dropout, Concatenate from keras.layers import BatchNormalization, Activation, ZeroPadding2D, Lambda from keras.layers import Dense, Activation, Dropout, Flatten, Conv2D, MaxPooling2D from keras.layers.convolutional ...
3,472
30.862385
96
py
GANterfactual
GANterfactual-main/GANterfactual/train_alexNet.py
import keras from keras import Input, Model from keras.layers import Dense, Activation, Dropout, Flatten, Conv2D, MaxPooling2D from keras.preprocessing.image import ImageDataGenerator from keras.layers.normalization import BatchNormalization import numpy as np from keras.regularizers import l2 import os tensorboard_cal...
4,910
30.88961
119
py
GANterfactual
GANterfactual-main/GANterfactual/generator.py
from keras.layers import Dropout from keras.layers import Input, Concatenate from keras.layers.advanced_activations import LeakyReLU from keras.layers.convolutional import UpSampling2D, Conv2D from keras.models import Model from keras_contrib.layers.normalization.instancenormalization import InstanceNormalization def...
1,557
32.869565
98
py
compsensing_dip
compsensing_dip-master/cs_dip.py
import numpy as np import parser import torch from torch.autograd import Variable import baselines import utils import time args = parser.parse_args('configs.json') CUDA = torch.cuda.is_available() dtype = utils.set_dtype(CUDA) se = torch.nn.MSELoss(reduction='none').type(dtype) BATCH_SIZE = 1 EXIT_WINDOW = 51 los...
2,757
33.475
96
py
compsensing_dip
compsensing_dip-master/utils.py
import numpy as np import os import errno import parser import torch import torch.nn as nn import torch.nn.functional as F from torchvision import datasets,transforms BATCH_SIZE = 1 class DCGAN_XRAY(nn.Module): def __init__(self, nz, ngf=64, output_size=256, nc=3, num_measurements=1000): super(DCGAN_XRA...
11,104
36.265101
113
py
compsensing_dip
compsensing_dip-master/comp_sensing.py
import numpy as np import pickle as pkl import os import parser import numpy as np import torch from torchvision import datasets import utils import cs_dip import baselines as baselines import time NEW_RECONS = False args = parser.parse_args('configs.json') print(args) NUM_MEASUREMENTS_LIST, ALG_LIST = utils.conv...
1,944
28.029851
97
py
PrivateCovariance
PrivateCovariance-main/functions.py
import torch import os import gzip import argparse import numpy as np from exponential.algos import EMCov from adaptive.algos import GaussCov, LapCov, SeparateCov, SeparateLapCov, AdaptiveCov, AdaptiveLapCov from coinpress.algos import cov_est from urllib.request import urlretrieve from sklearn.feature_extraction.text ...
39,810
39.873717
163
py
PrivateCovariance
PrivateCovariance-main/coinpress/utils.py
# coding: utf-8 ''' Utilities functions ''' import torch import argparse import os.path as osp import numpy as np import math import pdb def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('--total_budget', default=.5, type=float, help='Total privacy budget') parser.add_argument('--d'...
4,308
29.34507
115
py
PrivateCovariance
PrivateCovariance-main/coinpress/algos.py
''' Privately estimating covariance. ''' import torch import coinpress.utils as utils import numpy as np import math def cov_est_step(X, A, rho, cur_iter, args): """ One step of multivariate covariance estimation, scale cov a. """ W = torch.mm(X, A) n = args.n d = args.d #Hyperparameters...
3,435
28.118644
96
py
PrivateCovariance
PrivateCovariance-main/adaptive/utils.py
import torch import numpy as np from scipy.optimize import root_scalar def SVT(T,eps,D,func,args): T_tilde = T + np.random.laplace(scale=2.0/eps) i = 0 m = len(args) while i < m: Qi = func(D,args[i]) + np.random.laplace(scale=4.0/eps) if Qi >= T_tilde: break i = i +...
3,410
26.288
87
py
PrivateCovariance
PrivateCovariance-main/adaptive/algos.py
import numpy as np import torch from adaptive.utils import get_gauss_wigner_matrix, get_lap_wigner_matrix, get_gauss_noise_vector, get_lap_noise_vector, SVT, get_bincounts, gaussian_tailbound, laplace_tailbound, wigner_gauss_fnormbound, wigner_lap_fnormbound, wigner_gauss_tailbound, wigner_lap_tailbound, clip def Gau...
8,261
34.612069
278
py
PrivateCovariance
PrivateCovariance-main/exponential/utils.py
import torch import numpy as np from scipy.optimize import root_scalar import time def root_bisect_dec(x0,x1,func,args,T=10,thres=1e-8): left = x0 right = x1 mid = 0.5*(left+right) mid_val = func(mid, args) t = 0 err = abs(mid_val) while t<T and err > thres: if mid_val > 0: ...
1,821
26.19403
86
py
PrivateCovariance
PrivateCovariance-main/exponential/algos.py
import torch import numpy as np from exponential.utils import find_bingham, convert_eps from scipy.linalg import null_space def EMCov(X, args, b_budget=False, b_fleig=True): rho = args.total_budget delta = args.delta n = args.n d = args.d cov = torch.mm(X.t(),X) if not(delta > 0.0): eps...
1,802
27.619048
69
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/experiment_run.py
"""This library contains all utility functions to help you run your experiments. Methods ------- run_experiment: Run a single experiment with a specific solver and ExperimentParameters run_experiment_agenda: Run a number of experiments defined in the ExperimentAgenda run_specific_experiments_from_research_agend...
58,195
54.372027
160
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_online_random.py
import pprint from typing import Dict import numpy as np from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.scheduling.propagate import verify_consistency_of_route_dag_constraints_for_agent from rsp.scheduling.scheduling_problem import RouteDAGConstraints from rsp.scheduling.scheduling_prob...
4,898
42.353982
145
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_offline_fully_restricted.py
import pprint from typing import Dict import numpy as np from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.scheduling.propagate import verify_consistency_of_route_dag_constraints_for_agent from rsp.scheduling.scheduling_problem import RouteDAGConstraints from rsp.scheduling.scheduling_prob...
4,060
44.122222
141
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_offline_delta_weak.py
import pprint from typing import Dict import numpy as np from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.scheduling.propagate import verify_consistency_of_route_dag_constraints_for_agent from rsp.scheduling.propagate import verify_trainrun_satisfies_route_dag_constraints from rsp.schedul...
4,868
43.263636
149
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_agent_wise.py
from enum import Enum import networkx as nx from flatland.envs.rail_trainrun_data_structures import Trainrun from rsp.scheduling.scheduling_problem import ScheduleProblemDescription from rsp.step_05_experiment_run.experiment_malfunction import ExperimentMalfunction from rsp.step_05_experiment_run.scopers.scoper_onlin...
2,810
43.619048
145
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_offline_delta.py
import logging import pprint from typing import Dict import networkx as nx import numpy as np from flatland.envs.rail_trainrun_data_structures import Trainrun from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.scheduling.propagate import _get_delayed_trainrun_waypoint_after_malfunction from...
8,348
42.036082
141
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_online_transmission_chains.py
import pprint from typing import Dict from typing import Set from typing import Tuple import numpy as np from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.resource_occupation.resource_occupation import extract_resource_occupations from rsp.scheduling.propagate import verify_consistency_of_...
5,579
45.115702
132
py
rsp
rsp-master/src/python/rsp/step_05_experiment_run/scopers/scoper_online_route_restricted.py
import pprint from typing import Dict import numpy as np from flatland.envs.rail_trainrun_data_structures import TrainrunDict from rsp.scheduling.propagate import verify_consistency_of_route_dag_constraints_for_agent from rsp.scheduling.scheduling_problem import RouteDAGConstraintsDict from rsp.scheduling.scheduling_...
4,118
41.463918
119
py
Alpha-IoU
Alpha-IoU-main/test.py
import argparse, csv import json import os from pathlib import Path from threading import Thread import numpy as np import torch import yaml from tqdm import tqdm from models.experimental import attempt_load from utils.datasets import create_dataloader from utils.general import coco80_to_coco91_class, check_dataset, ...
17,952
47.131367
122
py
Alpha-IoU
Alpha-IoU-main/detect.py
import argparse import time from pathlib import Path import cv2 import torch import torch.backends.cudnn as cudnn from numpy import random from models.experimental import attempt_load from utils.datasets import LoadStreams, LoadImages from utils.general import check_img_size, check_requirements, check_imshow, non_max...
8,218
45.698864
119
py
Alpha-IoU
Alpha-IoU-main/hubconf.py
"""File for accessing YOLOv5 via PyTorch Hub https://pytorch.org/hub/ Usage: import torch model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True, channels=3, classes=80) """ from pathlib import Path import torch from models.yolo import Model from utils.general import set_logging from utils....
5,274
34.884354
114
py
Alpha-IoU
Alpha-IoU-main/train.py
import argparse import logging import math import os import random import time from copy import deepcopy from pathlib import Path from threading import Thread import numpy as np import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.optim.lr_sche...
32,757
51.4128
151
py
Alpha-IoU
Alpha-IoU-main/models/yolo.py
import argparse import logging import sys from copy import deepcopy sys.path.append('./') # to run '$ python *.py' files in subdirectories logger = logging.getLogger(__name__) from models.common import * from models.experimental import * from utils.autoanchor import check_anchor_order from utils.general import make_...
12,060
42.699275
119
py
Alpha-IoU
Alpha-IoU-main/models/export.py
"""Exports a YOLOv5 *.pt model to ONNX and TorchScript formats Usage: $ export PYTHONPATH="$PWD" && python models/export.py --weights ./weights/yolov5s.pt --img 640 --batch 1 """ import argparse import sys import time sys.path.append('./') # to run '$ python *.py' files in subdirectories import torch import to...
4,422
41.12381
117
py
Alpha-IoU
Alpha-IoU-main/models/common.py
# This file contains modules common to various models import math from pathlib import Path import numpy as np import requests import torch import torch.nn as nn from PIL import Image from utils.datasets import letterbox from utils.general import non_max_suppression, make_divisible, scale_coords, xyxy2xywh from utils...
12,997
41.064725
120
py
Alpha-IoU
Alpha-IoU-main/models/experimental.py
# This file contains experimental modules import numpy as np import torch import torch.nn as nn from models.common import Conv, DWConv from utils.google_utils import attempt_download class CrossConv(nn.Module): # Cross Convolution Downsample def __init__(self, c1, c2, k=3, s=1, g=1, e=1.0, shortcut=False): ...
5,146
37.125926
114
py
Alpha-IoU
Alpha-IoU-main/utils/loss.py
# Loss functions import torch import torch.nn as nn from utils.general import bbox_iou, bbox_alpha_iou from utils.torch_utils import is_parallel def smooth_BCE(eps=0.1): # https://github.com/ultralytics/yolov3/issues/238#issuecomment-598028441 # return positive, negative label smoothing BCE targets return ...
15,771
44.191977
120
py
Alpha-IoU
Alpha-IoU-main/utils/autoanchor.py
# Auto-anchor utils import numpy as np import torch import yaml from scipy.cluster.vq import kmeans from tqdm import tqdm from utils.general import colorstr def check_anchor_order(m): # Check anchor order against stride order for YOLOv5 Detect() module m, and correct if necessary a = m.anchor_grid.prod(-1)....
13,869
45.233333
120
py
Alpha-IoU
Alpha-IoU-main/utils/plots.py
# Plotting utils import glob import math import os import random from copy import copy from pathlib import Path import cv2 import matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import torch import yaml from PIL import Image, ImageDraw, ImageFont from scipy.sign...
18,126
41.254079
120
py
Alpha-IoU
Alpha-IoU-main/utils/datasets.py
# Dataset utils and dataloaders import glob import logging import math import os import random import shutil import time from itertools import repeat from multiprocessing.pool import ThreadPool from pathlib import Path from threading import Thread import cv2 import numpy as np import torch import torch.nn.functional ...
45,239
41.201493
120
py
Alpha-IoU
Alpha-IoU-main/utils/torch_utils.py
# PyTorch utils import logging import math import os import subprocess import time from contextlib import contextmanager from copy import deepcopy from pathlib import Path import torch import torch.backends.cudnn as cudnn import torch.nn as nn import torch.nn.functional as F import torchvision try: import thop ...
11,956
39.532203
120
py