repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
GaitForeMer | GaitForeMer-main/training/transformer_model_fn.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 11,607 | 37.059016 | 119 | py |
GaitForeMer | GaitForeMer-main/training/seq2seq_model_fn.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 24,065 | 36.024615 | 179 | py |
GaitForeMer | GaitForeMer-main/training/pose_classifier_fn.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 7,534 | 34.21028 | 139 | py |
GaitForeMer | GaitForeMer-main/models/Conv1DEncoder.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 5,262 | 32.954839 | 114 | py |
GaitForeMer | GaitForeMer-main/models/Transformer.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 6,581 | 33.103627 | 85 | py |
GaitForeMer | GaitForeMer-main/models/PoseTransformer.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 19,154 | 38.658385 | 120 | py |
GaitForeMer | GaitForeMer-main/models/seq2seq_model.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 5,425 | 34.697368 | 89 | py |
GaitForeMer | GaitForeMer-main/models/PoseEncoderDecoder.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 4,120 | 32.504065 | 87 | py |
GaitForeMer | GaitForeMer-main/models/TransformerEncoder.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 7,169 | 28.628099 | 79 | py |
GaitForeMer | GaitForeMer-main/models/TransformerDecoder.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 11,059 | 31.818991 | 87 | py |
GaitForeMer | GaitForeMer-main/models/__init__.py | 0 | 0 | 0 | py | |
GaitForeMer | GaitForeMer-main/models/PoseGCN.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 11,945 | 26.976581 | 97 | py |
GaitForeMer | GaitForeMer-main/models/potr_fn.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 14,622 | 30.245726 | 110 | py |
GaitForeMer | GaitForeMer-main/visualize/forward_kinematics.py | """Visualize predictions as a sequence of skeletons."""
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as anumation
import numpy as np
import json
import argparse
import viz
import os
import sys
import h5py
sys.path.append('../')
import utils.utils as utils
if __name__ == '__main__... | 1,867 | 23.578947 | 80 | py |
GaitForeMer | GaitForeMer-main/visualize/viz.py | """Functions to visualize human poses"""
import matplotlib.pyplot as plt
import numpy as np
import h5py
import os
from mpl_toolkits.mplot3d import Axes3D
# red color "#e74c3c"
# blue color "#3498db"
class Ax3DPose(object):
def __init__(self, ax, lcolor="#3498db", rcolor="#e74c3c"):
"""
Create a 3d pose vi... | 2,647 | 30.903614 | 79 | py |
GaitForeMer | GaitForeMer-main/utils/WarmUpScheduler.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 4,280 | 39.771429 | 108 | py |
GaitForeMer | GaitForeMer-main/utils/utils.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 19,278 | 30.708882 | 161 | py |
GaitForeMer | GaitForeMer-main/utils/visualize_attention_weights.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 6,648 | 33.630208 | 632 | py |
GaitForeMer | GaitForeMer-main/utils/PositionEncodings.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 6,337 | 32.712766 | 81 | py |
GaitForeMer | GaitForeMer-main/utils/__init__.py | 0 | 0 | 0 | py | |
GaitForeMer | GaitForeMer-main/data/GaitJointsDataset.py | import os
import sys
import numpy as np
import torch
import argparse
import tqdm
import pickle
import random
_TOTAL_ACTIONS = 4
# Mapping from 1-base of NTU to vibe 49 joints
# hip, thorax,
_MAJOR_JOINTS = [39, 41, 37, 43, 34, 35, 36, 33, 32, 31, 28, 29, 30, 27, 26, 25, 40]
# 1, 2, 3, 4, 5, 6, ... | 6,232 | 31.128866 | 137 | py |
GaitForeMer | GaitForeMer-main/data/NTURGDDataset.py | ###############################################################################
# Pose Transformers (POTR): Human Motion Prediction with Non-Autoregressive
# Transformers
#
# Copyright (c) 2021 Idiap Research Institute, http://www.idiap.ch/
# Written by
# Angel Martinez <angel.martinez@idiap.ch>,
#
# This file is p... | 15,284 | 32.084416 | 110 | py |
CPFN | CPFN-master/training_PatchSelection.py | # Importation of packages
import os
import sys
import torch
import argparse
import numpy as np
# Importing the Dataset file
from Dataset import dataloaders
# Importing the Network file
from PointNet2 import pn2_network
# Importing the Utils files
from Utils import config_loader, training_utils, training_visualisation
... | 4,812 | 54.321839 | 193 | py |
CPFN | CPFN-master/evaluation_globalSPFN.py | # Importation of packages
import os
import sys
import torch
import argparse
import numpy as np
import pandas as pd
# Importing the Dataset files
from Dataset import dataloaders
# Importing the Network files
from SPFN import fitter_factory, metric_implementation, losses_implementation
from PointNet2 import pn2_network
... | 7,235 | 63.607143 | 321 | py |
CPFN | CPFN-master/evaluation_baselineSPFN.py | # Importation of packages
import os
import sys
import torch
import argparse
import numpy as np
import pandas as pd
# Importing the Dataset files
from Dataset import dataloaders
# Importing the Network files
from SPFN import fitter_factory, metric_implementation, losses_implementation
from PointNet2 import pn2_network
... | 7,131 | 60.482759 | 197 | py |
CPFN | CPFN-master/evaluation_PatchSelection.py | # Importation of packages
import os
import sys
import h5py
import torch
import argparse
import numpy as np
# Importing the Dataset file
from Dataset import dataloaders
# Importing the Network file
from PointNet2 import pn2_network
# Importing the Utils files
from Utils import config_loader, sampling_utils
if __name__... | 5,095 | 54.391304 | 158 | py |
CPFN | CPFN-master/evaluation_localSPFN.py | # Importation of packages
import os
import sys
import torch
import argparse
import numpy as np
import pandas as pd
# Importing the Dataset files
from Dataset import dataloaders
# Importing the Network files
from SPFN import fitter_factory, metric_implementation, losses_implementation
from PointNet2 import pn2_network
... | 10,606 | 63.284848 | 197 | py |
CPFN | CPFN-master/training_SPFN.py | # Importation of packages
import os
import sys
import torch
import argparse
import numpy as np
# Importing the Dataset files
from Dataset import dataloaders
# Importing the Network files
from SPFN import fitter_factory, losses_implementation
from PointNet2 import pn2_network
# Importing Utils files
from Utils import c... | 6,960 | 59.530435 | 198 | py |
CPFN | CPFN-master/Preprocessing/preprocessing_sampling_patch.py | # Importation of packages
import os
import h5py
import numba
import argparse
import numpy as np
import pandas as pd
import multiprocessing as mp
from joblib import Parallel, delayed
def get_small_primitives(gt_labels_hr, max_nb_points):
unique_labels, unique_counts = np.unique(gt_labels_hr, return_counts=True)
... | 5,085 | 58.139535 | 235 | py |
CPFN | CPFN-master/Preprocessing/preprocessing_creation_patch.py | # Importatiom of packages
import os
import re
import sys
import h5py
import pickle
import argparse
import numpy as np
import pandas as pd
import multiprocessing as mp
from joblib import Parallel, delayed
def multiprocessing(tuple):
ind_file, n_file, file_, path_lowres, path_highres, path_features, path_patches, nu... | 7,998 | 59.598485 | 212 | py |
CPFN | CPFN-master/Preprocessing/preprocessing_sampling_lowres.py | # Importation of packages
import os
import h5py
import time
import numba
import shutil
import argparse
import numpy as np
import pandas as pd
import multiprocessing as mp
from joblib import Parallel, delayed
# Furthest point sampling code
@numba.jit(numba.int32[:](numba.float32[:, :], numba.int32[:], numba.int32), nop... | 5,072 | 50.765306 | 179 | py |
CPFN | CPFN-master/SPFN/sphere_fitter.py | # Importatiomn of packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from SPFN.primitives import Sphere
from SPFN.geometry_utils import weighted_sphere_fitting, weighted_sphere_fitting_tensorflow
def compute_parameters(P, W):
batch_size, n_points, _ = P.size()
_, _,... | 5,084 | 44.810811 | 129 | py |
CPFN | CPFN-master/SPFN/fitter_factory.py | import numpy as np
from SPFN import plane_fitter, sphere_fitter, cylinder_fitter, cone_fitter
primitive_name_to_id_dict = {}
def primitive_name_to_id(name):
return primitive_name_to_id_dict[name]
def get_n_registered_primitives():
return len(primitive_name_to_id_dict)
def register_primitives(primitive_name... | 1,039 | 32.548387 | 74 | py |
CPFN | CPFN-master/SPFN/plane_fitter.py | # Importatiomn of packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from SPFN.primitives import Plane
from SPFN.geometry_utils import weighted_plane_fitting, weighted_plane_fitting_tensorflow
def compute_parameters(P, W):
batch_size, n_points, _ = P.size()
_, _, n_... | 8,518 | 43.369792 | 194 | py |
CPFN | CPFN-master/SPFN/metric_implementation.py | # Importation of packages
import torch
import numpy as np
from scipy.optimize import linear_sum_assignment
from SPFN import plane_fitter, sphere_fitter, cylinder_fitter, cone_fitter
from SPFN import losses_implementation
def hungarian_matching(W_pred, I_gt):
# This non-tf function does not backprob gradient, only... | 36,132 | 59.121464 | 304 | py |
CPFN | CPFN-master/SPFN/geometry_utils.py | # Importing packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from SPFN.differentiable_tls import solve_weighted_tls, solve_weighted_tls_tensorflow
def compute_consistent_plane_frame(normal):
# Input: normal is Bx3
# Returns: x_axis, y_axis, both of dimension Bx3
... | 12,490 | 46.494297 | 148 | py |
CPFN | CPFN-master/SPFN/differentiable_tls.py | # Importation of packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from torch.autograd import gradcheck
def guard_one_over_matrix(M, min_abs_value=1e-10):
_, row, _ = M.size()
device = M.get_device()
up = torch.triu(torch.clamp(M, min=min_abs_value, max=None), ... | 8,960 | 36.493724 | 113 | py |
CPFN | CPFN-master/SPFN/primitives.py | import math
import random
import numpy as np
def normalized(v, epsilon=1e-12):
return v / (np.linalg.norm(v) + epsilon)
def make_rand_unit_vector(dims=3):
vec = np.array([random.gauss(0, 1) for i in range(dims)])
return normalized(vec)
class Plane: # A finite plane patch spanned by x_axis and y_axis
... | 4,985 | 33.625 | 133 | py |
CPFN | CPFN-master/SPFN/cylinder_fitter.py | # Importation of pqckqges
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from SPFN.primitives import Cylinder
from SPFN.differentiable_tls import solve_weighted_tls, solve_weighted_tls_tensorflow
from SPFN.geometry_utils import compute_consistent_plane_frame, compute_consistent_p... | 11,804 | 51.234513 | 166 | py |
CPFN | CPFN-master/SPFN/losses_implementation.py | # Importation of packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from scipy.optimize import linear_sum_assignment
from SPFN import plane_fitter, sphere_fitter, cylinder_fitter, cone_fitter
# Segmentation Loss
def hungarian_matching(W_pred, I_gt):
# This non-tf funct... | 55,650 | 62.819954 | 319 | py |
CPFN | CPFN-master/SPFN/cone_fitter.py | # Importation of packages
import torch
import numpy as np
if __name__ == '__main__':
import tensorflow as tf
from SPFN.primitives import Cone
from SPFN.geometry_utils import guarded_matrix_solve_ls, guarded_matrix_solve_ls_tensorflow, weighted_plane_fitting, weighted_plane_fitting_tensorflow
def acos_safe(x):
... | 12,047 | 49.835443 | 172 | py |
CPFN | CPFN-master/Utils/dataset_utils.py | # Importation of packages
import os
import re
import h5py
import pickle
import numpy as np
from SPFN import cone_fitter, cylinder_fitter, fitter_factory, plane_fitter, sphere_fitter
def create_unit_data_from_hdf5_patch_selection(h5file_lowres, h5file_highres, normalisation, scale, n_points=None):
with h5py.File(h... | 5,228 | 41.512195 | 160 | py |
CPFN | CPFN-master/Utils/training_utils.py | # Importation of packages
import sys
import torch
import numpy as np
from SPFN import losses_implementation
# BN Decay
def get_batch_norm_decay(global_step, batch_size, bn_decay_step, staircase=True):
BN_INIT_DECAY = 0.5
BN_DECAY_RATE = 0.5
BN_DECAY_CLIP = 0.99
p = global_step * batch_size / bn_decay_... | 8,974 | 49.994318 | 166 | py |
CPFN | CPFN-master/Utils/training_visualisation.py | import torch
import numpy as np
from torch import nn
from visdom import Visdom
ORANGE = np.array([[255, 105, 0]])
BLUE = np.array([[40, 40, 255]])
RED = np.array([[255, 40, 40]])
class Visualiser(object):
def __init__(self, plotting_interval, port=8097):
self.vis = Visdom(port=port)
self.line_plot... | 2,658 | 38.102941 | 118 | py |
CPFN | CPFN-master/Utils/config_loader.py | # Importation of packages
import yaml
class Config(object):
def __init__(self, filename):
self.conf = yaml.safe_load(open(filename, 'r'))
def fetch(self, name, default_value=None):
result = self.conf.get(name, default_value)
assert result is not None
return result
def get_... | 3,341 | 26.85 | 55 | py |
CPFN | CPFN-master/Utils/merging_utils.py | # Importation of packages
import torch
import numba
import numpy as np
def similarity_soft(spfn_labels, predicted_labels, point_indices):
num_points_per_object, max_label_per_object = spfn_labels.size()
nb_patches, num_points_per_patch, max_label_per_patch = predicted_labels.size()
point2primitive_predicti... | 3,371 | 62.622642 | 165 | py |
CPFN | CPFN-master/Utils/sampling_utils.py | # Importation of packages
import numpy as np
def sample(gt_points_lr, gt_points_hr, pool_indices, num_points_patch=8192, max_number_patches=32):
list_patch_indices = []
while (len(list_patch_indices) < max_number_patches) and (len(pool_indices) != 0):
# Selecting a random pool index for label l
... | 1,113 | 57.631579 | 112 | py |
CPFN | CPFN-master/Dataset/dataloaders.py | # Importation of packages
import os
import re
import h5py
import torch
import pickle
import random
import numpy as np
import pandas as pd
from tqdm import tqdm
import torch.utils.data as data
# Importing Utils files
from Utils import dataset_utils
class Dataset_PatchSelection(data.Dataset):
def __init__(self, csv... | 19,560 | 54.729345 | 318 | py |
CPFN | CPFN-master/PointNet2/pn2_network.py | # Importation of packages
import os
import sys
import torch
import numpy as np
from SPFN.losses_implementation import compute_all_losses
from PointNet2.pointnet2_ops.modules.pointset_abstraction import PointsetAbstraction
from PointNet2.pointnet2_ops.modules.pointset_feature_propagation import PointsetFeaturePropagatio... | 3,692 | 49.589041 | 183 | py |
CPFN | CPFN-master/PointNet2/pointnet2_ops/setup.py | import os
import glob
import setuptools
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
sources = glob.glob("cuda_ops/src/*.cpp") + glob.glob("cuda_ops/src/*.cu")
headers = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'cuda_ops/include')
setuptools.setup(
name="pointnet2_ops",
... | 915 | 28.548387 | 86 | py |
CPFN | CPFN-master/PointNet2/pointnet2_ops/modules/pointset_feature_propagation.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .geometry_utils import three_nn, three_weighted_sum
class PointsetFeaturePropagation(nn.Module):
"""
Propagate features from an abstracted point set back to the original point set,
analogous to upsampling followed by 1x1 convolutions o... | 2,234 | 41.980769 | 122 | py |
CPFN | CPFN-master/PointNet2/pointnet2_ops/modules/pointset_abstraction.py | from collections.abc import Sequence
import torch
import torch.nn as nn
import torch.nn.functional as F
from .geometry_utils import farthest_point_sample, select_point_subset, ball_query
class PointsetAbstraction(nn.Module):
"""
Abstract a point set (possibly with features) into a smaller point set,
analog... | 3,755 | 47.779221 | 114 | py |
CPFN | CPFN-master/PointNet2/pointnet2_ops/modules/geometry_utils.py | import torch
from .. import cuda_ops
def pairwise_squared_distance(src, dst):
"""
Calculate squared euclidean distance between each pair of points from src to dst.
src^T * dst = xn * xm + yn * ym + zn * zm;
sum(src^2, dim=-1) = xn*xn + yn*yn + zn*zn;
sum(dst^2, dim=-1) = xm*xm + ym*ym + zm*zm;
... | 10,626 | 36.419014 | 135 | py |
pdf2image | pdf2image-master/tests.py | import os
import sys
import errno
import pathlib
import tempfile
import unittest
import time
import shutil
import subprocess
from inspect import signature
from subprocess import Popen, PIPE
from tempfile import TemporaryDirectory
from multiprocessing.dummy import Pool
from memory_profiler import profile as profile_memo... | 67,434 | 37.446408 | 106 | py |
pdf2image | pdf2image-master/setup.py | # Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()
setup(
name... | 1,479 | 33.418605 | 118 | py |
pdf2image | pdf2image-master/docs/conf.py | #
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or ... | 5,595 | 27.697436 | 79 | py |
pdf2image | pdf2image-master/pdf2image/generators.py | """
pdf2image filename generators
"""
import uuid
import threading
class ThreadSafeGenerator(object):
"""Wrapper around generator that protects concurrent access"""
def __init__(self, gen):
self.gen = gen
self.lock = threading.Lock()
def __iter__(self):
return self
def ... | 917 | 18.531915 | 68 | py |
pdf2image | pdf2image-master/pdf2image/exceptions.py | """
Define exceptions specific to pdf2image
"""
class PopplerNotInstalledError(Exception):
"""Raised when poppler is not installed"""
pass
class PDFInfoNotInstalledError(PopplerNotInstalledError):
"""Raised when pdfinfo is not installed"""
pass
class PDFPageCountError(Exception):
"""Rais... | 623 | 17.352941 | 71 | py |
pdf2image | pdf2image-master/pdf2image/pdf2image.py | """
pdf2image is a light wrapper for the poppler-utils tools that can convert your
PDFs into Pillow images.
"""
import os
import platform
import tempfile
import types
import shutil
import subprocess
from subprocess import Popen, PIPE, TimeoutExpired
from typing import Any, Union, Tuple, List, Dict, Callable
fr... | 23,863 | 34.993967 | 114 | py |
pdf2image | pdf2image-master/pdf2image/parsers.py | """
pdf2image custom buffer parsers
"""
from io import BytesIO
from typing import List
from PIL import Image
def parse_buffer_to_ppm(data: bytes) -> List[Image.Image]:
"""Parse PPM file bytes to Pillow Image
:param data: pdftoppm/pdftocairo output bytes
:type data: bytes
:return: List of PPM im... | 2,609 | 25.363636 | 88 | py |
pdf2image | pdf2image-master/pdf2image/__init__.py | """
__init__ of the pdf2image module
"""
from .pdf2image import (
convert_from_bytes,
convert_from_path,
pdfinfo_from_bytes,
pdfinfo_from_path,
)
| 167 | 14.272727 | 36 | py |
learning-to-quantize | learning-to-quantize-master/args.py | import argparse
import yaml
import os
import torch
import utils
def add_args():
# Training settings
parser = argparse.ArgumentParser(description='PyTorch NUQSGD')
# options overwritting yaml options
parser.add_argument('--path_opt', default='default.yaml',
type=str, help='pat... | 8,495 | 47 | 81 | py |
learning-to-quantize | learning-to-quantize-master/grid_run.py | from __future__ import print_function
import argparse
import grid
import grid.cluster
import grid.nuq
class RunSingle(object):
def __init__(self, log_dir, module_name, exclude, prefix, parallel=False):
self.log_dir = log_dir
self.num = 0
self.module_name = module_name
self.exclude ... | 3,583 | 34.137255 | 91 | py |
learning-to-quantize | learning-to-quantize-master/utils.py | import shutil
import torch
import numpy as np
class DictWrapper(object):
def __init__(self, d):
self.d = d
def __getattr__(self, key):
if key in self.d:
return self.d[key]
else:
return None
class SaveCheckpoint(object):
def __init__(self):
# remem... | 3,161 | 28.551402 | 76 | py |
learning-to-quantize | learning-to-quantize-master/data.py | import torch
from torchvision import datasets, transforms
import torch.utils.data as data
import numpy as np
import os
def get_loaders(opt):
if opt.dataset == 'mnist':
return get_mnist_loaders(opt)
elif opt.dataset == 'cifar10':
return get_cifar10_loaders(opt)
elif opt.dataset == 'cifar100... | 9,431 | 31.979021 | 78 | py |
learning-to-quantize | learning-to-quantize-master/log_utils.py | from collections import OrderedDict, defaultdict
import numpy as np
from tensorboardX import SummaryWriter
import time
import torch
import os
class TBXWrapper(object):
def configure(self, logger_name, flush_secs=5, opt=None):
self.writer = SummaryWriter(logger_name, flush_secs=flush_secs)
self.log... | 5,411 | 27.041451 | 75 | py |
learning-to-quantize | learning-to-quantize-master/log_plotter.py | from scipy import interpolate
import numpy as np
import os
import re
import torch
import pylab as plt
import matplotlib.ticker as mtick
from tensorboard.backend.event_processing import event_accumulator
def get_run_names(logdir, patterns):
run_names = []
for pattern in patterns:
for root, subdirs, fil... | 8,772 | 36.016878 | 104 | py |
learning-to-quantize | learning-to-quantize-master/__init__.py | 0 | 0 | 0 | py | |
learning-to-quantize | learning-to-quantize-master/models/cifar10_wresnet2.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)
self.relu1 = nn.ReLU(inplace=True)
se... | 3,794 | 42.62069 | 116 | py |
learning-to-quantize | learning-to-quantize-master/models/logreg.py | import torch.nn as nn
import torch.nn.functional as F
class Linear(nn.Module):
def __init__(self, dim, num_class):
super(Linear, self).__init__()
self.linear = nn.Linear(dim, num_class)
def forward(self, x):
x = self.linear(x)
return F.log_softmax(x, dim=-1)
class TwoLinear(... | 637 | 24.52 | 48 | py |
learning-to-quantize | learning-to-quantize-master/models/linreg.py | import torch.nn as nn
# import torch.nn.functional as F
class Linear(nn.Module):
def __init__(self, dim, num_class):
super(Linear, self).__init__()
self.linear = nn.Linear(dim, num_class)
def forward(self, x):
x = self.linear(x)
return x
class TwoLinear(nn.Module):
def _... | 623 | 23 | 48 | py |
learning-to-quantize | learning-to-quantize-master/models/loss.py | import torch.nn.functional as F
def nll_loss(model, data, reduction='mean', weights=1):
data, target = data[0].cuda(), data[1].cuda()
model.zero_grad()
output = model(data)
loss = F.nll_loss(output, target, reduction=reduction)*weights
return loss
| 270 | 26.1 | 66 | py |
learning-to-quantize | learning-to-quantize-master/models/cifar10_wresnet.py | # https://github.com/xternalz/WideResNet-pytorch/blob/master/wideresnet.py
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.B... | 3,850 | 43.264368 | 116 | py |
learning-to-quantize | learning-to-quantize-master/models/cifar10.py | # https://github.com/akamaster/pytorch_resnet_cifar10
'''
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the implementations on the... | 7,687 | 31.033333 | 78 | py |
learning-to-quantize | learning-to-quantize-master/models/__init__.py | import torch
import torch.nn
import models.mnist
import models.cifar10
import models.logreg
import models.imagenet
import models.cifar10_wresnet
import models.loss
def init_model(opt):
if opt.dataset == 'mnist':
if opt.arch == 'cnn':
model = models.mnist.Convnet(not opt.nodropout)
elif... | 1,969 | 36.169811 | 78 | py |
learning-to-quantize | learning-to-quantize-master/models/imagenet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models
class Model(nn.Module):
def __init__(self, arch, pretrained=False, nclass=None):
super(Model, self).__init__()
model = torchvision.models.__dict__[arch](pretrained)
if arch.startswith('alexnet') or... | 910 | 34.038462 | 73 | py |
learning-to-quantize | learning-to-quantize-master/models/clone_model.py | import torch
import torch.nn as nn
import copy
from torch.nn.parallel.parallel_apply import parallel_apply
class CloneModel(nn.Module):
def __init__(self, module, batch_size):
super(CloneModel, self).__init__()
self.replicas = [module]
self.batch_size = batch_size
for i in range(ba... | 887 | 28.6 | 75 | py |
learning-to-quantize | learning-to-quantize-master/models/mnist.py | import torch.nn as nn
import torch.nn.functional as F
class MNISTNet(nn.Module):
def __init__(self, dropout=True):
"""30 epochs no lr update
"""
super(MNISTNet, self).__init__()
self.dropout = dropout
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.conv2 = nn.Conv... | 5,494 | 30.58046 | 61 | py |
learning-to-quantize | learning-to-quantize-master/estim/optim.py | import logging
import torch
import utils
from data import get_minvar_loader
from log_utils import LogCollector
from estim.gvar import MinVarianceGradient
class OptimizerFactory(object):
def __init__(self, model, train_loader, tb_logger, opt):
self.model = model
self.opt = opt
self.niters... | 2,964 | 33.476744 | 126 | py |
learning-to-quantize | learning-to-quantize-master/estim/sgd.py | import torch
import torch.nn
import torch.multiprocessing
from .gestim import GradientEstimator
class SGDEstimator(GradientEstimator):
def __init__(self, *args, **kwargs):
super(SGDEstimator, self).__init__(*args, **kwargs)
self.init_data_iter()
def grad(self, model, in_place=False):
... | 543 | 22.652174 | 59 | py |
learning-to-quantize | learning-to-quantize-master/estim/gvar.py | import torch
import torch.nn
import torch.multiprocessing
import numpy as np
from estim.sgd import SGDEstimator
from estim.nuq import NUQEstimator
#from estim.nuq import NUQEstimatorSingleGPUParallel
from estim.nuq import NUQEstimatorMultiGPUParallel
class MinVarianceGradient(object):
def __init__(self, model, ... | 7,202 | 41.875 | 198 | py |
learning-to-quantize | learning-to-quantize-master/estim/nuq.py | import torch
import torch.nn
import torch.multiprocessing
import numpy as np
import copy
import math
from args import opt_to_nuq_kwargs
from .gestim import GradientEstimator
from nuq.quantize import QuantizeMultiBucket
class NUQEstimator(GradientEstimator):
def __init__(self, *args, **kwargs):
super(NUQE... | 5,978 | 35.018072 | 78 | py |
learning-to-quantize | learning-to-quantize-master/estim/dist.py | from scipy.stats import truncnorm
from scipy import integrate
import numpy as np
import bisect
import matplotlib.pyplot as plt
class Distribution:
def __init__(self, begin=-1, end=+1, nbins=1000, bin_type='linear'):
self.begin = begin
self.end = end
self.bin_edges = bin_edges = self._get_... | 9,644 | 34.855019 | 101 | py |
learning-to-quantize | learning-to-quantize-master/estim/gestim.py | import torch
import torch.nn
import torch.multiprocessing
import numpy as np
import math
import random
import copy
import logging
from data import InfiniteLoader
class GradientEstimator(object):
def __init__(self, data_loader, opt, tb_logger=None, *args, **kwargs):
self.opt = opt
self.model = No... | 24,608 | 34.105563 | 167 | py |
learning-to-quantize | learning-to-quantize-master/nuq/quantize.py | import numpy as np
import torch
from cuquant import QDQ
import math
from estim.dist import TruncNorm, CondNormalTrunc, CondNormalTruncHist
import time
from scipy.stats import truncnorm, norm
import scipy.integrate as integrate
EPS = 1e-7
def get_quantile_levels(bits, grad_dist):
"""quantile levels """
num_l... | 17,549 | 35.036961 | 102 | py |
learning-to-quantize | learning-to-quantize-master/nuq/cuda/test.py | import torch
import cuquant as qdq
import numpy as np
def test_qdq_gpu():
if not torch.cuda.is_available():
return
x = torch.randn(1000).cuda().uniform_(-1, 1)
q = qdq.qdq_gpu(x)
dq = np.unique(q.cpu().numpy())
print('x', x)
print('q', q)
print('unique q', dq)
print('# unique q... | 380 | 18.05 | 48 | py |
learning-to-quantize | learning-to-quantize-master/nuq/cuda/qdq.py | import torch
import math
from cuquant import QDQ
def get_uniform_levels(bits):
num_levels = 2 << bits - 1
levels_uni = torch.linspace(-1, 1, steps=num_levels)
return levels_uni
def qdq_gpu(a):
assert isinstance(a, torch.cuda.FloatTensor)
bucket_size = 16
asize = a.size()
num_tail = math... | 867 | 26.125 | 69 | py |
learning-to-quantize | learning-to-quantize-master/nuq/cuda/setup.py | import os
from setuptools import setup
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
os.system('make -j%d' % os.cpu_count())
# Python interface
setup(
name='CuQuantize',
version='0.1.0',
install_requires=['torch'],
packages=['cuquant'],
package_dir={'cuquant': './'},
ext_... | 735 | 23.533333 | 67 | py |
learning-to-quantize | learning-to-quantize-master/nuq/cuda/__init__.py | import torch
from cuquant_back import QDQ
from .qdq import qdq_gpu
| 69 | 10.666667 | 28 | py |
learning-to-quantize | learning-to-quantize-master/grid/cluster.py | from __future__ import print_function
def ssh(sargs):
"""
rm jobs/*.sh jobs/log/* -f && python grid_run.py --grid G --run_name X
pattern=""; for i in 1 2; do ./kill.sh $i $pattern; done
./start.sh
"""
jobs_0 = ['machine0_gpu0', 'machine0_gpu1',
'machine1_gpu0', 'machine1_gpu1',
... | 2,057 | 31.666667 | 76 | py |
learning-to-quantize | learning-to-quantize-master/grid/nuq.py | from collections import OrderedDict
def mnist(args):
dataset = 'mnist'
module_name = 'main.gvar'
log_dir = 'runs_%s_nuq' % dataset
exclude = ['dataset', 'epochs', 'lr_decay_epoch', 'g_epoch']
shared_args = [('dataset', dataset),
('lr', .1), # [.1, .05, .01]),
... | 12,833 | 36.747059 | 95 | py |
learning-to-quantize | learning-to-quantize-master/grid/__init__.py | 0 | 0 | 0 | py | |
learning-to-quantize | learning-to-quantize-master/main/gvar.py | from __future__ import print_function
import numpy as np
import logging
import os
import sys
import torch
import torch.nn
import torch.backends.cudnn as cudnn
import torch.optim
import torch.nn.functional as F
import torch.multiprocessing
import utils
import models
from data import get_loaders
from args import get_op... | 7,579 | 34.754717 | 94 | py |
PyBDSF | PyBDSF-master/setup.py | from skbuild import setup # This line replaces 'from setuptools import setup'
setup(
name='bdsf',
version='1.11.0a1',
author='David Rafferty',
author_email='drafferty@hs.uni-hamburg.de',
url='https://github.com/lofar-astron/PyBDSF',
description='Blob Detection and Source Finder',
long_desc... | 1,361 | 33.923077 | 78 | py |
PyBDSF | PyBDSF-master/test/test_watershed.py |
import matplotlib.cm as cm
import scipy.ndimage as nd
from bdsf.const import fwsig
from bdsf.gausfit import Op_gausfit as gg
import bdsf.functions as func
from _cbdsm import MGFunction
from _cbdsm import lmder_fit, dn2g_fit, dnsg_fit
import numpy as N
from copy import deepcopy as cp
for isl in img.islands:
#isl = i... | 4,358 | 39.738318 | 122 | py |
PyBDSF | PyBDSF-master/test/test.py |
import sys
import numpy as N
sys.path.append('')
def plotim():
""" Plots the image and overlays the island borders with the island number. Also draws the detected gaussians
at their fwhm radius, with each source being a colour (and line style). """
bdsm.analysis.plotresults(img)
def getisl(c):
"... | 6,695 | 68.030928 | 425 | py |
PyBDSF | PyBDSF-master/test/tbdsf_process_image.py | import bdsf
import sys
# Process the image
img = bdsf.process_image('tbdsf_process_image.in', ncores=2)
# List of operations that must have been done on `img`.
operations = [
'readimage', 'collapse', 'preprocess', 'rmsimage', 'threshold',
'islands', 'gausfit', 'gaul2srl', 'make_residimage', 'wavelet_atrous',
... | 568 | 27.45 | 74 | py |
PyBDSF | PyBDSF-master/test/colourcorrection.py | """
This is for pybdsm for calculating spectral index. We assume a linear spectral index
in log(freq) and then each channel has a flux which is bit wrong because of the colour
correction problem within that band.
Now we average n such channels. There will be another error made, partly because of the
colour correction... | 3,214 | 35.123596 | 88 | py |
PyBDSF | PyBDSF-master/test/do_stuff.py |
"""make watershed images for each island in isls """
def do_ws(isls, crms):
import bdsm.functions as func
import os, subprocess
import pylab as pl
import numpy as N
thr = crms
for isl in isls:
image = isl.image*~isl.mask_active
op1, markers1 = func.watershed(image, thr=thr*... | 2,153 | 38.888889 | 140 | py |
PyBDSF | PyBDSF-master/test/Ateammodels.py |
import pylab as pl
import bdsf, pyfits
import numpy as N
import os, subprocess
from bdsf.FITS import Op_loadFITS
from bdsf.collapse import Op_collapse
from bdsf.preprocess import Op_preprocess
from bdsf.rmsimage import Op_rmsimage
from bdsf.threshold import Op_threshold
from bdsf.islands import Op_islands
import bdsf... | 1,932 | 33.517857 | 142 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.