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
MCUa-Model
MCUa-Model-main/src/networks_N1.py
import numpy as np import torch.nn as nn import torch.nn.functional as F import torchvision class BaseNetwork(nn.Module): def __init__(self, name, channels=1): super(BaseNetwork, self).__init__() self._name = name self._channels = channels def name(self): return self._name ...
3,718
31.622807
103
py
MCUa-Model
MCUa-Model-main/src/models2_N1.py
import time import time import ntpath import datetime import matplotlib.pyplot as plt import torch.optim as optim import torch.nn.functional as F import matplotlib.pyplot as ply from torch.autograd import Variable from torch.utils.data import DataLoader, TensorDataset from sklearn.metrics import roc_curve, auc from skl...
22,897
36.23252
170
py
MCUa-Model
MCUa-Model-main/src/networks2_P5.py
import numpy as np import torch.nn as nn import torch.nn.functional as F import torchvision class BaseNetwork2(nn.Module): def __init__(self, name, channels=1): super(BaseNetwork2, self).__init__() self._name = name self._channels = channels def name(self): return self._name ...
3,678
31.27193
103
py
MCUa-Model
MCUa-Model-main/src/models2_N3.py
import time import time import ntpath import datetime import matplotlib.pyplot as plt import torch.optim as optim import torch.nn.functional as F import matplotlib.pyplot as ply from torch.autograd import Variable from torch.utils.data import DataLoader, TensorDataset from sklearn.metrics import roc_curve, auc from skl...
23,151
36.0432
170
py
MCUa-Model
MCUa-Model-main/src/datasets1.py
import os import glob import torch import numpy as np from PIL import Image, ImageEnhance from torch.utils.data import Dataset from torchvision.transforms import transforms from .patch_extractor import PatchExtractor LABELS = ['Normal', 'Benign', 'InSitu', 'Invasive'] #IMAGE_SIZE = (2048, 1536) PATCH_SIZE = 224 clas...
5,239
34.890411
166
py
MCUa-Model
MCUa-Model-main/src/models_P6.py
import time import time import ntpath import datetime import matplotlib.pyplot as plt import torch.optim as optim import torch.nn.functional as F import matplotlib.pyplot as ply from torch.autograd import Variable from torch.utils.data import DataLoader, TensorDataset from sklearn.metrics import roc_curve, auc from skl...
22,354
35.587561
170
py
vae-npvc
vae-npvc-master/models.py
import pdb # from tensorflow.contrib import slim import tensorflow as tf from util.layers import GaussianLogDensity, GaussianKLD, \ GaussianSampleLayer, lrelu # TODO: # 1. Multi-stream? # 2. Separate MLP & CNN? # (or we can also just use CNN by viewing MLP input as D-channels) # 3. Conditional input as an ...
3,845
31.59322
86
py
vae-npvc
vae-npvc-master/util/mnist.py
import tensorflow as tf from tensorflow.contrib import keras def mnist_batcher_in_tanh_vector( batch_size, capacity=256, min_after_dequeue=128, ): (x, y), (_, _) = keras.datasets.mnist.load_data() x = tf.constant(x) x = tf.cast(x, tf.float32) x = keras.layers.Flatten()(x) / 127.5 - 1. ...
2,442
27.08046
75
py
SAL
SAL-master/code/training/base_training.py
import utils.general as utils import os from datetime import datetime from pyhocon import ConfigFactory import sys import torch import numpy as np import json import logging class BaseTrainRunner(): def __init__(self,**kwargs): if (type(kwargs['conf']) == str): self.conf = ConfigFactory.pars...
8,716
42.80402
166
py
SAL
SAL-master/code/training/sal_training.py
import sys sys.path.append('../code') from utils.plots import plot_surface import torch from training.base_training import BaseTrainRunner import logging import time class SalTrainRunner(BaseTrainRunner): def run(self): timing_log = [] for epoch in range(self.start_epoch,self.nepochs + 2): ...
4,270
45.934066
174
py
SAL
SAL-master/code/datasets/recon_dataset.py
import torch.utils.data as data from utils.general import * import trimesh from trimesh.sample import sample_surface from scipy.spatial import cKDTree from tqdm import tqdm import utils.general as utils class ReconDataSet(data.Dataset): def __init__(self,split,dataset_path,dist_file_name): model = trime...
2,410
32.957746
118
py
SAL
SAL-master/code/datasets/dfaust_dataset.py
import torch.utils.data as data from utils.general import * import utils.general as utils import logging class DFaustDataSet(data.Dataset): def __init__(self,split,dataset_path,dist_file_name,with_gt = False): base_dir = dataset_path self.npyfiles_mnfld = self.get_instance_filenames(base_dir,spli...
2,392
40.982456
130
py
SAL
SAL-master/code/evaluate/evaluate.py
import argparse import sys sys.path.append('../code') import utils.general as utils import os import json import trimesh import utils.general as utils import logging from datasets.dfaust_dataset import DFaustDataSet from datasets.recon_dataset import ReconDataSet import torch from pyhocon import ConfigFactory import ut...
21,265
48.803279
176
py
SAL
SAL-master/code/utils/plots.py
import plotly.graph_objs as go import plotly.offline as offline import torch import numpy as np from skimage import measure import os from tqdm import tqdm import utils.general as utils def get_threed_scatter_trace(points,caption = None,colorscale = None,color = None): # assert points.shape[1] == 3, "3d scatter pl...
14,459
43.767802
155
py
SAL
SAL-master/code/utils/general.py
import os import numpy as np import torch import trimesh import logging from scipy.spatial import cKDTree as KDTree def mkdir_ifnotexists(directory): if not os.path.exists(directory): os.mkdir(directory) def as_mesh(scene_or_mesh): """ Convert a possible scene to a mesh. If conversion occurs,...
6,986
30.615385
103
py
SAL
SAL-master/code/model/network.py
import numpy as np import utils.general as utils import torch.nn as nn import torch import torch.nn.functional as F from torch import distributions as dist def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out class SimplePointnet_VAE(nn.Module): ''' PointNet-based e...
6,434
32.868421
123
py
SAL
SAL-master/code/model/loss.py
from torch import nn import torch import utils.general as utils import numpy as np # class GenLoss(nn.Module): def __init__(self,manifold_pnts_weight): super().__init__() self.manifold_pnts_weight = manifold_pnts_weight class SALLoss(GenLoss): def __init__(self, manifold_pnts_weight,unsigned): ...
1,747
30.781818
140
py
action-segmentation
action-segmentation-master/src/models/test_semimarkov.py
import random import numpy as np import torch from scipy.optimize import linear_sum_assignment from torch.utils.data import Dataset, DataLoader from torch_struct import SemiMarkov, MaxSemiring from models.semimarkov.semimarkov_modules import SemiMarkovModule # device = torch.device("cuda") device = torch.device("cpu...
11,849
33.955752
115
py
action-segmentation
action-segmentation-master/src/models/flow.py
# code from Junxian He, https://github.com/jxhe/struct-learning-with-flow/blob/master/modules/projection.py from __future__ import print_function import math import torch import torch.nn as nn import torch.nn.functional as F class ReLUNet(nn.Module): @classmethod def add_args(cls, parser): parser.add...
4,504
34.472441
107
py
action-segmentation
action-segmentation-master/src/models/model.py
import torch.optim from torch.utils.data import DataLoader from data.corpus import Datasplit def add_training_args(parser): parser.add_argument('--epochs', type=int, default=60) parser.add_argument('--batch_accumulation', type=int, default=1) parser.add_argument('--lr', type=float, default=5e-3) pars...
2,895
32.674419
105
py
action-segmentation
action-segmentation-master/src/models/sequential.py
import tqdm import numpy as np import torch import torch.nn as nn from models.model import Model, make_optimizer, make_data_loader from utils.utils import all_equal from data.corpus import Datasplit class Encoder(nn.Module): @classmethod def add_args(cls, parser): parser.add_argument('--seq_num_layer...
14,671
40.213483
130
py
action-segmentation
action-segmentation-master/src/models/framewise.py
import tqdm import numpy as np import torch import torch.nn as nn from models.model import Model, make_optimizer, make_data_loader from utils.utils import all_equal from models.semimarkov.semimarkov_utils import semimarkov_sufficient_stats from collections import Counter from data.corpus import Datasplit class Fee...
10,396
42.320833
132
py
action-segmentation
action-segmentation-master/src/models/semimarkov/semimarkov_utils.py
import numpy as np import torch from sklearn.mixture import GaussianMixture def labels_to_spans(position_labels, max_k): # position_labels: b x N, LongTensor assert not (position_labels == -1).any(), "position_labels already appear span encoded (have -1)" b, N = position_labels.size() last = position_...
4,658
35.685039
116
py
action-segmentation
action-segmentation-master/src/models/semimarkov/semimarkov.py
import copy import numpy as np import tqdm import time import torch from data.corpus import Datasplit from models.model import Model, make_optimizer, make_data_loader from models.semimarkov.semimarkov_modules import SemiMarkovModule, ComponentSemiMarkovModule from models.semimarkov import semimarkov_utils from utils....
19,890
47.396594
173
py
action-segmentation
action-segmentation-master/src/models/semimarkov/semimarkov_modules.py
from typing import Dict, Set import pickle import numpy as np import torch import torch.nn.functional as F from torch import nn from torch.autograd import Variable from torch.distributions import MultivariateNormal, Poisson from torch.nn.init import xavier_uniform_ from torch_struct import SemiMarkovCRF from models.f...
43,230
43.522142
125
py
action-segmentation
action-segmentation-master/src/data/corpus.py
# modified from slim_mallow by Anna Kukleva, https://github.com/Annusha/slim_mallow import os import copy import json import random import numpy as np import torch from torch.utils.data import Dataset, Sampler from evaluation.accuracy import Accuracy from evaluation.f1 import F1Score from utils.logger import logger ...
31,994
38.745342
149
py
matminer
matminer-master/matminer/featurizers/structure.py
from __future__ import division, unicode_literals, print_function import os import sys import math import json import itertools import warnings from collections import OrderedDict from operator import itemgetter from random import sample from copy import copy from functools import lru_cache import numpy as np import ...
154,271
39.248369
115
py
matminer
matminer-master/matminer/featurizers/tests/test_structure.py
# coding: utf-8 # Copyright (c) Pymatgen Development Team. # Distributed under the terms of the MIT License. from __future__ import unicode_literals, division import os import copy import unittest import csv import json import numpy as np import pandas as pd from multiprocessing import set_start_method from sklearn.ex...
41,657
44.929438
100
py
matminer
matminer-master/matminer/featurizers/utils/cgcnn.py
import inspect import functools import warnings import numpy as np import random from monty.dev import requires try: import torch from torch.utils.data import Dataset import cgcnn import cgcnn.data as cgcnn_data from cgcnn.data import AtomInitializer from cgcnn.model import CrystalGraphConvNet ...
8,242
41.932292
80
py
matminer
matminer-master/matminer/featurizers/utils/tests/test_cgcnn.py
from unittest import TestCase import unittest import os import json import csv from matminer.featurizers.utils.cgcnn import CIFDataWrapper, \ CrystalGraphConvNetWrapper, appropriate_kwargs, AtomCustomArrayInitializer from pymatgen.core import Structure, Lattice try: import cgcnn import torch except ImportEr...
4,312
40.873786
81
py
DeepOD
DeepOD-main/deepod/core/base_networks.py
import importlib import warnings import math import torch import numpy as np from torch.nn.utils import weight_norm from deepod.core.base_transformer_network import TSTransformerEncoder # from deepod.core.base_transformer_network_dev import TSTransformerEncoder from deepod.core.network_utility import _instantiate_class...
22,239
37.949212
113
py
DeepOD
DeepOD-main/deepod/core/base_model.py
# -*- coding: utf-8 -*- """ Base class for deep Anomaly detection models some functions are adapted from the pyod library @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ import numpy as np import torch import random import time from abc import ABCMeta, abstractmethod from scipy.stats import binom ...
13,595
31.218009
111
py
DeepOD
DeepOD-main/deepod/core/base_transformer_network.py
# -*- coding: utf-8 -*- """ Transformer structure adapted from https://github.com/gzerveas/mvts_transformer """ import math import torch from typing import Optional, Any, Union, Callable from torch.nn.modules import TransformerEncoderLayer from torch.nn import functional as F from torch import Tensor from deepod.core...
17,235
44.357895
159
py
DeepOD
DeepOD-main/deepod/core/transformer/embed.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.utils import weight_norm import math class PositionalEmbedding(nn.Module): def __init__(self, d_model, max_len=5000): super(PositionalEmbedding, self).__init__() # Compute the positional encodings once in log space. ...
6,401
35.793103
114
py
DeepOD
DeepOD-main/deepod/core/transformer/selfattention_family.py
import torch import torch.nn as nn import numpy as np from math import sqrt # from reformer_pytorch import LSHSelfAttention from einops import rearrange, repeat class DSAttention(nn.Module): '''De-stationary Attention''' def __init__(self, mask_flag=True, factor=5, scale=None, attention_dropout=0.1, output_a...
12,759
38.021407
137
py
DeepOD
DeepOD-main/deepod/model_selection/fmms.py
# -*- coding: utf-8 -*- """ Factorization Machine-based Unsupervised Model Selection Method @Author: Ruyi Zhang & Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ import torch import torch.utils.data as Data import numpy as np from deepod.model_selection.gene_feature import generate_meta_features from sklea...
7,894
31.356557
109
py
DeepOD
DeepOD-main/deepod/models/repen.py
# -*- coding: utf-8 -*- """ Representation learning-based unsupervised/weakly-supervised anomaly detection PyTorch's implementation this script is partially adapted from the official keras's implementation https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FGuansongPang%2Fdeep-outlier-detection&sa=D&sntz=1&usg=AOvV...
9,212
38.711207
138
py
DeepOD
DeepOD-main/deepod/models/devnet.py
# -*- coding: utf-8 -*- """ Deep anomaly detection with deviation networks. PyTorch's implementation @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import get_network from torch.utils.data import DataLoader, TensorDatase...
7,510
33.934884
102
py
DeepOD
DeepOD-main/deepod/models/dsad.py
# -*- coding: utf-8 -*- """ One-class classification this is partially adapted from https://github.com/lukasruff/Deep-SAD-PyTorch (MIT license) @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import get_network from torch...
8,482
32.266667
102
py
DeepOD
DeepOD-main/deepod/models/rca.py
""" RCA: A Deep Collaborative Autoencoder Approach for Anomaly Detection this script is partially adapted from https://hub.nuaa.cf/illidanlab/RCA @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import MLPnet from tqdm imp...
7,861
30.198413
95
py
DeepOD
DeepOD-main/deepod/models/feawad.py
# -*- coding: utf-8 -*- """ Feature Encoding with AutoEncoders for Weakly-supervised Anomaly Detection PyTorch's implementation @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import get_network from torch.utils.data impo...
7,417
33.826291
102
py
DeepOD
DeepOD-main/deepod/models/icl.py
# -*- coding: utf-8 -*- """ Anomaly Detection for Tabular Data with Internal Contrastive Learning this script is partially adapted from the supplementary material in https://openreview.net/forum?id=_hszZbt46bT @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseD...
9,573
32.950355
107
py
DeepOD
DeepOD-main/deepod/models/dif.py
# -*- coding: utf-8 -*- """ Deep isolation forest for anomaly detection @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from sklearn.utils import check_array from sklearn.preprocessing import StandardScaler from sklearn.ensemble import IsolationForest from deepod.core.base_model import BaseDeepAD ...
13,547
36.738162
118
py
DeepOD
DeepOD-main/deepod/models/rdp.py
# -*- coding: utf-8 -*- """ Random distance prediction-based anomaly detection this script is partially adapted from https://github.com/billhhh/RDP @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import MLPnet from torch....
4,764
32.794326
95
py
DeepOD
DeepOD-main/deepod/models/goad.py
# -*- coding: utf-8 -*- """ Classification-based anomaly detection this script is partially adapted from https://github.com/lironber/GOAD License: https://github.com/lironber/GOAD/blob/master/LICENSE @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from...
6,604
32.871795
115
py
DeepOD
DeepOD-main/deepod/models/prenet.py
# -*- coding: utf-8 -*- """ Weakly-supervised anomaly detection by pairwise relation prediction task @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import LinearBlock, get_network import torch import numpy as np class ...
7,979
31.704918
110
py
DeepOD
DeepOD-main/deepod/models/_local_test_.py
from deepod.models import * from sklearn.metrics import roc_auc_score import numpy as np import torch import pandas as pd from deepod.utils.utility import cal_metrics if __name__ == '__main__': device = 'cuda' if torch.cuda.is_available() else 'cpu' # # # # random data # x1 = np.random.rand(10, 1) # ...
4,228
33.663934
100
py
DeepOD
DeepOD-main/deepod/models/slad.py
""" scale learning-based deep anomaly detection @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import MLPnet, LinearBlock from torch.utils.data import DataLoader, TensorDataset import numpy as np import torch.nn.function...
10,063
34.814947
108
py
DeepOD
DeepOD-main/deepod/models/dsvdd.py
# -*- coding: utf-8 -*- """ One-class classification @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.base_networks import get_network from torch.utils.data import DataLoader import torch class DeepSVDD(BaseDeepAD): """ Deep One-c...
6,642
31.886139
100
py
DeepOD
DeepOD-main/deepod/models/neutral.py
# -*- coding: utf-8 -*- """ Neural Transformation Learning-based Anomaly Detection this script is partially adapted from https://github.com/boschresearch/NeuTraL-AD (AGPL-3.0 license) @Author: Hongzuo Xu <hongzuoxu@126.com, xuhongzuo13@nudt.edu.cn> """ from deepod.core.base_model import BaseDeepAD from deepod.core.bas...
6,206
30.994845
100
py
DeepOD
DeepOD-main/deepod/test/test_icl.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,663
37.27027
81
py
DeepOD
DeepOD-main/deepod/test/test_goad.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,655
37.216216
81
py
DeepOD
DeepOD-main/deepod/test/test_dsad.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
8,418
39.475962
93
py
DeepOD
DeepOD-main/deepod/test/test_slad.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,648
37.168919
81
py
DeepOD
DeepOD-main/deepod/test/test_neutral.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,652
37.195946
81
py
DeepOD
DeepOD-main/deepod/test/test_rdp.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,645
37.148649
81
py
DeepOD
DeepOD-main/deepod/test/test_dsvdd.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
7,274
39.642458
100
py
DeepOD
DeepOD-main/deepod/test/test_rca.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
5,661
37.256757
81
py
DeepOD
DeepOD-main/deepod/test/test_dif.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
6,867
38.930233
89
py
DeepOD
DeepOD-main/deepod/test/test_devnet.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
7,408
38.620321
107
py
DeepOD
DeepOD-main/deepod/test/test_repen.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest import pandas as pd # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy...
6,862
38.67052
97
py
DeepOD
DeepOD-main/deepod/test/test_feawad.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
7,311
38.101604
81
py
DeepOD
DeepOD-main/deepod/test/test_prenet.py
# -*- coding: utf-8 -*- from __future__ import division from __future__ import print_function import os import sys import unittest # noinspection PyProtectedMember from numpy.testing import assert_allclose from numpy.testing import assert_array_less from numpy.testing import assert_equal from numpy.testing import ass...
7,068
37.840659
83
py
YOLOF
YOLOF-master/setup.py
from setuptools import find_packages, setup import torch torch_ver = [int(x) for x in torch.__version__.split(".")[:2]] assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3" setup( name="yolof", version="0.1.0", author="Chensnathan", url="https://github.com/chensnathan/YOLOF", description="Code fo...
422
25.4375
62
py
YOLOF
YOLOF-master/tools/train_net.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. """ Detection Training Script. This scripts reads a given config file and runs the training or evaluation. It is an entry point that is made to train standard models in detectron2. In order to let one script support training of many models, this...
8,298
34.165254
79
py
YOLOF
YOLOF-master/yolof/data/dataset_mapper.py
from collections import deque import copy import logging from typing import Optional, List, Union import numpy as np import torch from detectron2.config import configurable, CfgNode from detectron2.data import transforms as T from detectron2.data import detection_utils as utils from detectron2.data.dataset_mapper imp...
13,794
41.446154
79
py
YOLOF
YOLOF-master/yolof/modeling/box_regression.py
import math from typing import Tuple import torch _DEFAULT_SCALE_CLAMP = math.log(1000.0 / 16) @torch.jit.script class YOLOFBox2BoxTransform(object): """ The box-to-box transform defined in R-CNN. The transformation is parameterized by 4 deltas: (dx, dy, dw, dh). The transformation scales the box's ...
5,283
39.335878
79
py
YOLOF
YOLOF-master/yolof/modeling/uniform_matcher.py
import numpy as np import torch from torch import nn def box_xyxy_to_cxcywh(x): x0, y0, x1, y1 = x.unbind(-1) b = [(x0 + x1) / 2, (y0 + y1) / 2, (x1 - x0), (y1 - y0)] return torch.stack(b, dim=-1) class UniformMatcher(nn.Module): """ Uniform Matching between the anchors and gt boxes, wh...
3,887
33.714286
76
py
YOLOF
YOLOF-master/yolof/modeling/utils.py
from functools import partial import torch.nn as nn from detectron2.layers import (BatchNorm2d, NaiveSyncBatchNorm, FrozenBatchNorm2d) from detectron2.utils import env def get_norm(norm, out_channels, **kwargs): """ Args: norm (str or callable): either one of BN, SyncB...
1,656
27.084746
71
py
YOLOF
YOLOF-master/yolof/modeling/encoder.py
from typing import List from fvcore.nn import c2_xavier_fill import torch import torch.nn as nn from detectron2.layers import ShapeSpec from .utils import get_activation, get_norm class DilatedEncoder(nn.Module): """ Dilated Encoder for YOLOF. This module contains two types of components: - th...
4,521
36.683333
79
py
YOLOF
YOLOF-master/yolof/modeling/decoder.py
import math from typing import Tuple import torch import torch.nn as nn from .utils import get_activation, get_norm class Decoder(nn.Module): """ Head Decoder for YOLOF. This module contains two types of components: - A classification head with two 3x3 convolutions and one classific...
4,423
39.218182
79
py
YOLOF
YOLOF-master/yolof/modeling/yolof.py
import copy import logging import numpy as np from typing import Dict, List, Tuple import torch from fvcore.nn import sigmoid_focal_loss_jit, giou_loss from torch import Tensor, nn import torch.distributed as dist from torchvision.ops.boxes import box_iou from detectron2.config import configurable from detectron2.data...
22,871
40.966972
79
py
YOLOF
YOLOF-master/yolof/modeling/backbone/darknet.py
import logging import torch import torch.nn as nn import torch.nn.functional as F from detectron2.modeling.backbone import Backbone, BACKBONE_REGISTRY from detectron2.layers import ShapeSpec from ..utils import get_norm try: from mish_cuda import MishCuda as Mish except Exception: logger = logging.getLogger...
11,903
28.392593
75
py
bert-nmt
bert-nmt-master/setup.py
#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from setupt...
1,894
27.712121
78
py
bert-nmt
bert-nmt-master/generate.py
#!/usr/bin/env python3 -u # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Trans...
7,827
38.938776
107
py
bert-nmt
bert-nmt-master/hubconf.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from fairseq.models.transformer im...
1,668
30.490566
79
py
bert-nmt
bert-nmt-master/eval_lm.py
#!/usr/bin/env python3 -u # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Eval...
8,070
34.712389
118
py
bert-nmt
bert-nmt-master/interactive.py
#!/usr/bin/env python3 -u # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Trans...
7,593
34.820755
103
py
bert-nmt
bert-nmt-master/generator.py
#!/usr/bin/env python3 -u # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from col...
8,776
39.447005
143
py
bert-nmt
bert-nmt-master/train.py
#!/usr/bin/env python3 -u # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. """ Train...
11,920
36.724684
105
py
bert-nmt
bert-nmt-master/scripts/average_checkpoints.py
#!/usr/bin/env python3 # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argp...
5,408
36.825175
134
py
bert-nmt
bert-nmt-master/tests/test_train.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import contextlib from io import S...
4,799
35.363636
94
py
bert-nmt
bert-nmt-master/tests/test_average_checkpoints.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import collections import os impor...
4,603
30.319728
80
py
bert-nmt
bert-nmt-master/tests/test_sequence_scorer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argparse import unittest i...
4,057
33.389831
78
py
bert-nmt
bert-nmt-master/tests/utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argparse import torch from...
7,550
30.860759
101
py
bert-nmt
bert-nmt-master/tests/test_binaries.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import contextlib from io import S...
21,672
38.120939
112
py
bert-nmt
bert-nmt-master/tests/test_concat_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest import torch from...
2,051
29.626866
78
py
bert-nmt
bert-nmt-master/tests/test_noising.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest from typing import...
19,887
36.595463
87
py
bert-nmt
bert-nmt-master/tests/test_backtranslation_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest import torch fro...
4,140
33.798319
90
py
bert-nmt
bert-nmt-master/tests/test_sequence_generator.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argparse import unittest i...
10,700
40.476744
96
py
bert-nmt
bert-nmt-master/tests/test_label_smoothing.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import argparse import copy import...
4,247
40.647059
101
py
bert-nmt
bert-nmt-master/tests/test_convtbc.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import unittest from ...
1,787
34.058824
102
py
bert-nmt
bert-nmt-master/tests/test_token_block_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest import torch fro...
3,078
37.012346
89
py
bert-nmt
bert-nmt-master/tests/test_multi_corpus_sampled_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest from collections i...
3,213
31.795918
79
py
bert-nmt
bert-nmt-master/tests/test_dictionary.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import tempfile import unittest i...
1,971
26.013699
80
py
bert-nmt
bert-nmt-master/tests/test_utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import unittest import torch fro...
2,239
25.046512
78
py
bert-nmt
bert-nmt-master/tests/test_character_token_embedder.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import unittest from...
1,764
35.020408
96
py
bert-nmt
bert-nmt-master/fairseq/checkpoint_utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import OrderedDic...
12,633
36.713433
123
py
bert-nmt
bert-nmt-master/fairseq/utils.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from collections import defaultdic...
10,749
31.874618
111
py
bert-nmt
bert-nmt-master/fairseq/sequence_scorer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import torch import sys from fair...
4,364
36.307692
107
py