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 |
|---|---|---|---|---|---|---|
THULAC-Python | THULAC-Python-master/thulac/manage/Punctuation.py | #coding: utf-8
from ..base.Dat import Dat
class Punctuation():
def __init__(self, filename):
self.__pDat = Dat(filename)
def adjustSeg(self, sentence):
if(not self.__pDat):
return
tmpVec = []
for i in range(len(sentence)):
if(i>=len(sentence)):
break
tmp = sentence[i]
if(self.__pDat.getInfo(... | 1,600 | 22.895522 | 74 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/Postprocesser.py | from ..base.Dat import Dat, DATMaker
from ..base.compatibility import decodeGenerator
decode = decodeGenerator()
class Postprocesser():
def __init__(self, filename, tag, isTxt):
if(not filename):
return None
self.tag = tag
if(isTxt):
lexicon = []
f = Non... | 2,550 | 27.662921 | 63 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/TimeWord.py | #coding: utf-8
class TimeWord():
def __init__(self):
self.__arabicNumSet = set()
self.__timeWordSet = set()
self.__otherSet = set()
timeWord = {24180, 26376, 26085, 21495, 26102, 28857, 20998, 31186}
for i in range(48, 58):
self.__arabicNumSet.add(i)
for i... | 5,475 | 33.225 | 108 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/Preprocesser.py | #coding: utf-8
import os
import struct
from ..base.compatibility import chrGenerator
chr = chrGenerator()
class Preprocesser:
def __init__(self, rm_space=False):
self.otherSet = [65292, 12290, 65311, 65281, 65306, 65307, 8216, \
8217, 8220, 8221, 12304, 12305, \
12289, 1229... | 9,839 | 33.526316 | 119 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/__init__.py | 0 | 0 | 0 | py | |
THULAC-Python | THULAC-Python-master/thulac/manage/Filter.py | from ..base.Dat import Dat
class Filter:
def __init__(self, xuWordFile, timeWordFile):
self.xu_dat = Dat(xuWordFile)
self.time_dat = Dat(timeWordFile)
self.posSet = ["n","np","ns","ni","nz","v","a","id","t","uw"]
self.arabicNumSet = [i for i in range(48, 58)] +[i for i in range(652... | 2,792 | 35.75 | 90 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/SoExtention.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from ctypes import cdll, c_char, c_char_p, cast, POINTER
from ..base.compatibility import fixC_char_p, isPython2
import os.path
import platform
fixCCP = fixC_char_p()
# path = os.path.dirname(os.path.realpath(__file__)) #设置so文件的位置
class SoExtention:
def __init__(self, ... | 1,166 | 35.46875 | 143 | py |
THULAC-Python | THULAC-Python-master/tests/testInitVariables.py | #coding: utf-8
import thulac
import sys
prefix = sys.path[0]
def testSegOnly():
test_text = "我爱北京天安门"
thu = thulac.thulac(seg_only = True)
gold = thu.cut(test_text, text = True)
assert gold == "我 爱 北京 天安门"
#由于Tag模型初始化耗时较大,在这里将两个Tag模型的测试放在一起
def testTagAndDeli():
test_text = "我爱北京天安门"
thu = thulac.thulac(deli = ... | 1,261 | 24.24 | 75 | py |
THULAC-Python | THULAC-Python-master/tests/testAllCutMethod.py | #coding: utf-8
import thulac
import sys
prefix = sys.path[0]
thu = thulac.thulac(seg_only = True)
def readFile(file_name):
with open(file_name) as result:
for line in result:
return line
def testCutFile():
thu.cut_f(prefix +"/textForTest/input.txt", prefix +"/textForTest/output.txt")
... | 811 | 29.074074 | 87 | py |
SpectralRadex | SpectralRadex-master/setup.py | import setuptools # this is the "magic" import
from numpy.distutils.core import setup, Extension
from numpy.distutils import exec_command
from glob import glob
import os
with open("README.md", "r") as fh:
long_description = fh.read()
DATA_DIR="src/spectralradex/radex/data/"
#exec_command.exec_command( "make pyth... | 1,615 | 34.911111 | 103 | py |
SpectralRadex | SpectralRadex-master/src/radex_src/test.py | import radexwrap | 16 | 16 | 16 | py |
SpectralRadex | SpectralRadex-master/src/spectralradex/version.py | __version__='1.1.5'
| 20 | 9.5 | 19 | py |
SpectralRadex | SpectralRadex-master/src/spectralradex/__init__.py |
from . import radex
from .version import __version__
from pandas import DataFrame,read_csv
import numpy as np
import os
package_directory = os.path.dirname(os.path.abspath(__file__))
light_speed_si=2.99792e5
planck=6.62607e-34
boltzman_si=1.38e-23
light_speed_cgs=c=2.99792458e10
boltzman_cgs=1.380649e-16 #cgs unit... | 7,183 | 37.832432 | 272 | py |
SpectralRadex | SpectralRadex-master/src/spectralradex/radex/__init__.py | from radexwrap import *
from pandas import DataFrame, concat
import numpy as np
from functools import partial
import os
_ROOT = os.path.dirname(os.path.abspath(__file__))
PARTNER_LIST={1:"h2",2:"p-h2",3:"o-h2", 4:"e-", 5:"h", 6:"he",7:"h+"}
def run(parameters, output_file=None):
"""
Run a single RADEX model ... | 13,556 | 39.109467 | 262 | py |
SpectralRadex | SpectralRadex-master/tests/test_sgeirFails.py | from spectralradex import radex
params={'molfile': 'SO-pH2.dat', 'tkin': 240.23288848051274, 'tbg': 2.73, 'cdmol': 2.7117385194476626e+19, 'h2': 1477400.1189838066, 'h': 0.0, 'e-': 0.0, 'p-h2': 369350.02974595164, 'o-h2': 1108050.0892378548, 'h+': 0.0, 'linewidth': 125.49076959987242, 'fmin': 0.0, 'fmax': 30000000.0}
... | 370 | 60.833333 | 286 | py |
SpectralRadex | SpectralRadex-master/tests/new_subroutine.py | from spectralradex import radex
import numpy as np
from time import perf_counter
params=radex.get_default_parameters()
def new():
start=perf_counter()
radex.new_run("co.dat",30.0,cdmol=1e16,nh=0.0,nh2=1e5,op_ratio=3.0,ne=0.0,nhe=0.0,nhx=0.0,
linewidth=1.0,fmin=0.0,fmax=500.0,tbg=2.73,geome... | 643 | 25.833333 | 94 | py |
SpectralRadex | SpectralRadex-master/tests/datafile_reading.py | from spectralradex import radex
for data_file in ['hcn.dat', 'o-nh3.dat', 'p-h3o+.dat', 'hc3n.dat', 'catom.dat', 'sio.dat', 'ch2_h2_para.dat', 'hnc.dat', 'hcl.dat', 'ch2_h2_ortho.dat', 'co.dat', 'hco+.dat', 'oh2s.dat', 'hd.dat', 'oh.dat', 'oh@hfs.dat', 'oh2cs.dat', 'n+.dat', 'hcl@hfs.dat', 'hcn@hfs.dat', 'oatom.dat', ... | 660 | 65.1 | 442 | py |
SpectralRadex | SpectralRadex-master/tests/radex.py | from spectralradex import radex
from multiprocessing import Pool
import time
# Single run using just the basic run() method from Spectral Radex
params = radex.get_default_parameters()
# params["molfile"] = "co.dat"
# output = radex.run(params)
# print(output)
# params = radex.get_default_parameters()
# #try to exce... | 927 | 23.421053 | 78 | py |
SpectralRadex | SpectralRadex-master/docs/make_tutorials.py | import subprocess
import glob
import os
# Convert the tutorials
for fn in glob.glob("../examples/*.ipynb"):
name = os.path.splitext(os.path.split(fn)[1])[0]
outfn = os.path.join("tutorials", name + ".rst")
print("Building {0}...".format(name))
subprocess.check_call(
"jupyter nbconvert --templat... | 431 | 29.857143 | 76 | py |
SpectralRadex | SpectralRadex-master/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,408 | 34.955224 | 95 | py |
StyleMask | StyleMask-master/run_inference.py | import os
import datetime
import random
import sys
import argparse
from argparse import Namespace
import torch
from torch import nn
import numpy as np
import warnings
from tqdm import tqdm
warnings.filterwarnings("ignore")
sys.dont_write_bytecode = True
seed = 0
random.seed(seed)
import face_alignment
from libs.model... | 12,669 | 39.479233 | 162 | py |
StyleMask | StyleMask-master/extract_statistics.py | """
Script to extract the npy file with the min, max values of facial pose parameters (yaw, pitch, roll, jaw and expressions)
1. Generate a set of random synthetic images
2. Use DECA model to extract the facial shape and the corresponding parameters
3. Calculate min, max values
"""
import os
import glob
import numpy ... | 3,152 | 26.181034 | 134 | py |
StyleMask | StyleMask-master/run_trainer.py | import os
import datetime
import random
import sys
import json
import argparse
import warnings
warnings.filterwarnings("ignore")
sys.dont_write_bytecode = True
from libs.trainer import Trainer
def main():
"""
Training script.
Options:
######### General ###########
--experiment_path : path to save ex... | 5,104 | 44.176991 | 157 | py |
StyleMask | StyleMask-master/libs/trainer.py | """
"""
import os
import json
import torch
import time
import numpy as np
import pdb
import cv2
import wandb
from torch import autograd
from torch import nn
from torch.utils.data import DataLoader
from tqdm import tqdm
from libs.utilities.utils import *
from libs.utilities.image_utils import *
from libs.DECA.estimate... | 20,832 | 40.5 | 192 | py |
StyleMask | StyleMask-master/libs/models/mask_predictor.py | import torch
from torch import nn
class MaskPredictor(nn.Module):
def __init__(self, input_dim, output_dim, inner_dim=1024):
super(MaskPredictor, self).__init__()
self.masknet = nn.Sequential(nn.Linear(input_dim, inner_dim, bias=True),
nn.ReLU(),
nn.Linear(inner_dim, output_dim, bias=True),... | 628 | 21.464286 | 74 | py |
StyleMask | StyleMask-master/libs/models/inversion/psp.py | """
This file defines the core research contribution
"""
import math
import matplotlib
matplotlib.use('Agg')
import torch
from torch import nn
import torchvision.transforms as transforms
import os
from libs.models.inversion import psp_encoders
def get_keys(d, name):
if 'state_dict' in d:
d = d['state_dict']
d_f... | 1,643 | 28.357143 | 149 | py |
StyleMask | StyleMask-master/libs/models/inversion/psp_encoders.py | from enum import Enum
import math
import numpy as np
import torch
from torch import nn
from torch.nn import Conv2d, BatchNorm2d, PReLU, Sequential, Module
from libs.models.inversion.helpers import get_blocks, bottleneck_IR, bottleneck_IR_SE, _upsample_add
from libs.models.StyleGAN2.model import EqualLinear, ScaledLeak... | 12,262 | 37.806962 | 115 | py |
StyleMask | StyleMask-master/libs/models/inversion/helpers.py | from collections import namedtuple
import torch
from torch.nn import Conv2d, BatchNorm2d, PReLU, ReLU, Sigmoid, MaxPool2d, AdaptiveAvgPool2d, Sequential, Module, Linear
import torch.nn.functional as F
"""
ArcFace implementation from [TreB1eN](https://github.com/TreB1eN/InsightFace_Pytorch)
"""
class Flatten(Module):... | 5,916 | 30.473404 | 120 | py |
StyleMask | StyleMask-master/libs/models/StyleGAN2/model.py | import math
import random
import torch
from torch import nn
from torch.nn import functional as F
from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
class PixelNorm(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return input * torch.rsqrt(torch.mean(inp... | 19,525 | 26.501408 | 116 | py |
StyleMask | StyleMask-master/libs/models/StyleGAN2/convert_weight.py | import argparse
import os
import sys
import pickle
import math
import torch
import numpy as np
from torchvision import utils
from models.StyleGAN2.model import Generator, Discriminator
def convert_modconv(vars, source_name, target_name, flip=False):
weight = vars[source_name + '/weight'].value().eval()
mod_... | 7,718 | 29.152344 | 131 | py |
StyleMask | StyleMask-master/libs/models/StyleGAN2/op/upfirdn2d.py | import os
import torch
from torch.autograd import Function
from torch.utils.cpp_extension import load
module_path = os.path.dirname(__file__)
upfirdn2d_op = load(
'upfirdn2d',
sources=[
os.path.join(module_path, 'upfirdn2d.cpp'),
os.path.join(module_path, 'upfirdn2d_kernel.cu'),
],
)
cl... | 5,186 | 26.590426 | 108 | py |
StyleMask | StyleMask-master/libs/models/StyleGAN2/op/__init__.py | from .fused_act import FusedLeakyReLU, fused_leaky_relu
from .upfirdn2d import upfirdn2d
| 89 | 29 | 55 | py |
StyleMask | StyleMask-master/libs/models/StyleGAN2/op/fused_act.py | import os
import torch
from torch import nn
from torch.autograd import Function
from torch.utils.cpp_extension import load
module_path = os.path.dirname(__file__)
fused = load(
'fused',
sources=[
os.path.join(module_path, 'fused_bias_act.cpp'),
os.path.join(module_path, 'fused_bias_act_kernel... | 2,379 | 26.356322 | 83 | py |
StyleMask | StyleMask-master/libs/utilities/image_utils.py | import torch
import numpy as np
import cv2
import torchvision
import os
" Read image from path"
def read_image_opencv(image_path):
img = cv2.imread(image_path, cv2.IMREAD_COLOR) # BGR order!!!!
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
return img.astype('uint8')
" image numpy array to tensor [-1,1] range "
def... | 1,548 | 25.706897 | 77 | py |
StyleMask | StyleMask-master/libs/utilities/stylespace_utils.py | import torch
import numpy as np
from torch.nn import functional as F
import os
import math
def conv_warper(layer, input, style, noise):
# the conv should change
conv = layer.conv
batch, in_channel, height, width = input.shape
style = style.view(batch, 1, in_channel, 1, 1)
weight = conv.scale * conv.weight * s... | 3,714 | 27.576923 | 90 | py |
StyleMask | StyleMask-master/libs/utilities/dataloader.py | """
"""
import torch
import os
import glob
import cv2
import numpy as np
from torchvision import transforms, utils
from PIL import Image
from torch.utils.data import Dataset
from libs.utilities.utils import make_noise
np.random.seed(0)
class CustomDataset_validation(Dataset):
def __init__(self, synthetic_dataset_p... | 2,169 | 29.138889 | 92 | py |
StyleMask | StyleMask-master/libs/utilities/utils.py | import os
import numpy as np
import torch
from torchvision import utils as torch_utils
import glob
from datetime import datetime
import json
from libs.utilities.stylespace_utils import encoder, decoder
def make_path(filepath):
if not os.path.exists(filepath):
os.makedirs(filepath, exist_ok = True)
def save_argume... | 3,116 | 32.880435 | 158 | py |
StyleMask | StyleMask-master/libs/utilities/ffhq_cropping.py | '''
Aling and crop images like in FFHQ dataset
Code from https://github.com/NVlabs/ffhq-dataset/blob/master/download_ffhq.py
'''
import numpy as np
import cv2
import os
import glob
import matplotlib.pyplot as plt
import collections
import PIL.Image
import PIL.ImageFile
from PIL import Image
import scipy.ndimage
def... | 3,531 | 36.978495 | 159 | py |
StyleMask | StyleMask-master/libs/utilities/utils_inference.py | import os
import numpy as np
import torch
from torchvision import utils as torch_utils
import cv2
from skimage import io
from libs.utilities.image_utils import read_image_opencv, torch_image_resize
from libs.utilities.ffhq_cropping import align_crop_image
def calculate_evaluation_metrics(params_shifted, params_target... | 4,100 | 36.281818 | 144 | py |
StyleMask | StyleMask-master/libs/configs/config_models.py | import os
import numpy as np
stylegan2_ffhq_1024 = {
'image_resolution': 1024,
'channel_multiplier': 2,
'gan_weights': './pretrained_models/stylegan2-ffhq-config-f_1024.pt',
'stylespace_dim': 6048,
'split_sections': [512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 256, 256, 128, 128, 64, 64, 32],
'... | 471 | 28.5 | 104 | py |
StyleMask | StyleMask-master/libs/criteria/losses.py | import torch
import numpy as np
"""
Calculate shape losses
"""
class Losses():
def __init__(self):
self.criterion_mse = torch.nn.MSELoss()
self.criterion_l1 = torch.nn.L1Loss()
self.image_deca_size = 224
def calculate_pixel_wise_loss(self, images_shifted, images):
pixel_wise_loss = self.criterion_l1(im... | 2,137 | 32.40625 | 116 | py |
StyleMask | StyleMask-master/libs/criteria/model_irse.py | from torch.nn import Linear, Conv2d, BatchNorm1d, BatchNorm2d, PReLU, Dropout, Sequential, Module
from .helpers import get_blocks, Flatten, bottleneck_IR, bottleneck_IR_SE, l2_norm
"""
Modified Backbone implementation from [TreB1eN](https://github.com/TreB1eN/InsightFace_Pytorch)
"""
class Backbone(Module):
def __i... | 2,821 | 32.2 | 97 | py |
StyleMask | StyleMask-master/libs/criteria/l2_loss.py | import torch
l2_criterion = torch.nn.MSELoss(reduction='mean')
def l2_loss(real_images, generated_images):
loss = l2_criterion(real_images, generated_images)
return loss
| 181 | 19.222222 | 54 | py |
StyleMask | StyleMask-master/libs/criteria/helpers.py | from collections import namedtuple
import torch
from torch.nn import Conv2d, BatchNorm2d, PReLU, ReLU, Sigmoid, MaxPool2d, AdaptiveAvgPool2d, Sequential, Module
"""
ArcFace implementation from [TreB1eN](https://github.com/TreB1eN/InsightFace_Pytorch)
"""
class Flatten(Module):
def forward(self, input):
return inp... | 3,556 | 28.641667 | 112 | py |
StyleMask | StyleMask-master/libs/criteria/id_loss.py | import torch
from torch import nn
from .model_irse import Backbone
import os
import torch.backends.cudnn as cudnn
class IDLoss(nn.Module):
def __init__(self, pretrained_model_path = './pretrained_models/model_ir_se50.pth'):
super(IDLoss, self).__init__()
print('Loading ResNet ArcFace for identity l... | 1,349 | 37.571429 | 92 | py |
StyleMask | StyleMask-master/libs/criteria/lpips/lpips.py | import torch
import torch.nn as nn
from .networks import get_network, LinLayers
from .utils import get_state_dict
class LPIPS(nn.Module):
r"""Creates a criterion that measures https://github.com/eladrich/pixel2style2pixel
Learned Perceptual Image Patch Similarity (LPIPS).
Arguments:
net_type (str... | 1,220 | 33.885714 | 87 | py |
StyleMask | StyleMask-master/libs/criteria/lpips/utils.py | from collections import OrderedDict
import torch
def normalize_activation(x, eps=1e-10):
# print(torch.sum(x ** 2, dim=1, keepdim=True))
# if torch.isnan(x).any():
# # print(gradients_keep)
# pdb.set_trace()
norm_factor = torch.sqrt(torch.sum(x ** 2, dim=1, keepdim=True)+1e-9)
return ... | 1,033 | 28.542857 | 79 | py |
StyleMask | StyleMask-master/libs/criteria/lpips/networks.py | from typing import Sequence
from itertools import chain
import torch
import torch.nn as nn
from torchvision import models
from .utils import normalize_activation
def get_network(net_type: str):
if net_type == 'alex':
return AlexNet()
elif net_type == 'squeeze':
return SqueezeNet()
elif ... | 2,653 | 26.645833 | 79 | py |
StyleMask | StyleMask-master/libs/criteria/lpips/__init__.py | 0 | 0 | 0 | py | |
StyleMask | StyleMask-master/libs/DECA/estimate_DECA.py | """
"""
import torch
import numpy as np
import cv2
import os
from .decalib.deca import DECA
from .decalib.datasets import datasets
from .decalib.utils import util
from .decalib.utils.config import cfg as deca_cfg
from .decalib.utils.rotation_converter import *
class DECA_model():
def __init__(self, device):
... | 2,153 | 36.137931 | 94 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/deca.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 15,374 | 46.307692 | 189 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/__init__.py | 0 | 0 | 0 | py | |
StyleMask | StyleMask-master/libs/DECA/decalib/models/resnet.py | """
Author: Soubhik Sanyal
Copyright (c) 2019, Soubhik Sanyal
All rights reserved.
Loads different resnet models
"""
'''
file: Resnet.py
date: 2018_05_02
author: zhangxiong(1025679612@qq.com)
mark: copied from pytorch source code
'''
import torch.nn as nn
import torch.nn.functional as F
import to... | 9,332 | 31.072165 | 122 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/models/lbs.py | # -*- coding: utf-8 -*-
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# You can only use this computer program if you have closed
# a license agreement with MPG or you get the right to use the computer
# program from someone who is... | 13,783 | 35.465608 | 79 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/models/FLAME.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 12,754 | 47.683206 | 134 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/models/decoders.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 2,461 | 42.964286 | 97 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/models/encoders.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 1,424 | 33.756098 | 78 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/datasets/detectors.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 1,983 | 28.61194 | 95 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/datasets/datasets.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 3,379 | 38.302326 | 148 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/datasets/detectors_2.py | """
Calculate euler angles yaw pitch roll using deep network HopeNet
https://github.com/natanielruiz/deep-head-pose
The face detector used is SFD (taken from face-alignment FAN) https://github.com/1adrianb/face-alignment
"""
import os
import numpy as np
import sys
from matplotlib import pyplot as plt
import cv2
from... | 14,022 | 27.444219 | 110 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/utils/renderer.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 15,927 | 45.847059 | 217 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/utils/config.py | '''
Default config for DECA
'''
from yacs.config import CfgNode as CN
import argparse
import yaml
import os
cfg = CN()
abs_deca_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
cfg.deca_dir = abs_deca_dir
cfg.device = 'cuda'
cfg.device_id = '0'
cfg.pretrained_modelpath = os.path.join(cfg.de... | 2,858 | 34.7375 | 100 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/utils/util.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 22,570 | 36.55574 | 145 | py |
StyleMask | StyleMask-master/libs/DECA/decalib/utils/rotation_converter.py | # -*- coding: utf-8 -*-
#
# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
# holder of all proprietary rights on this computer program.
# Using this computer program means that you agree to the terms
# in the LICENSE file included with this software distribution.
# Any use not explicitly grant... | 12,670 | 30.132678 | 87 | py |
hedgecut | hedgecut-master/python/prepare_propublica.py | import pandas as pd
from experimentation.encoding import discretize, ordinalize, binarize
from sklearn.model_selection import train_test_split
"""The custom pre-processing function is adapted from
https://github.com/IBM/AIF360/blob/master/aif360/algorithms/preprocessing/optim_preproc_helpers/data_preproc_functions.... | 4,586 | 45.806122 | 121 | py |
hedgecut | hedgecut-master/python/prepare_shopping.py | import numpy as np
import pandas as pd
from experimentation.encoding import discretize, ordinalize, binarize
from sklearn.model_selection import train_test_split
raw_data = pd.read_csv('datasets/shopping.csv', sep=',', index_col=False)
raw_data = raw_data.dropna()
raw_data['Weekend'] = raw_data['Weekend'].astype(st... | 6,342 | 53.213675 | 117 | py |
hedgecut | hedgecut-master/python/train_time.py | import pandas as pd
from experimentation.baseline import train_time
label_attribute = 'label'
train_samples = pd.read_csv('datasets/adult-train.csv', sep='\t')
attribute_candidates = ['age', 'workclass', 'fnlwgt', 'education', 'marital_status', 'occupation', 'relationship',
'race', 'sex', 'cap... | 1,931 | 46.121951 | 115 | py |
hedgecut | hedgecut-master/python/prepare_cardio.py | import pandas as pd
from experimentation.encoding import discretize, ordinalize, binarize
from sklearn.model_selection import train_test_split
raw_data = pd.read_csv('datasets/cardio.csv', sep=';')
raw_data = raw_data.dropna()
train_samples, test_samples = train_test_split(raw_data, test_size=0.2)
age, age_discret... | 3,052 | 35.783133 | 112 | py |
hedgecut | hedgecut-master/python/prepare_adult.py | import pandas as pd
from experimentation.encoding import discretize, ordinalize, binarize
from sklearn.model_selection import train_test_split
names = ['age', 'workclass', 'fnlwgt', 'education', 'education-num', 'marital-status', 'occupation', 'relationship',
'race', 'sex', 'capital-gain', 'capital-loss', ... | 4,670 | 47.65625 | 116 | py |
hedgecut | hedgecut-master/python/sklearn_givemesomecredit.py | import pandas as pd
from experimentation.baseline import run_evaluation
train_samples = pd.read_csv('datasets/givemesomecredit-train.csv', sep='\t')
test_samples = pd.read_csv('datasets/givemesomecredit-test.csv', sep='\t')
label_attribute = 'label'
attribute_candidates = ['revolving_util', 'age', 'past_due', 'debt_r... | 503 | 41 | 102 | py |
hedgecut | hedgecut-master/python/prepare_givemesomecredit.py | import pandas as pd
from experimentation.encoding import discretize, ordinalize, binarize
from sklearn.model_selection import train_test_split
df = pd.read_csv('datasets/givemesomecredit.csv', sep=',', na_values='NA')
df = df.dropna()
train_samples, test_samples = train_test_split(df, test_size=0.2)
revolving_uti... | 3,302 | 44.246575 | 117 | py |
hedgecut | hedgecut-master/python/forget.py | import pandas as pd
from experimentation.baseline import forget
label_attribute = 'label'
train_samples = pd.read_csv('datasets/adult-train.csv', sep='\t')
attribute_candidates = ['age', 'workclass', 'fnlwgt', 'education', 'marital_status', 'occupation', 'relationship',
'race', 'sex', 'capital... | 1,907 | 45.536585 | 115 | py |
hedgecut | hedgecut-master/python/sklearn_adult.py | import pandas as pd
from experimentation.baseline import run_evaluation
train_samples = pd.read_csv('datasets/adult-train.csv', sep='\t')
test_samples = pd.read_csv('datasets/adult-test.csv', sep='\t')
label_attribute = 'label'
attribute_candidates = ['age', 'workclass', 'fnlwgt', 'education', 'marital_status', 'occu... | 529 | 43.166667 | 114 | py |
hedgecut | hedgecut-master/python/sklearn_propublica.py | import pandas as pd
from experimentation.baseline import run_evaluation
train_samples = pd.read_csv('datasets/propublica-train.csv', sep='\t')
test_samples = pd.read_csv('datasets/propublica-test.csv', sep='\t')
label_attribute = 'label'
attribute_candidates = ['age', 'decile_score', 'priors_count', 'days_b_screening... | 523 | 42.666667 | 101 | py |
hedgecut | hedgecut-master/python/sklearn_cardio.py | import pandas as pd
from experimentation.baseline import run_evaluation
train_samples = pd.read_csv('datasets/cardio-train.csv', sep='\t')
test_samples = pd.read_csv('datasets/cardio-test.csv', sep='\t')
label_attribute = 'label'
attribute_candidates = ['age', 'gender', 'height', 'weight', 'ap_hi', 'ap_lo', 'choleste... | 485 | 39.5 | 113 | py |
hedgecut | hedgecut-master/python/sklearn_shopping.py | import pandas as pd
from experimentation.baseline import run_evaluation
train_samples = pd.read_csv('datasets/shopping-train.csv', sep='\t')
test_samples = pd.read_csv('datasets/shopping-test.csv', sep='\t')
label_attribute = 'label'
attribute_candidates = ['administrative', 'administrative_duration', 'informational'... | 717 | 50.285714 | 115 | py |
hedgecut | hedgecut-master/python/experimentation/baseline.py | import time
import pandas as pd
from sklearn.metrics import accuracy_score, confusion_matrix
from sklearn import tree, ensemble
def train_time(name, train_samples, attribute_candidates, label_attribute):
X_train = train_samples[attribute_candidates].values
y_train = train_samples[label_attribute].values
... | 5,686 | 43.085271 | 107 | py |
hedgecut | hedgecut-master/python/experimentation/encoding.py |
from sklearn.preprocessing import KBinsDiscretizer, LabelEncoder
def discretize(data, attribute):
discretizer = KBinsDiscretizer(n_bins=16, encode='ordinal', strategy='quantile')
discretizer = discretizer.fit(data[attribute].values.reshape(-1, 1))
transformed_values = discretizer.transform(data[attribute... | 791 | 32 | 85 | py |
pyUSID-legacy | pyUSID-master-legacy/setup.py | from codecs import open
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.rst')) as f:
long_description = f.read()
with open(os.path.join(here, 'pyUSID/__version__.py')) as f:
__version__ = f.read().split("'")[1]
# TO... | 3,498 | 39.686047 | 117 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/__version__.py | version = '0.0.10r2'
time = '2021-03-05 18:20:25'
| 50 | 16 | 28 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/__init__.py | """
The pyUSID package.
Submodules
----------
.. autosummary::
:toctree: _autosummary
"""
from . import io
from .io import *
from . import processing
from .processing import *
from .__version__ import version as __version__
__all__ = ['__version__']
__all__ += io.__all__
__all__ += processing.__all__
| 310 | 14.55 | 47 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/reg_ref.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 3 21:14:25 2015
@author: Chris Smith, Suhas Somnath
"""
from __future__ import division, print_function, absolute_import, unicode_literals
import sys
import h5py
from sidpy.hdf.reg_ref import *
from .hdf_utils import check_if_main
if sys.version_info.major == 3:
u... | 2,836 | 33.597561 | 108 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/image.py | """
:class:`~pyUSID.io.image.ImageTranslator` class that translates conventional 2D images to USID HDF5 files
Created on Feb 9, 2016
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import, unicode_literals
import os
import sys
from warnings import warn
import h5py
i... | 10,743 | 39.851711 | 117 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/anc_build_utils.py | # -*- coding: utf-8 -*-
"""
Utilities that assist in building ancillary USID datasets manually.
Formerly known as "write_utils"
Created on Thu Sep 7 21:14:25 2017
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, unicode_literals, absolute_import
import sys
import numpy as np
... | 11,302 | 35.111821 | 119 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/usi_data.py | # -*- coding: utf-8 -*-
"""
:class:`~pyUSID.io.usi_data.USIDataset` class that simplifies slicing, visualization, reshaping, etc. of USID datasets
Created on Thu Sep 7 21:14:25 2017
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import, unicode_literals
import os
... | 56,744 | 43.056677 | 127 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/dimension.py | import sys
from enum import Enum
from warnings import warn
import numpy as np
from sidpy import Dimension as SIDimension
if sys.version_info.major == 3:
unicode = str
class DimType(Enum):
DEFAULT = 0
INCOMPLETE = 1
DEPENDENT = 2
@staticmethod
def __check_other_type(other):
if not is... | 5,617 | 35.480519 | 118 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/__init__.py | """
Tools to read, write data in h5USID files
Submodules
----------
.. autosummary::
:toctree: _autosummary
hdf_utils
image
array_translator
usi_data
dimension
translator
anc_build_utils
"""
from sidpy.sid.translator import Translator
from . import usi_data
from . import array_transl... | 918 | 21.975 | 76 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/array_translator.py | # -*- coding: utf-8 -*-
"""
:class:`~pyUSID.io.numpy_translator.ArrayTranslator` capable of translating
numeric arrays to USID HDF5 files
Created on Fri Jan 27 17:58:35 2017
@author: Suhas Somnath
"""
from __future__ import division, print_function, absolute_import, \
unicode_literals
from os import path, remov... | 6,492 | 44.725352 | 120 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/hdf_utils/base.py | # -*- coding: utf-8 -*-
"""
Simple yet handy HDF5 utilities, independent of the USID model
Created on Tue Nov 3 21:14:25 2015
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import, unicode_literals
import sys
import h5py
from sidpy.hdf import hdf_utils as hut
from... | 3,164 | 28.579439 | 82 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/hdf_utils/simple.py | # -*- coding: utf-8 -*-
"""
Lower-level and simpler USID-specific HDF5 utilities that facilitate higher-level data operations
Created on Tue Nov 3 21:14:25 2015
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import, unicode_literals
import collections
from warnings ... | 50,455 | 38.326578 | 133 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/hdf_utils/model.py | # -*- coding: utf-8 -*-
"""
Utilities for reading and writing USID datasets that are highly model-dependent (with or without N-dimensional form)
Created on Tue Nov 3 21:14:25 2015
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import, unicode_literals
from warnings ... | 50,035 | 44.281448 | 223 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/io/hdf_utils/__init__.py | """
Utilities for reading and writing USID data in HDF5 files
Submodules
----------
.. autosummary::
:toctree: _autosummary
base
simple
model
"""
from .base import *
from .simple import *
from .model import *
| 230 | 11.157895 | 57 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/processing/__init__.py | """
Formalizing data processing on USID datasets using parallel computing tools
Submodules
----------
.. autosummary::
:toctree: _autosummary
"""
from .process import Process
from sidpy.proc import comp_utils
from sidpy.proc.comp_utils import parallel_compute
__all__ = ['Process', 'parallel_compute', 'comp_uti... | 325 | 18.176471 | 75 | py |
pyUSID-legacy | pyUSID-master-legacy/pyUSID/processing/process.py | """
:class:`~pyUSID.processing.process.Process` - An abstract class for formulating scientific problems as computational
problems
Created on 7/17/16 10:08 AM
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, unicode_literals, print_function, \
absolute_import
import numpy as np
import psut... | 49,297 | 46.908649 | 120 | py |
pyUSID-legacy | pyUSID-master-legacy/tests/__init__.py | 0 | 0 | 0 | py | |
pyUSID-legacy | pyUSID-master-legacy/tests/io/test_partial_h5.py | """
This script creates a partial h5py file then tests the process class with it.
Created on: Jul 12, 2019
Author: Emily Costa
from tests.io.data_utils import make_sparse_sampling_file
import pyUSID as usid
from pyUSID.io import dtype_utils, hdf_utils
import h5py
import numpy as np
from tests.io.simple_process import... | 921 | 26.117647 | 77 | py |
pyUSID-legacy | pyUSID-master-legacy/tests/io/test_image_translator.py | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 4 15:07:16 2017
@author: Suhas Somnath
"""
from __future__ import division, print_function, unicode_literals, absolute_import
import unittest
import sys
from enum import Enum
from PIL import Image
import h5py
import numpy as np
from .data_utils import validate_aux_dset_pa... | 11,680 | 37.807309 | 113 | py |
pyUSID-legacy | pyUSID-master-legacy/tests/io/test_usi_dataset.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 3 15:07:16 2017
@author: Suhas Somnath
"""
from __future__ import division, print_function, unicode_literals, absolute_import
import unittest
import os
import sys
import h5py
import numpy as np
import dask.array as da
import matplotlib as mpl
# Attempting to get things t... | 38,183 | 41.521158 | 110 | py |
pyUSID-legacy | pyUSID-master-legacy/tests/io/test_write_utils.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 3 15:07:16 2017
@author: Suhas Somnath
"""
from __future__ import division, print_function, unicode_literals, absolute_import
import unittest
import sys
import numpy as np
sys.path.append("../../pyUSID/")
from pyUSID.io import anc_build_utils
if sys.version_info.major ... | 9,868 | 41.908696 | 123 | py |
pyUSID-legacy | pyUSID-master-legacy/tests/io/test_array_translator.py | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 3 15:07:16 2017
@author: Suhas Somnath
"""
from __future__ import division, print_function, unicode_literals, absolute_import
import unittest
import os
import sys
import h5py
import numpy as np
import dask.array as da
from .data_utils import validate_aux_dset_pair, delet... | 14,205 | 44.825806 | 121 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.