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 |
|---|---|---|---|---|---|---|
tunit | tunit-master/validation/cluster_eval.py | """
Invariant Information Clustering for Unsupervised Image Classification and Segmentation
Copyright (c) 2019 Xu Ji
MIT license
"""
from __future__ import print_function
import sys
from datetime import datetime
import numpy as np
import torch
from validation.eval_metrics import _hungarian_match, _acc
def _cluster... | 6,681 | 34.542553 | 115 | py |
tunit | tunit-master/validation/plot_tsne.py | """
TUNIT: Truly Unsupervised Image-to-Image Translation
Copyright (c) 2020-present NAVER Corp.
MIT license
"""
import torch.nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.utils as vutils
import numpy as np
from sklearn.manifold import TS... | 3,798 | 30.396694 | 117 | py |
qBOLD-VI | qBOLD-VI-main/signals.py | #!/usr/bin/env python3
import math
import numpy as np
import argparse
import configparser
import tensorflow as tf
keras = tf.keras
class SignalGenerationLayer(keras.layers.Layer):
"""
Encapsulate all the signal generation code into a Keras layer
"""
def __init__(self, system_parameters, full_model... | 15,656 | 46.018018 | 141 | py |
qBOLD-VI | qBOLD-VI-main/qbold_train_model.py | #!/usr/bin/env python3
import os
import numpy as np
from model import EncoderTrainer
import tensorflow as tf
from tensorflow import keras
import tensorflow_addons as tfa
import wandb
from wandb.keras import WandbCallback
from qbold_build_model import ModelBuilder, WeightStatus
from signals import SignalGenerationLaye... | 15,261 | 44.153846 | 120 | py |
qBOLD-VI | qBOLD-VI-main/model.py | # Author: Ivor Simpson, University of Sussex (i.simpson@sussex.ac.uk)
# Purpose: Store the model code
import tensorflow as tf
from tensorflow import keras
import tensorflow_probability as tfp
import math
import numpy as np
def logit(signal):
# Inverse sigmoid function
return tf.math.log(signal / (1.0 - signal... | 44,478 | 49.088964 | 154 | py |
qBOLD-VI | qBOLD-VI-main/train.py | #!/usr/bin/env python3
from signals import SignalGenerationLayer, create_synthetic_dataset
import os
import numpy as np
import argparse
import configparser
from model import EncoderTrainer
import tensorflow as tf
from tensorflow import keras
import tensorflow_addons as tfa
import wandb
from wandb.keras import WandbC... | 22,623 | 44.98374 | 128 | py |
BATFormer | BATFormer-main/test.py | import torch
import models
import argparse
import torch
import torchvision
from torch import nn
from torch.autograd import Variable
from torch.utils.data import DataLoader
import os
import numpy as np
import torch
import cv2
from einops import rearrange, repeat
import utils.metrics as metrics
from hausdorff import haus... | 14,147 | 43.490566 | 213 | py |
BATFormer | BATFormer-main/train.py | import torch
import models
import argparse
import torch
import torchvision
from torch import nn
from torch.autograd import Variable
from torch.utils.data import DataLoader
import os
import numpy as np
import torch
import cv2
from einops import rearrange, repeat
from torch.utils.tensorboard import SummaryWriter
import u... | 15,653 | 50.834437 | 213 | py |
BATFormer | BATFormer-main/models/transformer_parts_mp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.autograd import Variable
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
import numpy as np
np.set_printoptions(threshold=1000)
import cv2
import random
from utils.visualization import featuremap_vis... | 19,485 | 39.260331 | 166 | py |
BATFormer | BATFormer-main/models/MPtrans.py | from .unets_parts import *
from .transformer_parts import TransformerDown
from .transformer_parts_mp import Transformer_block_global, Transformer_block_local, Transformer_block
from einops import rearrange, repeat
class C2FTrans(nn.Module):
def __init__(self, global_block, local_block, layers, n_channels, n_classe... | 4,214 | 45.318681 | 175 | py |
BATFormer | BATFormer-main/models/transformer_parts.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.autograd import Variable
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
import numpy as np
np.set_printoptions(threshold=1000)
import cv2
import random
from utils.visualization import featuremap_vis... | 4,969 | 36.938931 | 165 | py |
BATFormer | BATFormer-main/models/unets_parts.py | """ Parts of the U-Net model """
import torch
import torch.nn as nn
import torch.nn.functional as F
# ==================================================== for Unet ====================================================
class DoubleConv(nn.Module):
"""(convolution => [BN] => ReLU) * 2"""
def __init__(self, in_... | 10,993 | 35.164474 | 124 | py |
BATFormer | BATFormer-main/utils/utils_gray.py | import os
import numpy as np
import torch
from skimage import io, color
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms import functional as F
from typing import Callable
import os
import cv2
import pandas as pd
from numbers import Number
fr... | 12,057 | 37.401274 | 120 | py |
BATFormer | BATFormer-main/utils/visualization.py | import matplotlib.pylab as plt
import torchvision
import os
import torch
import cv2
import numpy as np
from utils.imgname import read_img_name
import matplotlib.pyplot as plt
import seaborn as sns
def featuremap_visual(feature,
out_dir='./utils/visualization',
save_feature... | 6,923 | 36.225806 | 135 | py |
BATFormer | BATFormer-main/utils/tensor_utils.py | import numpy as np
import torch
from torch import nn
def sum_tensor(inp, axes, keepdim=False):
axes = np.unique(axes).astype(int)
if keepdim:
for ax in axes:
inp = inp.sum(int(ax), keepdim=True)
else:
for ax in sorted(axes, reverse=True):
inp = inp.sum(int(ax))
... | 933 | 22.948718 | 66 | py |
BATFormer | BATFormer-main/utils/nd_softmax.py | import torch
from torch import nn
import torch.nn.functional as F
softmax_helper = lambda x: F.softmax(x, 1) | 109 | 21 | 42 | py |
BATFormer | BATFormer-main/utils/utils_multi_rgb.py | import os
import numpy as np
import torch
from skimage import io, color
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms import functional as F
from typing import Callable
import os
import cv2
import pandas as pd
from numbers import Number
fr... | 14,135 | 40.212828 | 118 | py |
BATFormer | BATFormer-main/utils/utils_rgb.py | import os
import numpy as np
import torch
from skimage import io, color
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms import functional as F
from typing import Callable
import os
import cv2
import pandas as pd
from numbers import Number
fr... | 10,960 | 39.899254 | 118 | py |
BATFormer | BATFormer-main/utils/utils_multi.py | import os
import numpy as np
import torch
from skimage import io, color
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms as T
from torchvision.transforms import functional as F
from typing import Callable
import os
import cv2
import pandas as pd
from numbers import Number
fr... | 13,762 | 39.96131 | 118 | py |
BATFormer | BATFormer-main/utils/flops_counter.py | import sys
import torch
import torch.nn as nn
import numpy as np
def get_model_complexity_info(model, input_res,
print_per_layer_stat=True,
as_strings=True,
input_constructor=None, ost=sys.stdout):
assert type(input_res) is... | 13,554 | 32.469136 | 100 | py |
BATFormer | BATFormer-main/utils/metrics.py | import numpy as np
import torch
from hausdorff import hausdorff_distance
def dice_coefficient(pred, gt, smooth=1e-5):
""" computational formula:
dice = 2TP/(FP + 2TP + FN)
"""
N = gt.shape[0]
pred[pred >= 1] = 1
gt[gt >= 1] = 1
pred_flat = pred.reshape(N, -1)
gt_flat = gt.reshape(N,... | 3,082 | 31.797872 | 112 | py |
BATFormer | BATFormer-main/utils/transfer_model.py | import torch
import torch.onnx
import onnx
from onnx_tf.backend import prepare
from onnx2keras import onnx_to_keras
import keras
import tensorflow as tf
def pth_to_onnx(input_model, onnx_path):
'''
1)声明:使用本函数之前,必须保证你手上已经有了.pth模型文件.
2)功能:本函数功能四将pytorch训练得到的.pth文件转化为onnx文件。
'''
model = input_model ... | 1,920 | 32.12069 | 127 | py |
BATFormer | BATFormer-main/utils/non_maximum_suppression.py | from torch import Tensor
import torch
def box_area(boxes: Tensor) -> Tensor:
return (boxes[:, 2] - boxes[:, 0]) * (boxes[:, 3] - boxes[:, 1])
def box_iou(boxes1: Tensor, boxes2: Tensor) -> Tensor:
area1 = box_area(boxes1) # 每个框的面积 (N,)
area2 = box_area(boxes2) # (M,)
lt = torch.max(boxes1[:, None... | 1,503 | 30.333333 | 87 | py |
BATFormer | BATFormer-main/utils/loss_functions/dice_loss.py | import torch
from utils.loss_functions.TopK_loss import TopKLoss
from utils.loss_functions.crossentropy import RobustCrossEntropyLoss
from utils.nd_softmax import softmax_helper
from utils.tensor_utils import sum_tensor
from torch import nn
import numpy as np
class GDL(nn.Module):
def __init__(self, apply_nonlin=... | 13,303 | 31.687961 | 121 | py |
BATFormer | BATFormer-main/utils/loss_functions/TopK_loss.py | import numpy as np
import torch
from utils.loss_functions.crossentropy import RobustCrossEntropyLoss
class TopKLoss(RobustCrossEntropyLoss):
"""
Network has to have NO LINEARITY!
"""
def __init__(self, weight=None, ignore_index=-100, k=10):
self.k = k
super(TopKLoss, self).__init__(weig... | 663 | 35.888889 | 91 | py |
BATFormer | BATFormer-main/utils/loss_functions/crossentropy.py | from torch import nn, Tensor
class RobustCrossEntropyLoss(nn.CrossEntropyLoss):
"""
this is just a compatibility layer because my target tensor is float and has an extra dimension
"""
def forward(self, input: Tensor, target: Tensor) -> Tensor:
if len(target.shape) == len(input.shape):
... | 437 | 38.818182 | 99 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_eval_CAE_embeddings_RSA.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import os,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
import yaml
import pprint
import collections
import pickle
import matplotlib.pyp... | 12,862 | 31.077307 | 102 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_train_seq2seq_embeddings.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import yaml
import pprint
import collections
# to get time model was trained
from datetime import datetime
import pytz
# NOTE: import torch before pandas, otherwise segementation fault error occurs
# The couse of this problem is UNKNOWN, and not solved yet
im... | 13,680 | 30.23516 | 93 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_eval_contrastive_embeddings_RSA.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import os,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
import yaml
import pprint
import collections
import pickle
import matplotlib.pyp... | 12,645 | 30.934343 | 102 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_eval_cross_model_embeddings_RSA.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import os,inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
import yaml
import pprint
import collections
import pickle
import matplotlib.pyp... | 13,186 | 29.810748 | 129 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_train_CAE_embeddings.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import yaml
import pprint
import collections
# to get time model was trained
from datetime import datetime
import pytz
# NOTE: import torch before pandas, otherwise segementation fault error occurs
# The couse of this problem is UNKNOWN, and not solved yet
im... | 14,190 | 30.747204 | 114 | py |
xRSA-AWEs | xRSA-AWEs-main/train_utils.py | # Helper functions to train neural models
# import sys
# reload(sys)
# sys.setdefaultencoding('utf8')
import os
from collections import defaultdict, Counter
import sys
import torch
import torch.nn.functional as F
import numpy as np
import faiss
from scipy.spatial import distance
import scipy.stats as stats
def mak... | 15,277 | 27.450652 | 112 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_eval_seq2seq_embeddings_RSA.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import os, inspect
current_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
parent_dir = os.path.dirname(current_dir)
sys.path.insert(0, parent_dir)
import yaml
import pprint
import collections
import pickle
import matplotlib.py... | 12,683 | 30.949622 | 102 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_train_auto_encoder_embeddings.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import yaml
import pprint
import collections
# to get time model was trained
from datetime import datetime
import pytz
# NOTE: import torch before pandas, otherwise segementation fault error occurs
# The couse of this problem is UNKNOWN, and not solved yet
im... | 14,154 | 30.666667 | 93 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_train_contrastive_embeddings.py | #!/usr/bin/env python
# coding: utf-8
import os
import sys
import yaml
import pprint
import collections
# to get time model was trained
from datetime import datetime
import pytz
# NOTE: import torch before pandas, otherwise segementation fault error occurs
# The couse of this problem is UNKNOWN, and not solved yet
im... | 14,385 | 31.621315 | 152 | py |
xRSA-AWEs | xRSA-AWEs-main/nn_speech_models.py | # coding: utf-8
# Code for Acoustic Word Representations (AWEs)
# Developed by Badr M. Abdullah — LSV @ Saarland University
# Follow me on Twitter @badr_nlp
import math
from collections import defaultdict, Counter
import sklearn
import sklearn.preprocessing
import numpy as np
import torch
from torch import Tensor
im... | 61,884 | 32.271505 | 139 | py |
DK-for-TST | DK-for-TST-master/Deep_Baselines_CIFAR10.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D and baselines in our paper on CIFAR dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA... | 16,910 | 41.067164 | 145 | py |
DK-for-TST | DK-for-TST-master/Ablation_Tests_Blob.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of ablation studies in our paper on Blob dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA ver... | 15,789 | 44.504323 | 172 | py |
DK-for-TST | DK-for-TST-master/Deep_Baselines_MNIST.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D and baselines in our paper on MNIST dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA... | 17,039 | 40.359223 | 143 | py |
DK-for-TST | DK-for-TST-master/Baselines_HIGGS.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of baselines in our paper on Higgs dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version i... | 9,184 | 39.822222 | 133 | py |
DK-for-TST | DK-for-TST-master/Deep_Kernel_Blob.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D in our paper on Blob dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version is 10.... | 8,545 | 39.695238 | 122 | py |
DK-for-TST | DK-for-TST-master/utils.py | import numpy as np
import torch
import torch.utils.data
import freqopttest.data as data
import freqopttest.tst as tst
is_cuda = True
class ModelLatentF(torch.nn.Module):
"""define deep networks."""
def __init__(self, x_in, H, x_out):
"""Init latent features."""
super(ModelLatentF, self).__init... | 14,217 | 36.914667 | 128 | py |
DK-for-TST | DK-for-TST-master/Ablation_Tests_HDGM.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of ablation studies in our paper on HDGM dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA ver... | 14,385 | 42.462236 | 152 | py |
DK-for-TST | DK-for-TST-master/Baselines_HDGM.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of baselines in our paper on HDGM dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version is... | 10,368 | 42.751055 | 133 | py |
DK-for-TST | DK-for-TST-master/Ablation_Tests_HIGGS.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of ablation studies in our paper on Higgs dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA ve... | 13,282 | 40.123839 | 152 | py |
DK-for-TST | DK-for-TST-master/utils_HD.py | import numpy as np
import torch
import torchvision # use it for torch.utils.data
import freqopttest.data as data
import freqopttest.tst as tst
import scipy.stats as stats
import pdb
is_cuda = True
class ModelLatentF(torch.nn.Module):
"""define deep networks."""
def __init__(self, x_in, H, x_out):
"""I... | 19,931 | 36.821632 | 138 | py |
DK-for-TST | DK-for-TST-master/Ablation_Tests_MNIST.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D and baselines in our paper on MNIST dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA... | 18,249 | 40.571754 | 129 | py |
DK-for-TST | DK-for-TST-master/Deep_Kernel_HIGGS.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D in our paper on Higgs dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version is 10... | 6,689 | 34.026178 | 122 | py |
DK-for-TST | DK-for-TST-master/Interpretability_CIFAR10_train_location.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of Deep-kernel ME (training test locations) and
ME in our paper on CIFAR dataset (Interpretability experiments).
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be foun... | 18,456 | 41.429885 | 155 | py |
DK-for-TST | DK-for-TST-master/Deep_Kernel_HDGM.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of MMD-D in our paper on HDGM dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version is 10.... | 7,700 | 38.290816 | 118 | py |
DK-for-TST | DK-for-TST-master/Interpretability_CIFAR10_select_location.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of Deep-kernel ME (selecting test locations) on CIFAR dataset (Interpretability experiments).
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch... | 14,748 | 38.862162 | 140 | py |
DK-for-TST | DK-for-TST-master/Baselines_Blob.py | # -*- coding: utf-8 -*-
"""
Created on Dec 21 14:57:02 2019
@author: Learning Deep Kernels for Two-sample Test
@Implementation of baselines in our paper on Blob dataset
BEFORE USING THIS CODE:
1. This code requires PyTorch 1.1.0, which can be found in
https://pytorch.org/get-started/previous-versions/ (CUDA version is... | 11,568 | 43.841085 | 137 | py |
desitarget | desitarget-main/doc/conf.py | # -*- coding: utf-8 -*-
#
# desitarget documentation build configuration file, created by
# sphinx-quickstart on Wed Oct 14 13:53:17 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
... | 10,907 | 31.658683 | 82 | py |
tick | tick-master/tick/hawkes/inference/hawkes_cumulant_matching.py | from itertools import product
import numpy as np
import scipy
from scipy.linalg import qr, sqrtm, norm
from tick.base import Base
from tick.hawkes.inference.base import LearnerHawkesNoParam
from tick.hawkes.inference.build.hawkes_inference import (HawkesCumulant as
... | 31,060 | 33.170517 | 114 | py |
tick | tick-master/tick/hawkes/inference/tests/hawkes_cumulant_matching_test.py | # License: BSD 3 clause
import os
import pickle
import unittest
import numpy as np
from tick.base.inference import InferenceTest
from tick.hawkes import (
HawkesCumulantMatching,
HawkesCumulantMatchingTf,
HawkesCumulantMatchingPyT
)
from tick.hawkes.inference.hawkes_cumulant_matching import HawkesTheor... | 15,919 | 33.16309 | 99 | py |
tick | tick-master/doc/conf.py | # -*- coding: utf-8 -*-
#
# tick documentation build configuration file, created by
# sphinx-quickstart
#
# This file is execfile()d with the current directory set to its containing
# dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a d... | 11,537 | 30.183784 | 79 | py |
GaitSet | GaitSet-master/work/OUMVLP_network/basic_blocks.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, **kwargs):
super(BasicConv2d, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, bias=False, **kwargs)
def for... | 1,661 | 32.918367 | 91 | py |
GaitSet | GaitSet-master/work/OUMVLP_network/gaitset.py | class SetNet(nn.Module):
def __init__(self, hidden_dim):
super(SetNet, self).__init__()
self.hidden_dim = hidden_dim
self.batch_frame = None
_in_channels = 1
_channels = [64,128,256]
self.set_layer1 = SetBlock(BasicConv2d(_in_channels, _channels[0], 5, paddin... | 3,623 | 40.181818 | 95 | py |
GaitSet | GaitSet-master/model/model.py | import math
import os
import os.path as osp
import random
import sys
from datetime import datetime
import numpy as np
import torch
import torch.nn as nn
import torch.autograd as autograd
import torch.optim as optim
import torch.utils.data as tordata
from .network import TripletLoss, SetNet
from .utils import TripletS... | 10,845 | 38.728938 | 103 | py |
GaitSet | GaitSet-master/model/network/basic_blocks.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicConv2d(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, **kwargs):
super(BasicConv2d, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, bias=False, **kwargs)
def for... | 896 | 29.931034 | 91 | py |
GaitSet | GaitSet-master/model/network/triplet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class TripletLoss(nn.Module):
def __init__(self, batch_size, hard_or_full, margin):
super(TripletLoss, self).__init__()
self.batch_size = batch_size
self.margin = margin
def forward(self, feature, label):
# fea... | 1,824 | 38.673913 | 105 | py |
GaitSet | GaitSet-master/model/network/gaitset.py | import torch
import torch.nn as nn
import numpy as np
from .basic_blocks import SetBlock, BasicConv2d
class SetNet(nn.Module):
def __init__(self, hidden_dim):
super(SetNet, self).__init__()
self.hidden_dim = hidden_dim
self.batch_frame = None
_set_in_channels = 1
_set_cha... | 4,812 | 38.77686 | 103 | py |
GaitSet | GaitSet-master/model/utils/sampler.py | import torch.utils.data as tordata
import random
class TripletSampler(tordata.sampler.Sampler):
def __init__(self, dataset, batch_size):
self.dataset = dataset
self.batch_size = batch_size
def __iter__(self):
while (True):
sample_indices = list()
pid_list = ran... | 828 | 29.703704 | 70 | py |
GaitSet | GaitSet-master/model/utils/data_set.py | import torch.utils.data as tordata
import numpy as np
import os.path as osp
import os
import pickle
import cv2
import xarray as xr
class DataSet(tordata.Dataset):
def __init__(self, seq_dir, label, seq_type, view, cache, resolution):
self.seq_dir = seq_dir
self.view = view
self.seq_type = ... | 3,243 | 34.648352 | 90 | py |
GaitSet | GaitSet-master/model/utils/evaluator.py | import torch
import torch.nn.functional as F
import numpy as np
def cuda_dist(x, y):
x = torch.from_numpy(x).cuda()
y = torch.from_numpy(y).cuda()
dist = torch.sum(x ** 2, 1).unsqueeze(1) + torch.sum(y ** 2, 1).unsqueeze(
1).transpose(0, 1) - 2 * torch.matmul(x, y.transpose(0, 1))
dist = torch... | 1,948 | 37.98 | 111 | py |
RoboBEV | RoboBEV-master/uda/tools/data_converter/create_gt_database.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pickle
from mmcv import track_iter_progress
from mmcv.ops import roi_align
from os import path as osp
from pycocotools import mask as maskUtils
from pycocotools.coco import COCO
from mmdet3d.core.bbox import box_np_ops as box_np_ops
... | 12,654 | 36.330383 | 79 | py |
RoboBEV | RoboBEV-master/uda/projects/mmdet3d_plugin/datasets/uda_nuscenes.py | # Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
import pyquaternion
import tempfile
from nuscenes.utils.data_classes import Box as NuScenesBox
from os import path as osp
from mmdet.datasets import DATASETS
from mmdet3d.core import show_result
from mmdet3d.core.bbox import Box3DMode, Coor... | 26,089 | 38.832061 | 154 | py |
RoboBEV | RoboBEV-master/uda/projects/mmdet3d_plugin/datasets/uda_nuscenes_mono.py | # Copyright (c) OpenMMLab. All rights reserved.
import copy
import mmcv
import numpy as np
import pyquaternion
import tempfile
import torch
import warnings
from nuscenes.utils.data_classes import Box as NuScenesBox
from os import path as osp
from mmdet3d.core import bbox3d2result, box3d_multiclass_nms, xywhr2xyxyr
fro... | 32,623 | 39.882206 | 154 | py |
RoboBEV | RoboBEV-master/zoo/CVT/scripts/generate_data.py | import torch
import json
import hydra
import cv2
import numpy as np
from pathlib import Path
from tqdm import tqdm
from cross_view_transformer.data.transforms import LoadDataTransform
from cross_view_transformer.common import setup_config, setup_data_module, setup_viz
def setup(cfg):
# Don't change these
cf... | 2,674 | 29.747126 | 90 | py |
RoboBEV | RoboBEV-master/zoo/CVT/scripts/benchmark.py | from pathlib import Path
from tqdm import tqdm
import torch
import pytorch_lightning as pl
import hydra
from cross_view_transformer.common import setup_config, setup_network, setup_data_module
def setup(cfg):
print('Benchmark mixed precision by adding +mixed_precision=True')
print('Benchmark cpu performance... | 1,206 | 23.14 | 94 | py |
RoboBEV | RoboBEV-master/zoo/CVT/scripts/overfit.py | from pathlib import Path
import numpy as np
import torch
import pytorch_lightning as pl
import hydra
import tqdm
import cv2
from omegaconf import DictConfig
from pytorch_lightning.core.memory import ModelSummary
from cross_view_transformer.common import setup_config, setup_experiment
def setup(cfg):
cfg.data.au... | 1,865 | 23.88 | 94 | py |
RoboBEV | RoboBEV-master/zoo/CVT/scripts/train.py | from pathlib import Path
import logging
import pytorch_lightning as pl
import hydra
from pytorch_lightning.strategies.ddp import DDPStrategy
from pytorch_lightning.callbacks import LearningRateMonitor, ModelCheckpoint
from cross_view_transformer.common import setup_config, setup_experiment, load_backbone
from cross_... | 2,449 | 30.410256 | 93 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/losses.py | import torch
import logging
from fvcore.nn import sigmoid_focal_loss
logger = logging.getLogger(__name__)
class SigmoidFocalLoss(torch.nn.Module):
def __init__(
self,
alpha=-1.0,
gamma=2.0,
reduction='mean'
):
super().__init__()
self.alpha = alpha
se... | 3,100 | 25.504274 | 93 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/common.py | import torch
from hydra.utils import instantiate
from omegaconf import OmegaConf, DictConfig
from torchmetrics import MetricCollection
from pathlib import Path
from .model.model_module import ModelModule
from .data.data_module import DataModule
from .losses import MultipleLoss
from collections.abc import Callable
fr... | 2,741 | 27.863158 | 115 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/metrics.py | import torch
from torchmetrics import Metric
from typing import List, Optional
class BaseIoUMetric(Metric):
"""
Computes intersection over union at given thresholds
"""
def __init__(self, thresholds=[0.4, 0.5]):
super().__init__(dist_sync_on_step=False, compute_on_step=False)
thresho... | 2,940 | 39.287671 | 106 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/callbacks/gitdiff_callback.py | import logging
import pytorch_lightning as pl
import git
from pathlib import Path
from pytorch_lightning.utilities import rank_zero_only
from omegaconf import OmegaConf, DictConfig
log = logging.getLogger(__name__)
PROJECT_ROOT = Path(__file__).parent.parent.parent
TEMPLATE = """
==================================... | 888 | 22.394737 | 87 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/callbacks/visualization_callback.py | import pytorch_lightning as pl
import torch
import torch.utils.data
from typing import Any, Optional
from pytorch_lightning.utilities.types import STEP_OUTPUT
from pytorch_lightning.loggers.wandb import WandbLogger
from pytorch_lightning.utilities import rank_zero_only
from pytorch_lightning.utilities.warnings import ... | 1,946 | 33.157895 | 103 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/data/nuscenes_dataset.py | import torch
import numpy as np
import cv2
from pathlib import Path
from functools import lru_cache
from pyquaternion import Quaternion
from shapely.geometry import MultiPolygon
from .common import INTERPOLATION, get_view_matrix, get_pose, get_split
from .transforms import Sample, SaveDataTransform
STATIC = ['lane... | 15,191 | 34.495327 | 106 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/data/augmentations.py | """
https://github.com/eriklindernoren/PyTorch-YOLOv3/blob/master/pytorchyolo/utils/transforms.py
"""
import imgaug.augmenters as iaa
import torchvision
import numpy as np
class AugBase(torchvision.transforms.ToTensor):
def __init__(self):
super().__init__()
self.augment = self.get_augment().augm... | 967 | 24.473684 | 93 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/data/nuscenes_dataset_generated.py | import json
import torch
from pathlib import Path
from .common import get_split
from .transforms import Sample, LoadDataTransform
def get_data(
dataset_dir,
labels_dir,
split,
version,
num_classes,
augment='none',
image=None, # image config
dataset='unused', ... | 1,524 | 26.727273 | 95 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/data/transforms.py | import pathlib
import torch
import torchvision
import numpy as np
from PIL import Image
from .common import encode, decode
from .augmentations import StrongAug, GeometricAug
class Sample(dict):
def __init__(
self,
token,
scene,
intrinsics,
extrinsics,
images,
... | 5,550 | 27.911458 | 91 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/data/data_module.py | import torch
import pytorch_lightning as pl
from . import get_dataset_module_by_name
class DataModule(pl.LightningDataModule):
def __init__(self, dataset: str, data_config: dict, loader_config: dict):
super().__init__()
self.get_data = get_dataset_module_by_name(dataset).get_data
self.d... | 1,088 | 29.25 | 85 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/visualizations/common.py | import torch
import numpy as np
import cv2
from matplotlib.pyplot import get_cmap
# many colors from
# https://github.com/nutonomy/nuscenes-devkit/blob/master/python-sdk/nuscenes/utils/color_map.py
COLORS = {
# static
'lane': (110, 110, 110),
'road_segment': (90, 90, 90),
# ... | 5,432 | 27.746032 | 96 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/visualizations/nuscenes_stitch_viz.py | import torch
import numpy as np
import cv2
from .common import resize, to_image
from ..data.nuscenes_dataset import CLASSES
def smooth(x, t1=0.6, c=[52, 101, 154]):
w = np.float32([255, 255, 255])[None, None]
c = np.float32(c)[None, None]
m1 = x > t1
x_viz = 255 * np.ones(x.shape + (3,), dtype=np.f... | 2,817 | 30.311111 | 102 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/model/encoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange, repeat
from torchvision.models.resnet import Bottleneck
from typing import List
ResNetBottleNeck = lambda c: Bottleneck(c, c // 4)
def generate_grid(height: int, width: int):
xs = torch.linspace(0, 1, width)
ys... | 12,089 | 34.769231 | 100 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/model/cvt.py | import torch.nn as nn
class CrossViewTransformer(nn.Module):
def __init__(
self,
encoder,
decoder,
dim_last: int = 64,
outputs: dict = {'bev': [0, 1]}
):
super().__init__()
dim_total = 0
dim_max = 0
for _, (start, stop) in outputs.items... | 1,016 | 23.804878 | 85 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/model/decoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class DecoderBlock(torch.nn.Module):
def __init__(self, in_channels, out_channels, skip_dim, residual, factor):
super().__init__()
dim = out_channels // factor
self.conv = nn.Sequential(
nn.Upsample(scale_fact... | 1,555 | 24.096774 | 79 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/model/model_module.py | import torch
import pytorch_lightning as pl
class ModelModule(pl.LightningModule):
def __init__(self, backbone, loss_func, metrics, optimizer_args, scheduler_args=None, cfg=None):
super().__init__()
self.save_hyperparameters(
cfg,
ignore=['backbone', 'loss_func', 'metrics'... | 3,383 | 34.621053 | 100 | py |
RoboBEV | RoboBEV-master/zoo/CVT/cross_view_transformer/model/backbones/efficientnet.py | import torch
import torch.nn as nn
from efficientnet_pytorch import EfficientNet
# Precomputed aliases
MODELS = {
'efficientnet-b0': [
('reduction_1', (0, 2)),
('reduction_2', (2, 4)),
('reduction_3', (4, 6)),
('reduction_4', (6, 12))
],
'efficientnet-b4': [
('redu... | 4,130 | 27.6875 | 93 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/generate_dataset.py | import argparse
import os
import warnings
import time
import numpy as np
import torch
import mmcv
from mmdet3d.datasets import build_dataset, build_dataloader
from mmcv import Config, DictAction
from mmdet3d.datasets import build_dataset
from project.mmdet3d_plugin.corruptions import CORRUPTIONS
def parse_args():
... | 4,414 | 34.32 | 128 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/test.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import mmcv
import os
import torch
import warnings
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (
get_dist_info,
init_dist,
loa... | 11,494 | 35.376582 | 79 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/benchmark.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import time
import torch
from mmcv import Config
from mmcv.parallel import MMDataParallel
from mmcv.runner import load_checkpoint, wrap_fp16_model
import sys
sys.path.append('.')
from projects.mmdet3d_plugin.datasets.builder import build_dataloader
from pr... | 3,650 | 31.891892 | 79 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/fuse_conv_bn.py | # Copyright (c) OpenMMLab. All rights reserved.
import argparse
import torch
from mmcv.runner import save_checkpoint
from torch import nn as nn
from mmdet3d.apis import init_model
def fuse_conv_bn(conv, bn):
"""During inference, the functionary of batch norm layers is turned off but
only the mean and var al... | 2,243 | 31.521739 | 79 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/robust_test.py | # Copyright (c) OpenMMLab. All rights reserved.
# ---------------------------------------------
# Modified by Shaoyuan Xie
# ---------------------------------------------
import argparse
import mmcv
import os
import torch
import warnings
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.p... | 11,425 | 39.51773 | 94 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/tools/train.py | # Copyright (c) OpenMMLab. All rights reserved.
from __future__ import division
import sys
import os
print(sys.executable, os.path.abspath(__file__))
# import init_paths # for conda pkgs submitting method
import argparse
import copy
import mmcv
import time
import torch
import warnings
from mmcv import Config, DictActi... | 11,412 | 34.009202 | 125 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/projects/configs/sparse4d_r101_H1.py | _base_ = [
'./default_runtime.py'
]
class_names = [
'car',
'truck',
'construction_vehicle',
'bus',
'trailer',
'barrier',
'motorcycle',
'bicycle',
'pedestrian',
'traffic_cone'
]
num_classes = len(class_names)
embed_dims = 256
num_groups = 8
num_decoder = 6
model = dict(
... | 7,074 | 25.799242 | 74 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/projects/configs/robust_test/sparse4d_r101_H1.py | _base_ = [
'../default_runtime.py'
]
class_names = [
'car',
'truck',
'construction_vehicle',
'bus',
'trailer',
'barrier',
'motorcycle',
'bicycle',
'pedestrian',
'traffic_cone'
]
num_classes = len(class_names)
embed_dims = 256
num_groups = 8
num_decoder = 6
model = dict(
... | 7,337 | 26.586466 | 104 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/projects/mmdet3d_plugin/apis/test.py | # ---------------------------------------------
# Copyright (c) OpenMMLab. All rights reserved.
# ---------------------------------------------
# Modified by Zhiqi Li
# ---------------------------------------------
import os.path as osp
import pickle
import shutil
import tempfile
import time
import mmcv
import torch
... | 5,960 | 33.656977 | 79 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/projects/mmdet3d_plugin/apis/mmdet_train.py | # ---------------------------------------------
# Copyright (c) OpenMMLab. All rights reserved.
# ---------------------------------------------
# Modified by Zhiqi Li
# ---------------------------------------------
import random
import warnings
import numpy as np
import torch
import torch.distributed as dist
from mmc... | 6,885 | 31.027907 | 79 | py |
RoboBEV | RoboBEV-master/zoo/Sparse4D/projects/mmdet3d_plugin/core/evaluation/eval_hooks.py | # Note: Considering that MMCV's EvalHook updated its interface in V1.3.16,
# in order to avoid strong version dependency, we did not directly
# inherit EvalHook but BaseDistEvalHook.
import bisect
import os.path as osp
import mmcv
import torch.distributed as dist
from mmcv.runner import DistEvalHook as BaseDistEvalHo... | 3,603 | 35.77551 | 76 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.