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 |
|---|---|---|---|---|---|---|
ROMP | ROMP-master/trace/lib/utils/rotation_transform.py | import torch
from torch.nn import functional as F
import numpy as np
def rotation_matrix2eular_angles(matrix, order='xyz'):
"""
input
matrix = 3x3 rotation matrix (numpy array)
oreder(str) = rotation order of x, y, z : e.g, rotation XZY -- 'xzy'
output
theta1, theta2, theta3 = rota... | 16,871 | 34.52 | 112 | py |
ROMP | ROMP-master/trace/lib/utils/transformation.py | # -*- coding: utf-8 -*-
# transformations.py
# Copyright (c) 2006-2019, Christoph Gohlke
# Copyright (c) 2006-2019, The Regents of the University of California
# Produced at the Laboratory for Fluorescence Dynamics
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modifica... | 66,841 | 33.313142 | 79 | py |
ROMP | ROMP-master/trace/lib/utils/demo_utils.py | import cv2
import keyboard
import imageio
import torch
import numpy as np
import random
#import open3d as o3d
from transforms3d.axangles import axangle2mat
import pickle
from PIL import Image
import torchvision
import time
import sys, os
root_dir = os.path.join(os.path.dirname(__file__),'..')
if root_dir not in sys.pat... | 13,811 | 39.268222 | 148 | py |
ROMP | ROMP-master/trace/lib/utils/make_demo.py | import cv2
import numpy as np
import torch
import os
import glob
import sys,os
from PIL import Image
sys.path.append(os.path.abspath(__file__).replace('utils/make_demo.py',''))
import config
shape = [1024,1024-200]
def grub_imges_demo(fold_name):
imgs_path_demo = os.path.join('/home/yusun/datasets/demo_image','{... | 4,630 | 37.591667 | 143 | py |
ROMP | ROMP-master/trace/lib/utils/cam_utils.py | import torch
import torch.nn.functional as F
import numpy as np
import cv2
import sys, os
import config
import constants
from config import args
#print('Assuming FOV is ', args().FOV)
tan_fov = np.tan(np.radians(args().FOV/2.))
cam3dmap_anchor = torch.from_numpy(constants.get_cam3dmap_anchor(args().FOV,args().center... | 8,052 | 38.282927 | 176 | py |
ROMP | ROMP-master/trace/lib/utils/center_utils.py | import torch
import constants
from config import args
import numpy as np
from .cam_utils import convert_cam_params_to_centermap_coords
def denormalize_center(center, size=args().centermap_size):
center = (center+1)/2*size
center[center<1] = 1
center[center>size - 1] = size - 1
if isinstance(center, np... | 2,334 | 40.696429 | 115 | py |
ROMP | ROMP-master/trace/lib/utils/video_utils.py | import torch
import numpy as np
from config import args
import copy
def match_trajectory_gts(traj3D_gts, traj2D_gts, traj_sids, subject_ids, batch_ids):
subject_num = len(subject_ids)
traj3D_gts_matched = torch.ones(
subject_num, args().temp_clip_length, 3).float().to(traj3D_gts.device) * -2.
traj2... | 24,291 | 55.493023 | 178 | py |
ROMP | ROMP-master/trace/lib/utils/train_utils.py | import sys,os
import random
import torch
import numpy as np
import logging
def justify_detection_state(detection_flag, reorganize_idx):
if detection_flag.sum() == 0:
detection_flag = False
else:
reorganize_idx = reorganize_idx[detection_flag.bool()].long()
detection_flag = True
retu... | 8,668 | 36.047009 | 108 | py |
ROMP | ROMP-master/trace/lib/utils/rot_6D.py | import torch
from torch.nn import functional as F
import numpy as np
#from utils.rotation_transform import rotation_matrix_to_angle_axis
from utils.util import rotation_matrix_to_angle_axis
def rotation_6d_to_matrix(d6: torch.Tensor) -> torch.Tensor:
"""
Converts 6D rotation representation by Zhou et al. [1] t... | 11,629 | 35.23053 | 126 | py |
ROMP | ROMP-master/trace/lib/utils/vis_utils.py | import cv2
import torch
import numpy as np
color_list = np.array([[.7, .7, .6],[.7, .5, .5],[.5, .5, .7], [.5, .55, .3],[.3, .5, .55], \
[1,0.855,0.725],[0.588,0.804,0.804],[1,0.757,0.757], [0.933,0.474,0.258],[0.847,191/255,0.847], [0.941,1,1]])
focal_length = 443.4
def get_rotate_x_mat(angle):
angle = ... | 15,331 | 44.360947 | 200 | py |
ROMP | ROMP-master/trace/lib/utils/quaternion_operations.py | import torch
import math
def q_mul(q1, q2):
"""
Multiply quaternion q1 with q2.
Expects two equally-sized tensors of shape [*, 4], where * denotes any number of dimensions.
Returns q1*q2 as a tensor of shape [*, 4].
"""
assert q1.shape[-1] == 4
assert q2.shape[-1] == 4
original_shape = ... | 3,648 | 36.234694 | 119 | py |
ROMP | ROMP-master/trace/lib/utils/projection.py | import torch
import numpy as np
import sys, os
import constants
from config import args
from utils.cam_utils import denormalize_cam_params_to_trans
#from pudb import set_trace; set_trace(paused=False)
def filter_out_incorrect_trans(kp_3ds, trans, kp_2ds, thresh=20, focal_length=args().focal_length, center_offset=torc... | 13,593 | 42.018987 | 183 | py |
ROMP | ROMP-master/trace/lib/utils/util.py | #encoding=utf-8
import h5py
import torch
import numpy as np
import json
import torch.nn.functional as F
import cv2
import math
import hashlib
import shutil
import pickle
import yaml
import csv
import platform
import os,sys
import glob
import time
from io import BytesIO
from scipy.spatial.transform import Rotation as R
... | 26,864 | 30.274738 | 129 | py |
ROMP | ROMP-master/trace/lib/utils/gpu_memory_log.py | import gc
import datetime
import pynvml
import torch
import numpy as np
import sys
def _get_tensors():
for obj in gc.get_objects():
if torch.is_tensor(obj):
tensor = obj
else:
continue
if tensor.is_cuda:
yield tensor
def _write_log(f, write_str):
pr... | 2,358 | 36.444444 | 108 | py |
ROMP | ROMP-master/trace/lib/utils/augments.py | import imgaug as ia
import imgaug.augmenters as iaa
from imgaug.augmenters import compute_paddings_to_reach_aspect_ratio, Crop, Pad
from imgaug.augmentables import Keypoint, KeypointsOnImage
import random
import cv2
import numpy as np
ia.seed(1)
import random
import math
import numpy as np
import torch
from PIL impor... | 23,644 | 39.488014 | 155 | py |
ROMP | ROMP-master/trace/lib/utils/debug.py | import cv2
import torch
import numpy as np
from vedo import *
import logging
def show_keypoints(kp3ds_list, bones_list, colors_list, invalid_value=-2., point_radius=6):
show_items = []
for kp3ds, bones, colors in zip(kp3ds_list, bones_list, colors_list):
points3D = []
for point in kp3ds:
... | 5,312 | 47.743119 | 195 | py |
ROMP | ROMP-master/trace/lib/raft/corr.py | import torch
import torch.nn.functional as F
from raft.utils.utils import bilinear_sampler, coords_grid
try:
import alt_cuda_corr
except:
# alt_cuda_corr is not compiled
pass
class CorrBlock:
def __init__(self, fmap1, fmap2, num_levels=4, radius=4):
self.num_levels = num_levels
self.r... | 3,090 | 32.597826 | 74 | py |
ROMP | ROMP-master/trace/lib/raft/update.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class FlowHead(nn.Module):
def __init__(self, input_dim=128, hidden_dim=256):
super(FlowHead, self).__init__()
self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1)
self.conv2 = nn.Conv2d(hidden_dim, 2, 3, padding=1)
... | 5,302 | 37.151079 | 87 | py |
ROMP | ROMP-master/trace/lib/raft/extractor.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, padding=1, stride=stride)
s... | 8,847 | 32.014925 | 93 | py |
ROMP | ROMP-master/trace/lib/raft/raft.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from raft.update import BasicUpdateBlock, SmallUpdateBlock
from raft.extractor import BasicEncoder, SmallEncoder
from raft.corr import CorrBlock, AlternateCorrBlock
from raft.utils.utils import bilinear_sampler, coords_grid, upflow8
... | 4,714 | 32.920863 | 102 | py |
ROMP | ROMP-master/trace/lib/raft/process.py |
from config import args
import os
import cv2
import glob
import numpy as np
import torch
from PIL import Image
import cv2
from torch import nn
import torch.nn.functional as F
from raft.raft import RAFT
from raft.utils import flow_viz
from raft.utils.utils import InputPadder
class FlowExtract(nn.Module):
def __in... | 2,932 | 35.6625 | 186 | py |
ROMP | ROMP-master/trace/lib/raft/utils/utils.py | import torch
import torch.nn.functional as F
import numpy as np
from scipy import interpolate
class InputPadder:
""" Pads images such that dimensions are divisible by 8 """
def __init__(self, dims, mode='sintel'):
self.ht, self.wd = dims[-2:]
pad_ht = (((self.ht // 8) + 1) * 8 - self.ht) % 8
... | 2,489 | 29 | 93 | py |
ROMP | ROMP-master/trace/lib/raft/utils/augmentor.py | import numpy as np
import random
import math
from PIL import Image
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import torch
from torchvision.transforms import ColorJitter
import torch.nn.functional as F
class FlowAugmentor:
def __init__(self, crop_size, min_scale=-0.2, max_scale=0.5, do_flip=Tru... | 9,108 | 35.878543 | 97 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpl_regressor.py | import sys,os
import torch
import torch.nn as nn
import config
import numpy as np
from .smpl import SMPL
from config import args
class SMPLR(nn.Module):
def __init__(self, use_gender=False):
super(SMPLR, self).__init__()
model_path = os.path.join(config.model_dir,'parameters','smpl')
self.... | 1,540 | 52.137931 | 161 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpl_wrapper.py | import torch
import torch.nn as nn
import numpy as np
import sys, os
import config
from config import args
import constants
from smpl_family.smpl import SMPL
from utils.projection import vertices_kp3d_projection
from utils.rot_6D import rot6D_to_angular
class SMPLWrapper(nn.Module):
def __init__(self):
s... | 3,058 | 58.980392 | 165 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smplx.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 i... | 8,598 | 49.28655 | 139 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpl_wrapper_relative_temp.py | import torch
import torch.nn as nn
import numpy as np
import logging
import sys
import os
import config
from config import args
import constants
from smpl_family.create_smpl_models import create_model
from utils.projection import vertices_kp3d_projection_withfov, vertices_kp3d_projection
from utils.rot_6D import rot6D... | 6,829 | 54.528455 | 198 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpla.py | import torch
from smpl_family.smpl import SMPL
import torch.nn as nn
from config import args
class SMPLA_parser(nn.Module):
def __init__(self, smpla_path, smil_path, baby_thresh=0.8):
super(SMPLA_parser, self).__init__()
self.smil_model = SMPL(smil_path, model_type='smpl')
self.smpla_model ... | 1,658 | 52.516129 | 189 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpl.py | from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import os,sys
import os.path as osp
import pickle
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import constants
def regress_joints_from_vertices(vertices, J_regressor)... | 15,388 | 39.604222 | 143 | py |
ROMP | ROMP-master/trace/lib/smpl_family/smpl_wrapper_relative.py | import torch
import torch.nn as nn
import numpy as np
import logging
import sys, os
import config
from config import args
import constants
from smpl_family.smpla import SMPLA_parser
from utils.projection import vertices_kp3d_projection
from utils.rot_6D import rot6D_to_angular
from maps_utils.relative_parser import p... | 9,532 | 54.424419 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/transfer_smpl_parameters.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... | 3,784 | 36.85 | 105 | py |
ROMP | ROMP-master/trace/lib/smpl_family/flame.py | """
FLAME Layer: Implementation of the 3D Statistical Face model in PyTorch
It is designed in a way to directly plug in as a decoder layer in a
Deep learning framework for training and testing
It can also be used for 2D or 3D optimisation applications
Author: Soubhik Sanyal
Copyright (c) 2019, Soubhik Sanyal
All right... | 11,909 | 48.012346 | 127 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smplxa_info_sparse.py | import pickle
import numpy as np
import os
import torch
gender = 'neutral'.upper()
#gender = 'female'.upper()
# gender = 'male'.upper()
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/"
with open(root_folder+"smplx/SMPLX_{}.pkl".format(gender.upper()), 'rb') as smpl_file:
model_in... | 5,829 | 45.269841 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smplx_info_sparse.py | import pickle
import numpy as np
import os
import torch
gender = 'neutral'.upper()
#gender = 'female'.upper()
# gender = 'male'.upper()
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/"
with open(root_folder+"smplx/SMPLX_{}.pkl".format(gender.upper()), 'rb') as smpl_file:
model_in... | 5,173 | 43.603448 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smplx_info.py | import pickle
import numpy as np
import os
import torch
gender = 'neutral'.upper()
#gender = 'male'.upper()
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/"
with open(root_folder+"smplx/SMPLX_{}.pkl".format(gender.upper()), 'rb') as smpl_file:
model_info = pickle.load(smpl_file, ... | 4,891 | 44.719626 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smil_info.py | import pickle
import numpy as np
import os
import torch
gender = 'neutral'.upper()
import pickle
import numpy as np
import os
import torch
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/"
with open("/home/yusun/Infinity/project_data/romp_data/model_data/parameters/smil/smil_web.pkl"... | 3,540 | 41.662651 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smpl_info.py | import pickle
import numpy as np
import os
import torch
gender = 'female'.upper()
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/smpl/"
with open(root_folder+"SMPL_{}.pkl".format(gender.upper()), 'rb') as smpl_file:
model_info = pickle.load(smpl_file, encoding='latin1')
np_model... | 4,317 | 43.515464 | 203 | py |
ROMP | ROMP-master/trace/lib/smpl_family/pack_smpl_params/pack_smpla_info.py | import pickle
import numpy as np
import os
import torch
gender = 'neutral'.upper()
#gender = 'male'.upper()
root_folder = "/home/yusun/Infinity/project_data/romp_data/model_data/parameters/"
with open(root_folder+"smplx/SMPLX_{}.pkl".format(gender.upper()), 'rb') as smpl_file:
model_info = pickle.load(smpl_file, ... | 4,891 | 44.719626 | 203 | py |
Causal-SE | Causal-SE-main/main.py | import os
import sys
from argparse import ArgumentParser
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torchaudio.functional as AF
import torchaudio
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from torchm... | 8,822 | 30.967391 | 112 | py |
Causal-SE | Causal-SE-main/dataset.py | import torch
import torch.nn.functional as F
from torch.utils.data import Dataset
import torchaudio
import os
import sys
import random
class VoiceBankDemandDataset(Dataset):
def __init__(self, data_dir, tier='train', n_fft=1023, hop_length=320, p_input=0.5):
self.data_dir = data_dir
self.tier = ti... | 13,932 | 35.95756 | 117 | py |
Causal-SE | Causal-SE-main/conformer.py | import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
from einops.layers.torch import Rearrange
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def calc_same_padding(kernel_size):
pad = ker... | 6,982 | 30.454955 | 197 | py |
Causal-SE | Causal-SE-main/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torchaudio.functional as AF
import torchaudio.transforms as AT
import torch.distributions as dist
from transformers import WavLMModel, WavLMConfig
from conformer import ConformerBlock
from einops.layers.torch import Rearrange
from demucs.ce_dem... | 21,244 | 30.196769 | 101 | py |
Causal-SE | Causal-SE-main/main-vanillaSE.py | import os
import sys
from argparse import ArgumentParser
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader
import torchaudio.functional as AF
import torchaudio
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint
from torchm... | 6,186 | 28.461905 | 87 | py |
Causal-SE | Causal-SE-main/cmgan/discriminator.py | import numpy as np
from joblib import Parallel, delayed
from pesq import pesq
from utils import *
def pesq_loss(clean, noisy, sr=16000):
try:
pesq_score = pesq(sr, clean, noisy, 'wb')
except:
# error can happen due to silent period
pesq_score = -1
return pesq_score
def batch_pesq... | 1,817 | 33.961538 | 96 | py |
Causal-SE | Causal-SE-main/cmgan/conformer.py | import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
from einops.layers.torch import Rearrange
# source: https://github.com/lucidrains/conformer/blob/master/conformer/conformer.py
# helper functions
def exists(val):
return val is not None
def default(val, d):
... | 6,308 | 28.759434 | 164 | py |
Causal-SE | Causal-SE-main/cmgan/generator.py | from cmgan.conformer import ConformerBlock
from utils import *
import torch.nn as nn
class DilatedDenseNet(nn.Module):
def __init__(self, depth=4, in_channels=64):
super(DilatedDenseNet, self).__init__()
self.depth = depth
self.in_channels = in_channels
self.pad = nn.ConstantPad2d(... | 7,661 | 41.331492 | 192 | py |
Causal-SE | Causal-SE-main/demucs/resample.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import math
import torch as th
from torch.nn import functional as F
def sinc(t):
"""sinc.
:p... | 2,184 | 28.931507 | 90 | py |
Causal-SE | Causal-SE-main/demucs/demucs.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import math
import time
import torch as th
from torch import nn
from torch.nn import functional as F
... | 16,821 | 35.890351 | 97 | py |
Causal-SE | Causal-SE-main/demucs/ce_demucs.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import math
import time
import torch as th
from torch import nn
from torch.nn import functional as F
... | 23,326 | 35.334891 | 103 | py |
redback | redback-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,390 | 34.686567 | 79 | py |
PAN.pytorch | PAN.pytorch-master/eval.py | # -*- coding: utf-8 -*-
# @Time : 2018/6/11 15:54
# @Author : zhoujun
import os
import cv2
import torch
import shutil
import numpy as np
from tqdm.auto import tqdm
from predict import Pytorch_model
from utils import cal_recall_precison_f1, draw_bbox
torch.backends.cudnn.benchmark = True
def main(model_path, img_... | 2,050 | 36.290909 | 92 | py |
PAN.pytorch | PAN.pytorch-master/predict.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/24 12:06
# @Author : zhoujun
import torch
from torchvision import transforms
import os
import cv2
import time
from models import get_model
from post_processing import decode
def decode_clip(preds, scale=1, threshold=0.7311, min_area=5):
import pyclipper
import nu... | 4,198 | 32.862903 | 98 | py |
PAN.pytorch | PAN.pytorch-master/trainer/trainer.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:58
# @Author : zhoujun
import os
import cv2
import shutil
import numpy as np
import traceback
import time
from tqdm import tqdm
import torch
import torchvision.utils as vutils
from torchvision import transforms
from post_processing import decode
from utils import Polyn... | 10,101 | 50.540816 | 254 | py |
PAN.pytorch | PAN.pytorch-master/post_processing/__init__.py | # -*- coding: utf-8 -*-
# @Time : 2019/9/8 14:18
# @Author : zhoujun
import os
import cv2
import torch
import time
import subprocess
import numpy as np
from .pypse import pse_py
from .kmeans import km
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
if subprocess.call(['make', '-C', BASE_DIR]) != 0: # ret... | 3,071 | 32.032258 | 98 | py |
PAN.pytorch | PAN.pytorch-master/data_loader/dataset.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:54
# @Author : zhoujun
import cv2
import numpy as np
from PIL import Image
from torch.utils.data import Dataset, DataLoader
from data_loader.data_utils import image_label
from utils import order_points_clockwise
class ImageDataset(Dataset):
def __init__(self, dat... | 6,546 | 39.41358 | 115 | py |
PAN.pytorch | PAN.pytorch-master/data_loader/__init__.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:52
# @Author : zhoujun
from torch.utils.data import DataLoader
from torchvision import transforms
import copy
import pathlib
from . import dataset
def get_datalist(train_data_path, validation_split=0.1):
"""
获取训练和验证的数据list
:param train_data_path: 训练的data... | 3,445 | 41.02439 | 135 | py |
PAN.pytorch | PAN.pytorch-master/models/loss.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:56
# @Author : zhoujun
import itertools
import torch
from torch import nn
import numpy as np
class PANLoss(nn.Module):
def __init__(self, alpha=0.5, beta=0.25, delta_agg=0.5, delta_dis=3, ohem_ratio=3, reduction='mean'):
"""
Implement PSE Loss.
... | 8,451 | 43.719577 | 120 | py |
PAN.pytorch | PAN.pytorch-master/models/model.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:57
# @Author : zhoujun
import torch
from torch import nn
import torch.nn.functional as F
from models.modules import *
backbone_dict = {'resnet18': {'models': resnet18, 'out': [64, 128, 256, 512]},
'resnet34': {'models': resnet34, 'out': [64, 128, 256... | 2,873 | 38.916667 | 104 | py |
PAN.pytorch | PAN.pytorch-master/models/modules/shufflenetv2.py | # -*- coding: utf-8 -*-
# @Time : 2019/11/1 15:31
# @Author : zhoujun
import torch
import torch.nn as nn
from torchvision.models.utils import load_state_dict_from_url
__all__ = [
'ShuffleNetV2', 'shufflenet_v2_x0_5', 'shufflenet_v2_x1_0',
'shufflenet_v2_x1_5', 'shufflenet_v2_x2_0'
]
model_urls = {
's... | 7,450 | 36.069652 | 112 | py |
PAN.pytorch | PAN.pytorch-master/models/modules/segmentation_head.py | # -*- coding: utf-8 -*-
# @Time : 2019/9/13 10:29
# @Author : zhoujun
import torch
from torch import nn
import torch.nn.functional as F
class FPN(nn.Module):
def __init__(self, backbone_out_channels, **kwargs):
"""
:param backbone_out_channels: 基础网络输出的维度
:param kwargs:
"""
... | 7,244 | 35.225 | 116 | py |
PAN.pytorch | PAN.pytorch-master/models/modules/resnet.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:55
# @Author : zhoujun
import torch.nn as nn
from torchvision.models.utils import load_state_dict_from_url
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d']
model_urls = {
'resnet1... | 11,217 | 36.393333 | 106 | py |
PAN.pytorch | PAN.pytorch-master/base/base_trainer.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:50
# @Author : zhoujun
import os
import shutil
import pathlib
from pprint import pformat
import torch
from torch import nn
from utils import setup_logger
class BaseTrainer:
def __init__(self, config, model, criterion, weights_init):
config['trainer']['o... | 8,467 | 40.106796 | 118 | py |
PAN.pytorch | PAN.pytorch-master/utils/schedulers.py | from torch.optim.lr_scheduler import _LRScheduler
class ConstantLR(_LRScheduler):
def __init__(self, optimizer, last_epoch=-1):
super(ConstantLR, self).__init__(optimizer, last_epoch)
def get_lr(self):
return [base_lr for base_lr in self.base_lrs]
class PolynomialLR(_LRScheduler):
def _... | 2,014 | 30.484375 | 93 | py |
PAN.pytorch | PAN.pytorch-master/utils/util.py | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 21:59
# @Author : zhoujun
import time
import json
import cv2
import torch
import numpy as np
import matplotlib.pyplot as plt
def setup_logger(log_file_path: str = None):
import logging
from colorlog import ColoredFormatter
logging.basicConfig(filename=log_fi... | 4,618 | 32.230216 | 104 | py |
PAN.pytorch | PAN.pytorch-master/utils/metrics.py | # Adapted from score written by wkentaro
# https://github.com/wkentaro/pytorch-fcn/blob/master/torchfcn/utils.py
import numpy as np
class runningScore(object):
def __init__(self, n_classes):
self.n_classes = n_classes
self.confusion_matrix = np.zeros((n_classes, n_classes))
def _fast_hist(s... | 1,945 | 35.037037 | 100 | py |
abm-pytorch | abm-pytorch-master/res_inner_nabp.py | import pdb
import torch
import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['res_INABP', 'res_inabp_18', 'res_inabp_34', \
'res_inabp_50', 'res_inabp_101', 'res_inabp_152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resn... | 14,783 | 32.676538 | 79 | py |
abm-pytorch | abm-pytorch-master/main.py | import argparse
import os
import time
import json
import shutil
import pdb
import torch
import torchvision
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
from torch.nn.utils import clip_grad_norm
from dataset_3d import TSNDataSet_3D
from transforms import *
from ... | 21,421 | 34.584718 | 81 | py |
abm-pytorch | abm-pytorch-master/res_inner_abp.py | import torch
import torch.nn as nn
import math
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
__all__ = ['res_IABP', 'res_iabp_18', 'res_iabp_34', \
'res_iabp_50', 'res_iabp_101', 'res_iabp_152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.p... | 15,349 | 31.315789 | 78 | py |
abm-pytorch | abm-pytorch-master/res_inner_nabp_wrapper.py | import os
import time
import json
import shutil
import pdb
import torch
import torchvision
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.nn.functional as F
from torch.nn.utils import clip_grad_norm
from res_inner_nabp import res_INABP, BasicBlock, B... | 5,719 | 34.974843 | 83 | py |
abm-pytorch | abm-pytorch-master/res_wrapper.py | import os
import time
import json
import shutil
import pdb
import torch
import torchvision
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.nn.functional as F
from torch.nn.utils import clip_grad_norm
from res_single_frame import res_SF, BasicBlock, Bo... | 6,864 | 34.755208 | 83 | py |
abm-pytorch | abm-pytorch-master/res_single_frame.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['res_SF', 'res_sf_18', 'res_sf_34', \
'res_sf_50', 'res_sf_101', 'res_sf_152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/mode... | 7,833 | 30.211155 | 86 | py |
abm-pytorch | abm-pytorch-master/dataset_3d.py | import torch.utils.data as data
import torch
from PIL import Image
import os
import os.path
import numpy as np
import pdb
from numpy.random import randint
from temporal_transforms import ReverseFrames, ShuffleFrames
from multiprocessing.dummy import Pool as ThreadPool
class VideoRecord(object):
def __init__(se... | 11,491 | 39.322807 | 79 | py |
abm-pytorch | abm-pytorch-master/res_inner_abp_wrapper.py | import os
import time
import json
import shutil
import pdb
import torch
import torchvision
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.nn.functional as F
from torch.nn.utils import clip_grad_norm
from res_inner_abp import res_IABP, BasicBlock, Bas... | 5,256 | 37.372263 | 110 | py |
abm-pytorch | abm-pytorch-master/res_alongframe_approximated_multilayer_feature_bilinear.py | from res_single_frame import res_SF, Bottleneck, BasicBlock
import torch.nn.functional as F
import torch.nn as nn
import torch
__all__ = ['res_AAMFB', 'res_aamfb_18', 'res_aamfb_34', \
'res_aamfb_50', 'res_aamfb_101', 'res_aamfb_152']
class res_AAMFB(res_SF):
def __init__(self,
block,
... | 5,685 | 31.124294 | 79 | py |
abm-pytorch | abm-pytorch-master/transforms.py | import torchvision
import random
from PIL import Image, ImageOps
import numpy as np
import pdb
import numbers
import math
import torch
class ReverseGroupNormalize(object):
def __init__(self, mean, std):
self.mean = mean
self.std = std
def __call__(self, tensor):
rep_mean = self.mean * ... | 12,115 | 32.655556 | 94 | py |
trustGAN | trustGAN-main/py/trustgan/losses.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 4,443 | 28.236842 | 104 | py |
trustGAN | trustGAN-main/py/trustgan/download_datasets.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 7,240 | 29.682203 | 108 | py |
trustGAN | trustGAN-main/py/trustgan/training.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 23,689 | 31.811634 | 176 | py |
trustGAN | trustGAN-main/py/trustgan/dataset.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 3,467 | 26.09375 | 88 | py |
trustGAN | trustGAN-main/py/trustgan/networks.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 10,131 | 27.380952 | 85 | py |
trustGAN | trustGAN-main/py/trustgan/waveunet.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 6,291 | 29.396135 | 87 | py |
trustGAN | trustGAN-main/py/trustgan/transforms.py | # Authors:
# Helion du Mas des Bourboux <helion.dumasdesbourboux'at'thalesgroup.com>
#
# MIT License
#
# Copyright (c) 2022 THALES
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
#... | 1,526 | 32.195652 | 79 | py |
asr-wav2vec | asr-wav2vec-main/evaluation.py | import argparse
import re
from typing import Dict
import torch
from datasets import Audio, Dataset, load_dataset, load_metric
from transformers import AutoFeatureExtractor, pipeline
# load dataset
dataset = load_dataset("common_voice", "de", split="test")
# use only 1% of data
#dataset = load_dataset("common_voice... | 1,865 | 27.707692 | 113 | py |
asr-wav2vec | asr-wav2vec-main/train.py | import random
import re
import json
from typing import Any, Dict, List, Optional, Union
import pandas as pd
import numpy as np
import torch
# import soundfile
from datasets import load_dataset, load_metric, Audio
from dataclasses import dataclass, field
from transformers import Wav2Vec2CTCTokenizer, Wav2Vec2FeatureE... | 8,834 | 35.966527 | 153 | py |
LM_bias | LM_bias-main/src/local_bias/measure_local_bias.py | import numpy as np
import torch
from torch.nn import functional as F
import scipy.stats
import time
import random
import os
import sys
import transformers
from transformers import (
CTRLLMHeadModel,
CTRLTokenizer,
GPT2LMHeadModel,
GPT2Tokenizer,
OpenAIGPTLMHeadModel,
OpenAIGPTTokenizer,
Tra... | 12,255 | 45.778626 | 178 | py |
LM_bias | LM_bias-main/src/local_bias/utils.py | import torch
import numpy as np
from torch.nn import functional as F
import scipy.stats
from sklearn.decomposition import PCA
import json
def doPCA(pairs, num_components=10):
matrix = []
for a, b in pairs:
center = (a + b) / 2
norm_a = a - center
norm_b = b - center
norm_a, nor... | 34,376 | 46.221154 | 147 | py |
LM_bias | LM_bias-main/src/data_preprocess/data_preprocess.py | from gensim.models import KeyedVectors
from sklearn.decomposition import PCA
import numpy as np
import torch
import random
import argparse
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--embed_source", type=str, default="glove",
help="choose the source of word... | 10,309 | 45.651584 | 127 | py |
LM_bias | LM_bias-main/src/data_preprocess/context_nullspace_projection.py | # Some codes are from https://github.com/shauli-ravfogel/nullspace_projection
import transformers
from transformers import (
CTRLLMHeadModel,
CTRLTokenizer,
GPT2LMHeadModel,
GPT2Tokenizer,
OpenAIGPTLMHeadModel,
OpenAIGPTTokenizer,
TransfoXLLMHeadModel,
TransfoXLTokenizer,
XLMTokeniz... | 12,123 | 41.243902 | 134 | py |
LM_bias | LM_bias-main/src/global_bias/generate_full_sentence.py | # generate full sentences
import numpy as np
import torch
from torch.nn import functional as F
import scipy.stats
import time
import random
import os
import sys
import argparse
import transformers
from transformers import (
CTRLLMHeadModel,
CTRLTokenizer,
GPT2LMHeadModel,
GPT2Tokenizer,
OpenAIGPTL... | 15,411 | 46.71517 | 175 | py |
DB | DB-master/convert_to_onnx.py | import argparse
import os
import torch
import numpy as np
from concern.config import Configurable, Config
def main():
parser = argparse.ArgumentParser(description='Convert model to ONNX')
parser.add_argument('exp', type=str)
parser.add_argument('resume', type=str, help='Resume from checkpoint')
parser... | 2,851 | 35.101266 | 116 | py |
DB | DB-master/demo.py | #!python3
import argparse
import os
import torch
import cv2
import numpy as np
from experiment import Structure, Experiment
from concern.config import Configurable, Config
import math
def main():
parser = argparse.ArgumentParser(description='Text Recognition Training')
parser.add_argument('exp', type=str)
... | 6,451 | 42.302013 | 125 | py |
DB | DB-master/eval.py | #!python3
import argparse
import os
import torch
import yaml
from tqdm import tqdm
import numpy as np
from trainer import Trainer
# tagged yaml objects
from experiment import Structure, TrainSettings, ValidationSettings, Experiment
from concern.log import Logger
from data.data_loader import DataLoader
from data.image_d... | 9,269 | 46.783505 | 164 | py |
DB | DB-master/train.py | #!python3
import argparse
import time
import torch
import yaml
from trainer import Trainer
# tagged yaml objects
from experiment import Structure, TrainSettings, ValidationSettings, Experiment
from concern.log import Logger
from data.data_loader import DataLoader
from data.image_dataset import ImageDataset
from train... | 3,964 | 54.069444 | 144 | py |
DB | DB-master/trainer.py | import os
import torch
from tqdm import tqdm
from experiment import Experiment
from data.data_loader import DistributedSampler
class Trainer:
def __init__(self, experiment: Experiment):
self.init_device()
self.experiment = experiment
self.structure = experiment.structure
self.lo... | 7,064 | 36.780749 | 129 | py |
DB | DB-master/assets/ops/dcn/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='deform_conv',
ext_modules=[
CUDAExtension('deform_conv_cuda', [
'src/deform_conv_cuda.cpp',
'src/deform_conv_cuda_kernel.cu',
]),
CUDAExtension('deform_p... | 469 | 28.375 | 72 | py |
DB | DB-master/assets/ops/dcn/functions/deform_pool.py | import torch
from torch.autograd import Function
from .. import deform_pool_cuda
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(ctx,
data,
rois,
offset,
spatial_scale,
out_size,
out_channels,... | 2,370 | 32.871429 | 78 | py |
DB | DB-master/assets/ops/dcn/functions/deform_conv.py | import torch
from torch.autograd import Function
from torch.nn.modules.utils import _pair
from .. import deform_conv_cuda
class DeformConvFunction(Function):
@staticmethod
def forward(ctx,
input,
offset,
weight,
stride=1,
paddin... | 7,291 | 39.065934 | 79 | py |
DB | DB-master/assets/ops/dcn/modules/deform_pool.py | from torch import nn
from ..functions.deform_pool import deform_roi_pooling
class DeformRoIPooling(nn.Module):
def __init__(self,
spatial_scale,
out_size,
out_channels,
no_trans,
group_size=1,
part_size=None,
... | 7,058 | 39.803468 | 79 | py |
DB | DB-master/assets/ops/dcn/modules/deform_conv.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from ..functions.deform_conv import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(self,
in_channels,
out_channels,
kernel_size,
... | 5,198 | 31.905063 | 78 | py |
DB | DB-master/training/checkpoint.py | from concern.config import Configurable, State
import os
import torch
class Checkpoint(Configurable):
start_epoch = State(default=0)
start_iter = State(default=0)
resume = State()
def __init__(self, **kwargs):
self.load_all(**kwargs)
cmd = kwargs['cmd']
if 'start_epoch' in cm... | 1,100 | 27.973684 | 65 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.