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
arc
arc-master/third_party/nonconformist/cp.py
from nonconformist.icp import * # TODO: move contents from nonconformist.icp here # ----------------------------------------------------------------------------- # TcpClassifier # ----------------------------------------------------------------------------- class TcpClassifier(BaseEstimator, ClassifierMixin): """Tra...
5,299
29.813953
79
py
arc
arc-master/third_party/nonconformist/util.py
from __future__ import division import numpy as np def calc_p(ncal, ngt, neq, smoothing=False): if smoothing: return (ngt + (neq + 1) * np.random.uniform(0, 1)) / (ncal + 1) else: return (ngt + neq + 1) / (ncal + 1)
223
23.888889
65
py
arc
arc-master/third_party/nonconformist/__init__.py
#!/usr/bin/env python """ docstring """ # Authors: Henrik Linusson # Yaniv Romano modified np.py file to include CQR __version__ = '2.1.0' __all__ = ['icp', 'nc', 'acp']
174
12.461538
49
py
arc
arc-master/third_party/nonconformist/evaluation.py
#!/usr/bin/env python """ Evaluation of conformal predictors. """ # Authors: Henrik Linusson # TODO: cross_val_score/run_experiment should possibly allow multiple to be evaluated on identical folding from __future__ import division from nonconformist.base import RegressorMixin, ClassifierMixin import sys import n...
14,339
30.378556
106
py
arc
arc-master/third_party/nonconformist/acp.py
#!/usr/bin/env python """ Aggregated conformal predictors """ # Authors: Henrik Linusson import numpy as np from sklearn.cross_validation import KFold, StratifiedKFold from sklearn.cross_validation import ShuffleSplit, StratifiedShuffleSplit from sklearn.base import clone from nonconformist.base import BaseEstimator...
10,138
26.402703
79
py
arc
arc-master/third_party/cqr/torch_models.py
import sys import copy import torch import numpy as np import torch.nn as nn from cqr import helper from sklearn.model_selection import train_test_split if torch.cuda.is_available(): device = "cuda:0" else: device = "cpu" ############################################################################### # Help...
17,313
33.217391
215
py
arc
arc-master/third_party/cqr/tune_params_cv.py
from cqr import helper from skgarden import RandomForestQuantileRegressor from sklearn.model_selection import train_test_split def CV_quntiles_rf(params, X, y, target_coverage, grid_q, test_ratio, random...
3,123
42.388889
109
py
arc
arc-master/third_party/cqr/helper.py
import sys import torch import numpy as np from cqr import torch_models from functools import partial from cqr import tune_params_cv from nonconformist.cp import IcpRegressor from nonconformist.base import RegressorAdapter from skgarden import RandomForestQuantileRegressor if torch.cuda.is_available(): device = "...
22,414
36.927242
133
py
arc
arc-master/third_party/cqr/__init__.py
#!/usr/bin/env python
22
10.5
21
py
arc
arc-master/third_party/cqr/nonconformist/nc.py
#!/usr/bin/env python """ Nonconformity functions. """ # Authors: Henrik Linusson # Yaniv Romano modified RegressorNc class to include CQR from __future__ import division import abc import numpy as np import sklearn.base from nonconformist.base import ClassifierAdapter, RegressorAdapter from nonconformist.base impo...
17,678
27.79316
79
py
arc
arc-master/third_party/cqr/nonconformist/base.py
#!/usr/bin/env python """ docstring """ # Authors: Henrik Linusson import abc import numpy as np from sklearn.base import BaseEstimator class RegressorMixin(object): def __init__(self): super(RegressorMixin, self).__init__() @classmethod def get_problem_type(cls): return 'regression' class ClassifierMix...
3,379
20.528662
63
py
arc
arc-master/third_party/cqr/nonconformist/icp.py
#!/usr/bin/env python """ Inductive conformal predictors. """ # Authors: Henrik Linusson from __future__ import division from collections import defaultdict from functools import partial import numpy as np from sklearn.base import BaseEstimator from nonconformist.base import RegressorMixin, ClassifierMixin from no...
13,978
30.698413
79
py
arc
arc-master/third_party/cqr/nonconformist/cp.py
from nonconformist.icp import * # TODO: move contents from nonconformist.icp here # ----------------------------------------------------------------------------- # TcpClassifier # ----------------------------------------------------------------------------- class TcpClassifier(BaseEstimator, ClassifierMixin): """Tra...
5,299
29.813953
79
py
arc
arc-master/third_party/cqr/nonconformist/util.py
from __future__ import division import numpy as np def calc_p(ncal, ngt, neq, smoothing=False): if smoothing: return (ngt + (neq + 1) * np.random.uniform(0, 1)) / (ncal + 1) else: return (ngt + neq + 1) / (ncal + 1)
223
23.888889
65
py
arc
arc-master/third_party/cqr/nonconformist/__init__.py
#!/usr/bin/env python """ docstring """ # Authors: Henrik Linusson # Yaniv Romano modified np.py file to include CQR __version__ = '2.1.0' __all__ = ['icp', 'nc', 'acp']
174
12.461538
49
py
arc
arc-master/third_party/cqr/nonconformist/evaluation.py
#!/usr/bin/env python """ Evaluation of conformal predictors. """ # Authors: Henrik Linusson # TODO: cross_val_score/run_experiment should possibly allow multiple to be evaluated on identical folding from __future__ import division from nonconformist.base import RegressorMixin, ClassifierMixin import sys import n...
14,339
30.378556
106
py
arc
arc-master/third_party/cqr/nonconformist/acp.py
#!/usr/bin/env python """ Aggregated conformal predictors """ # Authors: Henrik Linusson import numpy as np from sklearn.cross_validation import KFold, StratifiedKFold from sklearn.cross_validation import ShuffleSplit, StratifiedShuffleSplit from sklearn.base import clone from nonconformist.base import BaseEstimator...
10,138
26.402703
79
py
arc
arc-master/third_party/cqr_comparison/cqr.py
import sys import numpy as np import pdb # CQR error function class QR_errfun(): """Calculates conformalized quantile regression error. Conformity scores: .. math:: max{\hat{q}_low - y, y - \hat{q}_high} """ def __init__(self): super(QR_errfun, self).__init__() def apply(sel...
5,191
32.496774
109
py
arc
arc-master/third_party/cqr_comparison/qr_net.py
import numpy as np import torch from functools import partial import pdb import os, sys sys.path.insert(0, os.path.abspath("../third_party/")) from cqr import torch_models from nonconformist.base import RegressorAdapter if torch.cuda.is_available(): device = "cuda:0" else: device = "cpu" class NeuralNetworkQ...
3,909
36.961165
105
py
arc
arc-master/third_party/cqr_comparison/__init__.py
#!/usr/bin/env python from cqr_comparison.cqr import ConformalizedQR #from cqr_comparison.qr_forest import RandomForestQR # Note: skgarden has recent compatibility issues #from cqr_comparison.qr_net import NeuralNetworkQR # Note: skgarden has recent compatibility issues
271
53.4
101
py
arc
arc-master/third_party/cqr_comparison/qr_forest.py
import os, sys import pdb import numpy as np from skgarden import RandomForestQuantileRegressor as RF from sklearn.model_selection import train_test_split class RandomForestQR: def __init__(self, params, quantiles, verbose=False): self.regressor = RF(n_estimators = params['n_estimators'], ...
3,151
37.439024
114
py
arc
arc-master/experiments_sim_data/run_experiments.py
import numpy as np from sklearn.model_selection import train_test_split import pandas as pd from tqdm import tqdm import os.path from os import path import sys sys.path.insert(0, '..') import arc # Where to write results out_dir = "~/Workspace/classification/experiments" def assess_predictions(S, X, y): # Margin...
7,029
36.393617
111
py
arc
arc-master/experiments_real_data/all_real_data_experiments.py
from run_experiment_real_data import run_experiment alpha = 0.1 DATASET_LIST = ["mice", "fashion", "mnist", "cifar10"] N_TRAIN_LIST = [500, 1000, 5000, 10000] # Data sets directory dataset_base_path = '~/mydata/classification_data/' # Where to write results out_dir = "./results" for EXP_id in range(100): ...
753
25
56
py
arc
arc-master/experiments_real_data/run_experiment_real_data.py
import numpy as np from sklearn.model_selection import train_test_split import pandas as pd import os.path from os import path from datasets import GetDataset import random import torch import sys sys.path.insert(0, '..') import arc def assess_predictions(S, X, y): # Marginal coverage coverage = np.mean([y[i]...
6,950
37.192308
109
py
arc
arc-master/experiments_real_data/datasets.py
import numpy as np import pandas as pd import torch from torchvision import transforms import torchvision.datasets as datasets from sklearn.decomposition import PCA from sklearn.preprocessing import StandardScaler def GetDataset(name, base_path): """ Load a dataset Parameters ---------- name...
4,903
31.263158
116
py
arc
arc-master/arc/black_boxes.py
import numpy as np from sklearn import svm from sklearn import ensemble from sklearn import calibration from sklearn.neural_network import MLPClassifier import copy class Oracle: def __init__(self, model): self.model = model def fit(self,X,y): return self def predict(self, X): ...
5,552
32.251497
87
py
arc
arc-master/arc/classification.py
import numpy as np class ProbabilityAccumulator: def __init__(self, prob): self.n, self.K = prob.shape self.order = np.argsort(-prob, axis=1) self.ranks = np.empty_like(self.order) for i in range(self.n): self.ranks[i, self.order[i]] = np.arange(len(self.order[i])) ...
1,908
40.5
94
py
arc
arc-master/arc/others.py
import numpy as np from sklearn.model_selection import train_test_split from scipy.stats.mstats import mquantiles # Note: skgarden has recent compatibility issues #from skgarden import RandomForestQuantileRegressor # Note: skgarden has recent compatibility issues #import sys #sys.path.insert(0, '../third_party') #fr...
9,005
40.311927
132
py
arc
arc-master/arc/coverage.py
import numpy as np from sklearn.model_selection import train_test_split from tqdm import tqdm def wsc(X, y, S, delta=0.1, M=1000, random_state=2020, verbose=False): rng = np.random.default_rng(random_state) def wsc_v(X, y, S, delta, v): n = len(y) cover = np.array([y[i] in S[i] for i in range(...
2,607
35.732394
131
py
arc
arc-master/arc/methods.py
import numpy as np from sklearn.model_selection import train_test_split from sklearn.model_selection import KFold from scipy.stats.mstats import mquantiles import sys from tqdm import tqdm from arc.classification import ProbabilityAccumulator as ProbAccum class CVPlus: def __init__(self, X, Y, black_box, alpha, n...
9,536
43.35814
111
py
arc
arc-master/arc/models.py
import numpy as np from scipy.stats import norm def sigmoid(x): return(1/(1 + np.exp(-x))) class Model_Ex1: def __init__(self, K, p, magnitude=1): self.K = K self.p = p self.magnitude = magnitude # Generate model parameters self.beta_Z = self.magnitude*np.random.randn(s...
3,189
37.902439
100
py
arc
arc-master/arc/__init__.py
#!/usr/bin/env python from arc import models from arc import methods from arc import black_boxes from arc import others from arc import coverage
145
19.857143
27
py
QC3_release
QC3_release-main/solution_2pt.py
################################################################################ # Import relevant python modules ################################################################################ # Standard python modules import numpy as np, sys, os np.set_printoptions(precision=6) pi = np.pi; sqrt=np.sqrt; LA=np.linalg...
5,199
48.056604
105
py
QC3_release
QC3_release-main/solution.py
######################################A########################################## # Import relevant python modules ################################################################################ # Standard python modules import numpy as np, sys, os np.set_printoptions(precision=6) pi = np.pi; sqrt=np.sqrt; LA=np.linal...
5,304
53.690722
106
py
QC3_release
QC3_release-main/test.py
################################################################################ # Import relevant python modules ################################################################################ # Standard python modules import numpy as np, sys, os np.set_printoptions(precision=3) pi = np.pi; sqrt=np.sqrt; LA=np.linalg...
4,729
52.75
92
py
QC3_release
QC3_release-main/solution_ND.py
######################################A########################################## # Import relevant python modules ################################################################################ # Standard python modules import numpy as np, sys, os np.set_printoptions(precision=6) pi = np.pi; sqrt=np.sqrt; LA=np.linal...
5,230
55.247312
102
py
QC3_release
QC3_release-main/solution_ID.py
######################################A########################################## # Import relevant python modules ################################################################################ # Standard python modules import numpy as np, sys, os np.set_printoptions(precision=6) pi = np.pi; sqrt=np.sqrt; LA=np.linal...
4,280
50.578313
102
py
QC3_release
QC3_release-main/base_code/defns.py
import numpy as np pi=np.pi; LA=np.linalg from itertools import permutations as perms from constants import * # from numba import jit,njit #################################################################################### # This file defines several basic functions that get called multiple times ###################...
13,598
28.182403
139
py
QC3_release
QC3_release-main/base_code/constants.py
################################################################################ # Spectator cutoff constants ################################################################################ # Set xmin, xmax for J cutoff fn. def get_xrange(): xmin = 0.02 xmax = 0.97 return xmin, xmax # Set epsH for H cutoff fn....
781
26.928571
80
py
QC3_release
QC3_release-main/base_code/group_theory_defns.py
import numpy as np, sys pi=np.pi; conj=np.conjugate; LA=np.linalg from itertools import permutations as perms import defns; sqrt=defns.sqrt #from projections import l0_proj, l2_proj from scipy.linalg import block_diag #################################################################################### # Group theory...
23,358
28.419395
198
py
QC3_release
QC3_release-main/base_code/projections.py
import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg from scipy.linalg import block_diag import defns, group_theory_defns as GT import sys ################################################################################ ''' Here we implement projections onto all little group irreps ''' ############################...
9,770
39.882845
117
py
QC3_release
QC3_release-main/base_code/F3/F3_mat.py
import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg #from numba import jit,njit import defns, F_mat, G_mat, K2i_mat ############################################################## # Compute full matrix F3 for 2+1 systems ############################################################## def F3mat_2plus1(E,L,nnP, f_qcot_...
2,254
45.979167
119
py
QC3_release
QC3_release-main/base_code/F3/qcot_fits.py
import numpy as np, sys sqrt = np.sqrt; pi=np.pi # s-wave phase shift model (for K2) #@njit(fastmath=True) def qcot_fit_s(q2,par_vec,ERE=True): # Use effective range expansion by default if ERE==True: a0 = par_vec[0] qcot = -1/a0 if len(par_vec)==2: r = par_vec[1] qcot += 1/2*r*q...
762
25.310345
93
py
QC3_release
QC3_release-main/base_code/F3/K2i_mat.py
import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg from scipy.linalg import block_diag import defns # from numba import jit,njit ################################################################################ # Calculate matrix element of K2i_inv/(2*omega), no L^3 ################################################...
5,743
44.587302
130
py
QC3_release
QC3_release-main/base_code/F3/G_mat.py
import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg # import sums_mov as sums import defns # from numba import jit,njit ################################################################################ # Compute individual matrix element of Gtilde^{ij} = G^{ij}/(2*omega*L^3) ########################################...
6,725
34.776596
132
py
QC3_release
QC3_release-main/base_code/F3/F_mat.py
import numpy as np, sys pi=np.pi; LA=np.linalg; exp=np.exp from scipy.linalg import block_diag from scipy.special import erfi,erfc from scipy.optimize import fsolve import defns from constants import * sqrt = defns.sqrt ################################################################################ # Find maximum n ...
8,364
36.511211
119
py
QC3_release
QC3_release-main/base_code/Kdf3/K3E.py
import numpy as np #sqrt=np.sqrt pi=np.pi; conj=np.conjugate; LA=np.linalg; import defns sqrt=defns.sqrt ################################################################# # Want to compute K3E term in Kdf3 for 2+1 systems ################################################################# # Compute 4x4 block of K3E for g...
3,800
35.902913
209
py
QC3_release
QC3_release-main/base_code/Kdf3/K3B.py
import defns import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg ################################################################# # Want to compute K3B term in Kdf3 for 2+1 systems ################################################################# # Compute contributions to K3B for given (i,pvec; j,kvec) def K3B_...
2,306
35.619048
117
py
QC3_release
QC3_release-main/base_code/Kdf3/K3main.py
import numpy as np sqrt=np.sqrt; pi=np.pi; LA=np.linalg; import K3B, K3E import defns ################################################################# # Full linear-order threshold expansion of Kdf3 for 2+1 systems ################################################################# # Note: input order for all functio...
4,279
36.54386
117
py
signed-oracle
signed-oracle-main/implementation/main.py
import Eval Eval.runAllSyntheticExperiments() Eval.runAllRealWorldExperiments()
82
12.833333
33
py
signed-oracle
signed-oracle-main/implementation/GraphStats.py
import numpy import Graph def printGraphStats(G): print(f'n:\t\t {G.numVertices}') print(f'|E|:\t\t {G.numEdges}') print(f'|E+|:\t\t {G.numPositiveEdges}') print(f'|E-|:\t\t {G.numNegativeEdges}') print(f'|E-|/|E|:\t {G.numNegativeEdges / G.numEdges}') print(' ') degrees = [] for u in G.edges.keys(): degre...
537
23.454545
56
py
signed-oracle
signed-oracle-main/implementation/Graph.py
import random import numpy import networkx as nx import time class Graph: ''' The graph is stored as a dict over unordered lists. Because of how the graph is stored, the vertex ids start at 1 (and not at 0). For positive edges, the list contains the index of the vertex, and for negative edges, the list cont...
4,086
22.624277
84
py
signed-oracle
signed-oracle-main/implementation/Eval.py
import numpy import random import os import sys import time import networkx as nx from networkx.algorithms import bipartite import GraphReader import GraphStats import SyntheticData import OracleModule sys.path.insert(1, 'include/signed-local-community-master') from core import query_graph_using_sparse_linear_solv...
17,372
29.532513
210
py
signed-oracle
signed-oracle-main/implementation/OracleModule.py
import os def getInitCommand(inputfile, numSteps, numWalks, seedClusters=None, k=None, s=None, numEstNorm=1, unsigned=False, biclustering=False): command = './oracle ' command += f'{inputfile} ' command += f'{str(numSteps)} ' command += f'{str(numWalks)}...
2,934
23.057377
134
py
signed-oracle
signed-oracle-main/implementation/SyntheticData.py
import numpy import Graph ''' Generates a signed SBM with n vertices and 2*k equally sized bi-clusters. Intra-cluster (+,+)-edges are inserted with probability pIntra and intra-cluster (+,-)-edges are inserted with probability pCross. The edges have the ``correct'' sign with probability pSign. Inter-cluster edges...
2,948
29.091837
102
py
signed-oracle
signed-oracle-main/implementation/GraphReader.py
import numpy import Graph ''' Reads a sparse csv file and returns a Graph object. Assumes that the csv-file has the following format: u,v,edgeWeight where u and v are integers and edgeWeight is a float ''' def graphFromSparseCSV(inputfile, separator=',', skipHeader=False, inputIsZeroIndexed=False): ''' since ...
1,414
21.822581
93
py
RefVAE
RefVAE-main/main_GAN.py
from __future__ import print_function import argparse from math import log10 import os import torch import torch.nn as nn import torch.optim as optim import torch.backends.cudnn as cudnn from laploss import LapLoss from torch.utils.data import DataLoader import torch.nn.functional as F from model import * from network...
10,971
37.633803
147
py
RefVAE
RefVAE-main/test.py
from __future__ import print_function import argparse import os import torch import cv2 from model import * import torchvision.transforms as transforms from collections import OrderedDict import numpy as np from os.path import join import time from network import encoder4, decoder4 import numpy from dataset import is_...
8,446
35.5671
102
py
RefVAE
RefVAE-main/image_utils.py
import torch import numpy as np from PIL import Image import math import cv2 class TVLoss(torch.nn.Module): def __init__(self): super(TVLoss,self).__init__() def forward(self,x): batch_size = x.size()[0] h_x = x.size()[2] w_x = x.size()[3] count_h = self._tensor_size(x[...
9,144
37.104167
184
py
RefVAE
RefVAE-main/network.py
import torch import torch.nn as nn class encoder3(nn.Module): def __init__(self): super(encoder3,self).__init__() # vgg # 224 x 224 self.conv1 = nn.Conv2d(3,3,1,1,0) self.reflecPad1 = nn.ReflectionPad2d((1,1,1,1)) # 226 x 226 self.conv2 = nn.Conv2d(3,64,3,1,...
31,991
31.611621
125
py
RefVAE
RefVAE-main/model.py
import torch import torch.nn as nn from torch.nn import functional as F import math from torchvision import models class ncc_test(nn.Module): """Residual Channel Attention Networks. Paper: Image Super-Resolution Using Very Deep Residual Channel Attention Networks Ref git repo: https://github.com/...
47,234
33.129335
116
py
RefVAE
RefVAE-main/dataset.py
import torch.utils.data as data import torch import numpy as np import os from os import listdir from os.path import join from PIL import Image, ImageOps, ImageEnhance import random from torchvision import transforms from glob import glob from imresize import imresize def is_image_file(filename): return any(filen...
8,504
32.093385
108
py
RefVAE
RefVAE-main/data.py
from os.path import join from torchvision import transforms from dataset import DatasetFromFolderEval, DatasetFromFolder def transform(): return transforms.Compose([ transforms.ToTensor(), # Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)) ]) # def transform(fineSize): # return transforms.Comp...
887
26.75
84
py
RefVAE
RefVAE-main/laploss.py
import numpy as np from PIL import Image import torch from torch import nn import torch.nn.functional as fnn from torch.autograd import Variable def build_gauss_kernel(size=5, sigma=1.0, n_channels=1, cuda=False): if size % 2 != 1: raise ValueError("kernel size must be uneven") grid = np.float32(np.m...
3,025
35.457831
91
py
RefVAE
RefVAE-main/eval_4x.py
from __future__ import print_function import argparse import os import torch import cv2 from model import * import torchvision.transforms as transforms from collections import OrderedDict import numpy as np from os.path import join import time from network import encoder4, decoder4 import numpy from dataset import is_...
7,250
33.528571
109
py
RefVAE
RefVAE-main/eval_8x.py
from __future__ import print_function import argparse import os import torch import cv2 from model import * import torchvision.transforms as transforms from collections import OrderedDict import numpy as np from os.path import join import time from network import encoder4, decoder4 import numpy from dataset import is_...
7,250
33.528571
109
py
1L-3NErrors
1L-3NErrors-main/main_aberr.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """NLTE corrections calculator This code takes stellar parameters and line parameters for a specific line and calculates the NLTE corrections, based on results by Amarsi+2022. A neural network is used for interpolation. For more information about how to prepare the input ...
4,257
29.414286
105
py
1L-3NErrors
1L-3NErrors-main/function_aberr.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """NLTE corrections functions Functions to calculate the NLTE corrections aberr, used in the main_aberr.py program. For more information about how to prepare input files and run the main program, or how to use the functions provided in this script see the README files. Vi...
3,479
37.666667
288
py
TrianFlow
TrianFlow-master/test.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from core.dataset import KITTI_2012, KITTI_2015 from core.evaluation import eval_flow_avg, load_gt_flow_kitti from core.evaluation import eval_depth from core.visualize import Visualizer_debug from core.networks import Model_depth_pose, Model_fl...
10,749
40.030534
144
py
TrianFlow
TrianFlow-master/train.py
import os, sys import yaml sys.path.append(os.path.dirname(os.path.abspath(__file__))) from core.dataset import KITTI_RAW, KITTI_Prepared, NYU_Prepare, NYU_v2, KITTI_Odo from core.networks import get_model from core.config import generate_loss_weights_dict from core.visualize import Visualizer from core.evaluation impo...
10,881
49.37963
169
py
TrianFlow
TrianFlow-master/infer_vo.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from core.networks.model_depth_pose import Model_depth_pose from core.networks.model_flow import Model_flow from visualizer import * from profiler import Profiler import torch import torch.nn as nn import torch.nn.functional as F import numpy as...
13,467
38.964392
223
py
TrianFlow
TrianFlow-master/core/evaluation/evaluate_mask.py
import os import numpy as np import cv2 import functools import matplotlib.pyplot as plt import multiprocessing """ Adopted from https://github.com/martinkersner/py_img_seg_eval """ class EvalSegErr(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self....
6,269
23.782609
87
py
TrianFlow
TrianFlow-master/core/evaluation/flowlib.py
#!/usr/bin/python """ Adopted from https://github.com/liruoteng/OpticalFlowToolkit # ============================== # flowlib.py # library for optical flow processing # Author: Ruoteng Li # Date: 6th Aug 2016 # ============================== """ import png import scipy import numpy as np import matplotlib.colors as cl ...
14,420
25.656192
90
py
TrianFlow
TrianFlow-master/core/evaluation/evaluate_flow.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) import numpy as np from flowlib import read_flow_png, flow_to_image import cv2 import multiprocessing import functools def get_scaled_intrinsic_matrix(calib_file, zoom_x, zoom_y): intrinsics = load_intrinsics_raw(calib_file) intrinsics ...
6,496
36.125714
109
py
TrianFlow
TrianFlow-master/core/evaluation/eval_odom.py
import copy from matplotlib import pyplot as plt import numpy as np import os from glob import glob import pdb def scale_lse_solver(X, Y): """Least-sqaure-error solver Compute optimal scaling factor so that s(X)-Y is minimum Args: X (KxN array): current data Y (KxN array): reference data ...
13,822
36.975275
121
py
TrianFlow
TrianFlow-master/core/evaluation/evaluation_utils.py
import numpy as np import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) import cv2, skimage import skimage.io #import scipy.misc as sm import imageio as sm # Adopted from https://github.com/mrharicot/monodepth def compute_errors(gt, pred, nyu=False): thresh = np.maximum((gt / pred), (pred / ...
870
24.617647
60
py
TrianFlow
TrianFlow-master/core/evaluation/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from evaluate_flow import eval_flow_avg, load_gt_flow_kitti from evaluate_mask import load_gt_mask from evaluate_depth import eval_depth
212
34.5
59
py
TrianFlow
TrianFlow-master/core/evaluation/evaluate_depth.py
from evaluation_utils import * def process_depth(gt_depth, pred_depth, min_depth, max_depth): mask = gt_depth > 0 pred_depth[pred_depth < min_depth] = min_depth pred_depth[pred_depth > max_depth] = max_depth gt_depth[gt_depth < min_depth] = min_depth gt_depth[gt_depth > max_depth] = max_depth ...
1,977
35.62963
103
py
TrianFlow
TrianFlow-master/core/networks/model_flow.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from structures import * from pytorch_ssim import SSIM import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import pdb import cv2 def transformerFwd(U, flo, out_size, ...
18,005
46.384211
201
py
TrianFlow
TrianFlow-master/core/networks/model_flowposenet.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from structures import * from pytorch_ssim import SSIM from model_flow import Model_flow sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'visualize')) from visualizer import * from profiler import Profiler import t...
6,517
35.824859
178
py
TrianFlow
TrianFlow-master/core/networks/model_triangulate_pose.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) import torch import torch.nn as nn import numpy as np from structures import * from model_flow import Model_flow import pdb import cv2 class Model_triangulate_pose(nn.Module): def __init__(self, cfg): super(Model_triangulate_pose, s...
5,969
47.536585
182
py
TrianFlow
TrianFlow-master/core/networks/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from model_flow import Model_flow from model_triangulate_pose import Model_triangulate_pose from model_depth_pose import Model_depth_pose from model_flowposenet import Model_flowposenet def get_model(mode): if mode == 'flow': return...
635
32.473684
59
py
TrianFlow
TrianFlow-master/core/networks/model_depth_pose.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from structures import * from model_triangulate_pose import Model_triangulate_pose from pytorch_ssim import SSIM sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'visualize')) from visualizer import * import torch i...
30,237
53.978182
188
py
TrianFlow
TrianFlow-master/core/networks/pytorch_ssim/ssim.py
import torch import torch.nn as nn def SSIM(x, y): C1 = 0.01 ** 2 C2 = 0.03 ** 2 mu_x = nn.AvgPool2d(3, 1, padding=1)(x) mu_y = nn.AvgPool2d(3, 1, padding=1)(y) sigma_x = nn.AvgPool2d(3, 1, padding=1)(x**2) - mu_x**2 sigma_y = nn.AvgPool2d(3, 1, padding=1)(y**2) - mu_y**2 sigma_xy = nn.Av...
535
24.52381
65
py
TrianFlow
TrianFlow-master/core/networks/pytorch_ssim/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from ssim import SSIM
98
18.8
59
py
TrianFlow
TrianFlow-master/core/networks/structures/ransac.py
import torch import numpy as np import os, sys import torch.nn as nn import pdb import cv2 class reduced_ransac(nn.Module): def __init__(self, check_num, thres, dataset): super(reduced_ransac, self).__init__() self.check_num = check_num self.thres = thres self.dataset = dataset ...
3,145
45.955224
189
py
TrianFlow
TrianFlow-master/core/networks/structures/depth_model.py
''' This code was ported from existing repos [LINK] https://github.com/nianticlabs/monodepth2 ''' from __future__ import absolute_import, division, print_function import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) import numpy as np import torch import torch.nn as nn import torch.nn.functional a...
7,964
36.394366
92
py
TrianFlow
TrianFlow-master/core/networks/structures/flowposenet.py
import torch import torch.nn as nn from torch import sigmoid from torch.nn.init import xavier_uniform_, zeros_ def conv(in_planes, out_planes, kernel_size=3): return nn.Sequential( nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, padding=(kernel_size-1)//2, stride=2), nn.ReLU(inplace=True...
1,951
30.483871
104
py
TrianFlow
TrianFlow-master/core/networks/structures/feature_pyramid.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from net_utils import conv import torch import torch.nn as nn class FeaturePyramid(nn.Module): def __init__(self): super(FeaturePyramid, self).__init__() self.conv1 = conv(3, 16, kernel_size=3, stride=2) self.conv2...
1,586
40.763158
77
py
TrianFlow
TrianFlow-master/core/networks/structures/inverse_warp.py
from __future__ import division import torch import torch.nn.functional as F pixel_coords = None def set_id_grid(depth): global pixel_coords b, h, w = depth.size() i_range = torch.arange(0, h).view(1, h, 1).expand( 1, h, w).type_as(depth) # [1, H, W] j_range = torch.arange(0, w).view(1, 1, w...
10,018
36.107407
119
py
TrianFlow
TrianFlow-master/core/networks/structures/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from feature_pyramid import FeaturePyramid from pwc_tf import PWC_tf from ransac import reduced_ransac from depth_model import Depth_Model from net_utils import conv, deconv, warp_flow from flowposenet import FlowPoseNet from inverse_warp import...
335
32.6
59
py
TrianFlow
TrianFlow-master/core/networks/structures/pwc_tf.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from net_utils import conv, deconv, warp_flow sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'external')) # from correlation_package.correlation import Correlation # from spatial_correlation_sampler import S...
8,423
45.541436
97
py
TrianFlow
TrianFlow-master/core/networks/structures/net_utils.py
import torch import torch.nn as nn from torch.autograd import Variable import pdb import numpy as np def conv(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1): return nn.Sequential( nn.Conv2d(in_planes, out_planes, kernel_size=kernel_size, stride=stride, pa...
2,088
32.693548
119
py
TrianFlow
TrianFlow-master/core/config/config_utils.py
import os, sys def generate_loss_weights_dict(cfg): weight_dict = {} weight_dict['loss_pixel'] = 1 - cfg.w_ssim weight_dict['loss_ssim'] = cfg.w_ssim weight_dict['loss_flow_smooth'] = cfg.w_flow_smooth weight_dict['loss_flow_consis'] = cfg.w_flow_consis weight_dict['geo_loss'] = cfg.w_geo w...
546
33.1875
57
py
TrianFlow
TrianFlow-master/core/config/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from config_utils import generate_loss_weights_dict
128
24.8
59
py
TrianFlow
TrianFlow-master/core/dataset/kitti_raw.py
import os, sys import numpy as np import imageio from tqdm import tqdm import torch.multiprocessing as mp import pdb def process_folder(q, static_frames, test_scenes, data_dir, output_dir, stride=1): while True: if q.empty(): break folder = q.get() if folder in static_frames.key...
8,568
40.8
150
py
TrianFlow
TrianFlow-master/core/dataset/__init__.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from kitti_raw import KITTI_RAW from kitti_prepared import KITTI_Prepared from kitti_2012 import KITTI_2012 from kitti_2015 import KITTI_2015 from nyu_v2 import NYU_Prepare, NYU_v2 from kitti_odo import KITTI_Odo
287
35
59
py
TrianFlow
TrianFlow-master/core/dataset/nyu_v2.py
import os, sys import numpy as np import imageio import cv2 import copy import h5py import scipy.io as sio import torch import torch.utils.data import pdb from tqdm import tqdm import torch.multiprocessing as mp def collect_image_list(path): # Get ppm images list of a folder. files = os.listdir(path) sorte...
13,298
36.997143
150
py
TrianFlow
TrianFlow-master/core/dataset/kitti_2015.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from kitti_2012 import KITTI_2012 class KITTI_2015(KITTI_2012): def __init__(self, data_dir, img_hw=(256, 832)): super(KITTI_2015, self).__init__(data_dir, img_hw, init=False) self.num_total = 200 self.data_list = s...
378
24.266667
70
py
TrianFlow
TrianFlow-master/core/dataset/kitti_2012.py
import os, sys sys.path.append(os.path.dirname(os.path.abspath(__file__))) from kitti_prepared import KITTI_Prepared sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'evaluation')) from evaluate_flow import get_scaled_intrinsic_matrix, eval_flow_avg import numpy as np import cv2 import cop...
2,288
35.333333
110
py