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
pyslam
pyslam-master/utils_files.py
# From torchvision.uitls import smtplib, socket, os, os.path, hashlib, errno import __main__ as main from email.mime.text import MIMEText from os import path, mkdir def check_integrity(fpath, md5): if not os.path.isfile(fpath): return False md5o = hashlib.md5() with open(fpath, "rb") as f: ...
3,694
31.412281
155
py
pyslam
pyslam-master/feature_hardnet.py
""" * This file is part of PYSLAM * adapted from https://github.com/DagnyT/hardnet/blob/master/examples/extract_hardnet_desc_from_hpatches_file.py, see licence therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify *...
8,043
38.821782
155
py
pyslam
pyslam-master/feature_manager.py
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
63,509
62.957704
272
py
pyslam
pyslam-master/feature_delf.py
""" * This file is part of PYSLAM * Adapted from https://github.com/tensorflow/models/blob/master/research/delf/delf/python/examples/extract_features.py, see the license therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or ...
12,100
40.871972
183
py
pyslam
pyslam-master/feature_keynet.py
""" * This file is part of PYSLAM * * Adpated from https://raw.githubusercontent.com/axelBarroso/Key.Net/master/extract_multiscale_features.py, see the license therein. * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it ...
19,688
42.463576
146
py
pyslam
pyslam-master/feature_l2net_keras.py
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
2,773
32.829268
123
py
pyslam
pyslam-master/feature_sosnet.py
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
3,919
36.692308
142
py
pyslam
pyslam-master/feature_l2net.py
""" * This file is part of PYSLAM * Adapted from https://github.com/vcg-uvic/image-matching-benchmark-baselines/blob/master/third_party/l2net_config/l2net_model.py, see licence therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it ...
7,936
39.28934
151
py
pyslam
pyslam-master/feature_logpolar.py
""" * This file is part of PYSLAM * adapted from https://github.com/cvlab-epfl/log-polar-descriptors/blob/aed70f882cddcfe0c27b65768b9248bf1f2c65cb/example.py, see licence therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/...
10,571
36.094737
147
py
pyslam
pyslam-master/feature_geodesc.py
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
5,637
36.337748
130
py
pyslam
pyslam-master/feature_r2d2.py
""" * This file is part of PYSLAM. * Adapted from https://raw.githubusercontent.com/naver/r2d2/master/extract.py, see the licence therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU ...
9,607
35.393939
146
py
pyslam
pyslam-master/feature_tfeat.py
""" * This file is part of PYSLAM * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or ...
3,989
34.625
114
py
pyslam
pyslam-master/feature_disk.py
""" * This file is part of PYSLAM * Adapted from https://github.com/cvlab-epfl/disk/blob/master/detect.py, see licence therein. * * Copyright (C) 2016-present Luigi Freda <luigi dot freda at gmail dot com> * * PYSLAM is free software: you can redistribute it and/or modify * it under the terms of the GNU General Publ...
12,929
37.254438
181
py
pyslam
pyslam-master/thirdparty/l2net_keras/src/LRN.py
from keras import backend as K from keras.layers.core import Layer # from https://github.com/ckoren1975/Machine-learning/blob/master/googlenet_custom_layers.py # except channels have been moved from the 2nd position to the 4th postion # and shape of input vector is now a tensor operation # and default args are set to ...
1,616
31.34
132
py
pyslam
pyslam-master/thirdparty/l2net_keras/src/L2_Net.py
import os import warnings # to disable tensorflow-numpy warnings: from https://github.com/tensorflow/tensorflow/issues/30427 warnings.filterwarnings('ignore', category=FutureWarning) import keras from keras import backend as K from keras.models import Sequential from keras.layers import Conv2D, BatchNormalization, ...
6,657
34.227513
159
py
pyslam
pyslam-master/thirdparty/l2net/l2net_model.py
import torch import torch.nn.init import torch.nn as nn eps = 1e-10 class L2Norm(nn.Module): def __init__(self): super(L2Norm,self).__init__() self.eps = 1e-10 def forward(self, x): norm = torch.sqrt(torch.sum(x * x, dim = 1) + self.eps) x= x / norm.unsqueeze(-1).expand_as(x)...
2,081
34.288136
92
py
pyslam
pyslam-master/thirdparty/l2net/convert_l2net_weights_matconv_pytorch.py
import numpy as np import scipy.io as sio import torch import torch.nn.init from misc.l2net.l2net_model import L2Net eps = 1e-10 def check_ported(l2net_model, test_patch, img_mean): test_patch = test_patch.transpose(3, 2, 0, 1)-img_mean desc = l2net_model(torch.from_numpy(test_patch)) print(desc) ret...
2,854
37.066667
146
py
pyslam
pyslam-master/thirdparty/contextdesc/models/cnn_wrapper/network.py
#!/usr/bin/env python3 """ Copyright 2017, Zixin Luo, HKUST. CNN layer wrapper. Please be noted about following issues: 1. The center and scale paramter are disabled by default for all BN-related layers, as they have shown little influence on final performance. In particular, scale params is officially considered unn...
17,219
38.586207
110
py
pyslam
pyslam-master/test/thirdparty/test_delf.py
# Copyright 2017 The TensorFlow Authors All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
12,641
41.280936
183
py
pyslam
pyslam-master/test/thirdparty/test_tfeat.py
import sys sys.path.append("../../") import config config.cfg.set_lib('tfeat') import torchvision as tv import phototour import torch from tqdm import tqdm import numpy as np import torch.nn as nn import math import tfeat_model import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn...
2,048
24.936709
79
py
pyslam
pyslam-master/test/thirdparty/test_hardnet_dense.py
#!/usr/bin/python3 -utt # -*- coding: utf-8 -*- import sys import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import torch.backends.cudnn as cudnn import time import os #sys.path.insert(0, '/home/ubuntu/dev/opencv-3.1/build/lib') import cv2 import math import numpy as...
4,912
35.93985
161
py
pyslam
pyslam-master/test/thirdparty/test_logpolar.py
# Copyright 2019 EPFL, Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in wri...
7,015
34.979487
99
py
pyslam
pyslam-master/test/thirdparty/test_l2net_keras.py
import sys sys.path.append("../../") import config config.cfg.set_lib('l2net_keras') import cv2 import numpy as np from L2_Net import L2Net # One of "L2Net-HP", "L2Net-HP+", "L2Net-LIB", "L2Net-LIB+", "L2Net-ND", "L2Net-ND+", "L2Net-YOS", "L2Net-YOS+", net_name = 'L2Net-HP' l2net = L2Net(net_name,do_tf_loggin...
537
22.391304
113
py
pyslam
pyslam-master/test/thirdparty/test_hardnet_patches.py
#!/usr/bin/python3 -utt # -*- coding: utf-8 -*- import sys import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import torch.backends.cudnn as cudnn import time import os import cv2 import math import numpy as np hardnet_base_path='../../thirdparty/hardnet/' class L2...
4,935
33.517483
155
py
pyslam
pyslam-master/test/thirdparty/test_disk.py
# adapted from https://github.com/cvlab-epfl/disk/blob/master/detect.py import torch, os, argparse, h5py, warnings, imageio import numpy as np from tqdm import tqdm import sys sys.path.append("../../") import config config.cfg.set_lib('disk') config.cfg.set_lib('torch-dimcheck') config.cfg.set_lib('torch-localize')...
9,680
33.575
110
py
pyslam
pyslam-master/test/thirdparty/test_d2net.py
# adapted from https://github.com/mihaidusmanu/d2-net/blob/master/extract_features.py import sys sys.path.append("../../") import config config.cfg.set_lib('d2net') import os import argparse import numpy as np import imageio import cv2 import torch from tqdm import tqdm import scipy import scipy.io import sc...
4,953
26.370166
92
py
pyslam
pyslam-master/test/thirdparty/test_keynet.py
# from https://raw.githubusercontent.com/axelBarroso/Key.Net/master/extract_multiscale_features.py import sys sys.path.append("../../") import config config.cfg.set_lib('keynet') import warnings # to disable tensorflow-numpy warnings: from https://github.com/tensorflow/tensorflow/issues/30427 warnings.filterwarning...
13,674
40.189759
125
py
pyslam
pyslam-master/test/thirdparty/test_r2d2.py
# Copyright 2019-present NAVER Corp. # CC BY-NC-SA 3.0 # Available only for non-commercial use # from https://raw.githubusercontent.com/naver/r2d2/master/extract.py import sys sys.path.append("../../") import config config.cfg.set_lib('r2d2') import os, pdb from PIL import Image import numpy as np import torch impo...
6,659
32.807107
96
py
pyslam
pyslam-master/test/thirdparty/test_geodesc.py
#!/usr/bin/env python """ Copyright 2018, Zixin Luo, HKUST. Conduct pair-wise image matching. """ # adapted from https://github.com/lzx551402/geodesc/blob/master/examples/image_matching.py import sys sys.path.append("../../") import config config.cfg.set_lib('geodesc') #from __future__ import print_function impor...
7,192
35.328283
130
py
pyslam
pyslam-master/test/thirdparty/test_contextdesc.py
#!/usr/bin/env python3 # adpated from https://github.com/lzx551402/contextdesc/blob/master/image_matching.py """ Copyright 2019, Zixin Luo, HKUST. Image matching example. """ import sys sys.path.append("../../") import config config.cfg.set_lib('contextdesc',prepend=True) contextdesc_base_path='../../thirdparty/con...
8,106
41.668421
183
py
pyslam
pyslam-master/test/thirdparty/test_sosnet.py
import sys sys.path.append("../../") import config config.cfg.set_lib('sosnet') import torch import sosnet_model import os tfeat_base_path='../../thirdparty/SOSNet/' device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") torch.set_grad_enabled(False) sosnet32 = sosnet_model.SOSNet32x32() net_name...
570
23.826087
122
py
GANF
GANF-main/train_traffic.py
#%% import os import argparse import torch from models.GANF import GANF import numpy as np parser = argparse.ArgumentParser() # files parser.add_argument('--data_dir', type=str, default='./data', help='Location of datasets.') parser.add_argument('--output_dir', type=str, defa...
7,602
34.036866
138
py
GANF
GANF-main/utils.py
#%% import torch def h(A): return torch.trace(torch.matrix_exp(A*A)) - A.shape[0] def normalize(A): D = A.sum(dim=0) D_inv = D.pow_(-1) D_inv.masked_fill_(D_inv == float('inf'), 0) return A * D_inv def thresholding(A, thre): return torch.where(A.abs()>thre, A, torch.scalar_tensor(0.0...
2,221
29.027027
103
py
GANF
GANF-main/dataset.py
#%% import pandas as pd import torch from torch.utils.data import Dataset import numpy as np # %% from torch.utils.data import DataLoader def load_traffic(root, batch_size): """ Load traffic dataset return train_loader, val_loader, test_loader """ df = pd.read_hdf(root) df = df.reset_index() ...
5,624
31.894737
104
py
GANF
GANF-main/train_water.py
#%% import os import argparse import torch from models.GANF import GANF import numpy as np from sklearn.metrics import roc_auc_score # from data import fetch_dataloaders parser = argparse.ArgumentParser() # files parser.add_argument('--data_dir', type=str, default='./data/SWaT_Dataset_Attack_v0.c...
8,511
34.319502
138
py
GANF
GANF-main/eval_water.py
#%% import os import argparse import torch from models.GANF import GANF import numpy as np from sklearn.metrics import roc_auc_score # from data import fetch_dataloaders parser = argparse.ArgumentParser() # files parser.add_argument('--data_dir', type=str, default='./data/SWaT_Dataset_Attack_v0.c...
2,593
35.535211
138
py
GANF
GANF-main/models/RNN.py
#%% import torch import torch.nn as nn from functools import partial class RecurrentEncoder(nn.Module): """Recurrent encoder""" def __init__(self, n_features, latent_dim, rnn): super().__init__() self.rec_enc1 = rnn(n_features, latent_dim, batch_first=True) def forward(self, x): ...
2,929
26.904762
97
py
GANF
GANF-main/models/graph_layer.py
import torch from torch.nn import Parameter, Linear, Sequential, BatchNorm1d, ReLU import torch.nn.functional as F from torch_geometric.nn.conv import MessagePassing from torch_geometric.utils import remove_self_loops, add_self_loops, softmax from torch_geometric.nn.inits import glorot, zeros class GraphLayer(Message...
4,099
32.333333
84
py
GANF
GANF-main/models/NF.py
#%% import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as D import math import copy # -------------------- # Model layers and helpers # -------------------- def create_masks(input_size, hidden_size, n_hidden, input_order='sequential', input_degrees=None): # MADE paper ...
17,494
39.780886
169
py
GANF
GANF-main/models/DROCC.py
import os import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class LSTM_FC(nn.Module): def __init__(self, input_dim=32, num_classes=1, num_hidden_nodes=8 ): super(LSTM_FC, self).__init__() self.input_dim = i...
8,730
39.235023
106
py
GANF
GANF-main/models/DeepSAD.py
#%% import json import torch import logging import time import torch import torch.optim as optim class AETrainer: def __init__(self, device: str = 'cuda'): self.device = device def train(self, train_loader, ae_net, args): logger = logging.getLogger() # Set device for network ...
14,064
31.55787
129
py
GANF
GANF-main/models/GAN.py
#%% import os import torch import torch.nn as nn import torch.nn.functional as F from timeit import default_timer as timer def ConvEncoder(activation = nn.LeakyReLU, in_channels:int = 3, n_c:int = 64, k_size:int = 5): enc = nn.Sequential(*(nn.Conv1d(in_channels, n_c, k_size, stride=2, paddi...
10,849
34.113269
138
py
GANF
GANF-main/models/GANF.py
#%% import torch.nn as nn import torch.nn.functional as F from models.NF import MAF, RealNVP import torch class GNN(nn.Module): """ The GNN module applied in GANF """ def __init__(self, input_size, hidden_size): super(GNN, self).__init__() self.lin_n = nn.Linear(input_size, hidden_siz...
2,705
28.413043
140
py
GANF
GANF-main/example_baseline/train_SVDD_water.py
#%% import os import argparse import torch from models.RNN import RecurrentAE import torch.nn.functional as F from dataset import PMUTime import numpy as np parser = argparse.ArgumentParser() # action parser.add_argument('--data_dir', type=str, default='/data', help='Location of datasets.') pars...
2,916
33.317647
126
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/generate_images.py
# code is partly based on https://huggingface.co/blog/stable_diffusion import argparse import math import os import pathlib from datetime import datetime import torch from diffusers import AutoencoderKL, LMSDiscreteScheduler, UNet2DConditionModel from PIL import Image from rtpt import RTPT from torch import autocast ...
11,103
35.646865
112
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/perform_TPA.py
import argparse import os import random from datetime import datetime from unicodedata import * import torch from PIL import Image from torch.utils.data import DataLoader import wandb from metrics import metrics from utils.config_parser import ConfigParser from utils.stable_diffusion_utils import generate def main(...
14,103
36.913978
173
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/perform_clip_retrieval.py
import argparse import io import os import pathlib import urllib from datetime import datetime from clip_retrieval.clip_client import ClipClient from PIL import Image from rtpt import RTPT from transformers import CLIPModel, CLIPTextModel, CLIPTokenizer import wandb def main(): args = create_parser() if ar...
6,088
31.047368
90
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/perform_TAA.py
import argparse import os from datetime import datetime import torch from PIL import Image from torch.utils.data import DataLoader from tqdm.auto import tqdm import wandb from metrics import metrics from utils.attack_utils import inject_attribute_backdoor from utils.config_parser import ConfigParser from utils.stable...
12,345
36.299094
128
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/perform_concept_removal.py
import argparse import os import random from datetime import datetime import torch from PIL import Image from torch.utils.data import DataLoader from tqdm.auto import tqdm import wandb from metrics import metrics from utils.config_parser import ConfigParser from utils.stable_diffusion_utils import generate def main...
13,458
35.773224
128
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/metrics/metrics.py
import torch from utils.attack_utils import inject_attribute_backdoor from utils.encoder_utils import compute_text_embeddings from torch.nn.functional import cosine_similarity from torchmetrics.functional import pairwise_cosine_similarity def z_score_text(text_encoder: torch.nn.Module, tokenizer: tor...
7,426
38.930108
127
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/utils/config_parser.py
from pathlib import Path import torch.optim as optim import yaml from rtpt.rtpt import RTPT from transformers import CLIPTextModel, CLIPTokenizer import datasets from losses import losses from datasets import load_dataset class ConfigParser: def __init__(self, config_file): with open(config_file, 'r') ...
4,674
27.858025
127
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/utils/encoder_utils.py
import math from typing import List import torch def compute_text_embeddings(tokenizer: torch.nn.Module, encoder: torch.nn.Module, prompts: List[str], batch_size: int = 256) -> torch.Tensor: with torch.no_grad(): encoder....
958
34.518519
69
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/utils/stable_diffusion_utils.py
from typing import List import torch from diffusers import AutoencoderKL, LMSDiscreteScheduler, UNet2DConditionModel from PIL import Image from torch import autocast from tqdm.auto import tqdm from transformers import CLIPTextModel, CLIPTokenizer # code is partly based on https://huggingface.co/blog/stable_diffusion ...
4,710
35.51938
108
py
Rickrolling-the-Artist
Rickrolling-the-Artist-main/losses/losses.py
import torch from torch.nn.functional import cosine_similarity class MSELoss(torch.nn.Module): def __init__(self, flatten: bool = False, reduction: str = 'mean'): super().__init__() self.loss_fkt = torch.nn.MSELoss(reduction=reduction) self.flatten = flatten def forward(self, input: ...
2,888
31.1
72
py
DPT-VO
DPT-VO-main/main.py
import numpy as np import cv2 import argparse from tqdm import tqdm from dataloader.kitti import KITTI from camera_model import CameraModel from depth_model import DepthModel from visual_odometry import VisualOdometry from traj_utils import plot_trajectory, save_trajectory import torch if __name__ == "__main__": ...
4,644
33.407407
130
py
DPT-VO
DPT-VO-main/depth_model.py
""" Build DPT depth model - modified from https://github.com/isl-org/DPT """ import os import torch import cv2 import argparse import util.io from torchvision.transforms import Compose from dpt.models import DPTDepthModel from dpt.transforms import Resize, NormalizeImage, PrepareForNet class DepthModel(object): ...
6,129
28.052133
143
py
DPT-VO
DPT-VO-main/util/io.py
"""Utils for monoDepth. """ import sys import re import numpy as np import cv2 import torch import matplotlib as mpl from PIL import Image from .pallete import get_mask_pallete def read_pfm(path): """Read pfm file. Args: path (str): path to file Returns: tuple: (data, scale) """ ...
5,880
24.458874
122
py
DPT-VO
DPT-VO-main/dpt/base_model.py
import torch class BaseModel(torch.nn.Module): def load(self, path): """Load model from file. Args: path (str): file path """ parameters = torch.load(path, map_location=torch.device("cpu")) if "optimizer" in parameters: parameters = parameters["mod...
367
20.647059
71
py
DPT-VO
DPT-VO-main/dpt/midas_net.py
"""MidashNet: Network for monocular depth estimation trained by mixing several datasets. This file contains code that is adapted from https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py """ import torch import torch.nn as nn from .base_model import BaseModel f...
2,738
34.115385
110
py
DPT-VO
DPT-VO-main/dpt/vit.py
import torch import torch.nn as nn import timm import types import math import torch.nn.functional as F activations = {} def get_activation(name): def hook(model, input, output): activations[name] = output return hook attention = {} def get_attention(name): def hook(module, input, output): ...
17,106
28.64818
96
py
DPT-VO
DPT-VO-main/dpt/models.py
import torch import torch.nn as nn import torch.nn.functional as F from .base_model import BaseModel from .blocks import ( FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder, forward_vit, ) def _make_fusion_block(features, use_bn): return FeatureFusionBlock_custom( ...
4,563
28.636364
90
py
DPT-VO
DPT-VO-main/dpt/blocks.py
import torch import torch.nn as nn from .vit import ( _make_pretrained_vitb_rn50_384, _make_pretrained_vitl16_384, _make_pretrained_vitb16_384, forward_vit, ) def _make_encoder( backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, us...
9,090
22.674479
85
py
GraSP
GraSP-master/main_prune_imagenet.py
import argparse import os import torch import torch.nn as nn from models.model_base import ModelBase from tensorboardX import SummaryWriter from models.base.init_utils import weights_init from utils.common_utils import (get_logger, makedirs, process_config, str_to_list) from pruner.GraSP_ImageNet import GraSP import t...
6,550
36.867052
106
py
GraSP
GraSP-master/main_prune_non_imagenet.py
import argparse import json import math import os import sys import torch import torch.nn as nn import torch.optim as optim from models.model_base import ModelBase from tensorboardX import SummaryWriter from tqdm import tqdm from models.base.init_utils import weights_init from utils.common_utils import (get_logger, ma...
13,065
39.83125
119
py
GraSP
GraSP-master/main_finetune_imagenet.py
import argparse import os import random import shutil import time import warnings import sys import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing as mp import torch.utils.data import torch.utils...
19,921
38.293886
112
py
GraSP
GraSP-master/pruner/GraSP_ImageNet.py
import torch import torch.autograd as autograd import torch.nn as nn import torch.nn.functional as F import copy import types def count_total_parameters(net): total = 0 for m in net.modules(): if isinstance(m, (nn.Linear, nn.Conv2d)): total += m.weight.numel() return total def count...
4,231
30.348148
113
py
GraSP
GraSP-master/pruner/GraSP.py
import torch import torch.autograd as autograd import torch.nn as nn import torch.nn.functional as F import math import copy import types def GraSP_fetch_data(dataloader, num_classes, samples_per_class): datas = [[] for _ in range(num_classes)] labels = [[] for _ in range(num_classes)] mark = dict() ...
5,239
31.75
119
py
GraSP
GraSP-master/models/model_base.py
import torch.nn as nn from collections import OrderedDict from utils.network_utils import get_network from utils.prune_utils import filter_weights class ModelBase(object): def __init__(self, network, depth, dataset, model=None): self._network = network self._depth = depth self._dataset = ...
3,183
31.161616
73
py
GraSP
GraSP-master/models/base/resnet.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.init as init from utils.common_utils import try_cuda from .init_utils import weights_init __all__ = ['resnet'] # , 'resnet20', 'resnet32', 'resnet44', 'resnet56', 'resnet110', 'resnet1202'] _AFFINE = True #_AFFINE = False ...
3,943
33
114
py
GraSP
GraSP-master/models/base/vgg.py
import math import torch import torch.nn as nn from .init_utils import weights_init defaultcfg = { 11: [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 13: [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512], 16: [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512...
2,823
35.675325
110
py
GraSP
GraSP-master/models/base/init_utils.py
import torch import torch.nn as nn import torch.nn.init as init def weights_init(m): # print('=> weights init') if isinstance(m, nn.Conv2d): nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu') # nn.init.normal_(m.weight, 0, 0.1) if m.bias is not None: m.b...
767
32.391304
78
py
GraSP
GraSP-master/utils/prune_utils.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from .common_utils import try_contiguous def _fetch_weights_collections(scores, _prev_masks): weights = [] eps = 1e-10 if _prev_masks is None: for m in scores.keys(): if isinstance(m, (nn.Linear, nn....
8,463
33.267206
105
py
GraSP
GraSP-master/utils/data_utils.py
import torch import torchvision import torchvision.transforms as transforms def get_transforms(dataset): transform_train = None transform_test = None if dataset == 'mnist': # transforms.Normalize((0.1307,), (0.3081,)) t = transforms.Normalize((0.5,), (0.5,)) transform_train = trans...
4,728
44.038095
113
py
GraSP
GraSP-master/utils/common_utils.py
import os import time import json import logging import torch from pprint import pprint from easydict import EasyDict as edict def get_logger(name, logpath, filepath, package_files=[], displaying=True, saving=True): logger = logging.getLogger(name) logger.setLevel(logging.INFO) log_path =...
4,926
27.982353
76
py
State-Frequency-Memory-stock-prediction
State-Frequency-Memory-stock-prediction-master/test/itosfm.py
# -*- coding: utf-8 -*- from __future__ import absolute_import import numpy as np import theano.tensor as T from keras import backend as K from keras import activations, initializations, regularizers from keras.engine import Layer, InputSpec from keras.layers.recurrent import Recurrent class ITOSFM(Recurrent): d...
8,589
42.604061
104
py
State-Frequency-Memory-stock-prediction
State-Frequency-Memory-stock-prediction-master/test/build.py
import time import warnings import numpy as np import keras from numpy import newaxis from keras.layers.core import Dense, Activation, Dropout from itosfm import ITOSFM from keras.models import Sequential warnings.filterwarnings("ignore") #Load data from data file, and split the data into training, validation and tes...
2,067
31.825397
88
py
State-Frequency-Memory-stock-prediction
State-Frequency-Memory-stock-prediction-master/train/itosfm.py
# -*- coding: utf-8 -*- from __future__ import absolute_import import numpy as np import theano.tensor as T from keras import backend as K from keras import activations, initializations, regularizers from keras.engine import Layer, InputSpec from keras.layers.recurrent import Recurrent class ITOSFM(Recurrent): d...
8,589
42.604061
104
py
State-Frequency-Memory-stock-prediction
State-Frequency-Memory-stock-prediction-master/train/build.py
import time import warnings import numpy as np import keras from numpy import newaxis from keras.layers.core import Dense, Activation, Dropout from itosfm import ITOSFM from keras.models import Sequential warnings.filterwarnings("ignore") #Load data from data file, and split the data into training, validation and tes...
2,067
31.825397
88
py
delora
delora-main/setup.py
import os from setuptools import setup, find_packages from setuptools.command.install import install class CustomInstallCommand(install): # This is only run for "python setup.py install" (not for "pip install -e .") def run(self): print("--------------------------------") print("Writing enviro...
1,125
32.117647
107
py
delora
delora-main/src/utility/linalg.py
#!/usr/bin/env python3 # Modified from: Modar M. Alfadly, https://discuss.pytorch.org/t/covariance-and-gradient-support/16217 import torch def cov(point_neighbors, rowvar=True): ''' Estimate a covariance matrix given data. Covariance indicates the level to which two variables vary together. If we exa...
2,647
45.45614
102
py
delora
delora-main/src/utility/projection.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import numpy as np import torch import numba class ImageProjectionLa...
5,689
50.727273
119
py
delora
delora-main/src/utility/geometry.py
#!/usr/bin/env python3 # Parts of the code taken from pytorch3d (https://pytorch3d.readthedocs.io/) import torch def _angle_from_tan( axis: str, other_axis: str, data, horizontal: bool, tait_bryan: bool ): """ Extract the first or third Euler angle from the two members of the matrix which are posi...
3,009
33.204545
78
py
delora
delora-main/src/models/model_parts.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import torch import platform if not "2.7" in platform.python_version(...
3,940
41.836957
96
py
delora
delora-main/src/models/resnet_modified.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. # This model is build on top of the torchvision resnet model. import t...
7,993
43.910112
120
py
delora
delora-main/src/models/model.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. from __future__ import division import torch import models.model_par...
6,108
51.213675
97
py
delora
delora-main/src/deploy/tester.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import mlflow import numpy as np import pickle import torch import de...
8,233
49.515337
118
py
delora
delora-main/src/deploy/deployer.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import copy import math import torch import mlflow import numpy as np...
20,390
53.231383
119
py
delora
delora-main/src/deploy/trainer.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import time import mlflow import mlflow.pytorch import pickle import ...
9,336
48.930481
130
py
delora
delora-main/src/ros_utils/rosbag_pcl_extractor.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import numpy as np import rosbag import yaml import sensor_msgs.msg im...
2,500
38.698413
118
py
delora
delora-main/src/ros_utils/odometry_publisher.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. from __future__ import division import time import cv2 import geometr...
7,939
39.10101
119
py
delora
delora-main/src/ros_utils/odometry_integrator.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. from __future__ import division import time import cv2 import geometr...
4,075
37.45283
84
py
delora
delora-main/src/ros_utils/publish_point_cloud_and_normals.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import copy import numpy as np import geometry_msgs.msg import rospy ...
5,759
39.851064
99
py
delora
delora-main/src/ros_utils/convert_to_rosbag.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import os import rospy import rosbag import torch import sensor_msgs....
4,014
43.120879
118
py
delora
delora-main/src/data/kitti_scans.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import os import glob import numpy as np import pykitti import torch ...
2,322
39.754386
118
py
delora
delora-main/src/data/dataset.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import csv import glob import os import torch import numpy as np # ...
13,227
51.701195
120
py
delora
delora-main/src/data/rosbag_scans.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import os import glob import numpy as np import torch import ros_uti...
1,574
37.414634
111
py
delora
delora-main/src/losses/icp_losses.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import scipy.spatial import torch class ICPLosses(torch.nn.Module): ...
13,291
54.153527
109
py
delora
delora-main/src/preprocessing/normal_computation.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import numpy as np import torch import utility.linalg # Need an ins...
6,487
51.747967
101
py
delora
delora-main/bin/run_training.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import click import numpy as np import torch import yaml import deplo...
3,837
39.4
110
py
delora
delora-main/bin/run_rosnode.py
#!/usr/bin/env python3 # Copyright 2021 by Julian Nubert, Robotic Systems Lab, ETH Zurich. # All rights reserved. # This file is released under the "BSD-3-Clause License". # Please see the LICENSE file that has been included as part of this package. import click import numpy as np import torch import yaml import ros_u...
2,881
35.948718
117
py