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
WPAL-network
WPAL-network-master/lib/wpal_net/recog.py
import math import cv2 import numpy as np from utils.blob import img_list_to_blob from config import cfg class ResizedImageTooLargeException(Exception): pass class ResizedSideTooShortException(Exception): pass def _get_image_blob(img, neglect): """Converts an image into a network input. Argument...
5,787
32.651163
93
py
WPAL-network
WPAL-network-master/lib/wpal_net/config.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
6,652
28.30837
82
py
WPAL-network
WPAL-network-master/lib/wpal_net/train.py
#!/usr/bin/env python # -------------------------------------------------------------------- # This file is part of # Weakly-supervised Pedestrian Attribute Localization Network. # # Weakly-supervised Pedestrian Attribute Localization Network # is free software: you can redistribute it and/or modify # it under the ter...
4,383
36.152542
93
py
DiffVAE
DiffVAE-master/neural_network_models/neural_network.py
from keras.layers import Input, Dense, BatchNormalization, Dropout from keras.models import Model from keras import optimizers from keras.utils import np_utils import numpy as np from neural_network_models.base_NeuralNetwork import BaseNeuralNetwork class NeuralNetwork(BaseNeuralNetwork): def __init__(self, ...
2,744
37.125
117
py
DiffVAE
DiffVAE-master/neural_network_models/base_NeuralNetwork.py
from keras.models import load_model def NN_predictions(input_data, neural_network_filename): model = load_model(neural_network_filename) return model.predict(input_data) class BaseNeuralNetwork(): def __init__(self, input_size, num_classes, batch_size, epochs, learning_rate, dropout_probability): ...
963
33.428571
104
py
DiffVAE
DiffVAE-master/autoencoder_models/VAE_models.py
from keras.layers import Input, Dense, BatchNormalization, Lambda, Dropout from keras.models import Model, Sequential from keras import metrics, optimizers import numpy as np from keras import metrics from keras import backend as K import tensorflow as tf from autoencoder_models.base.base_VAE import BaseVAE class D...
5,870
41.23741
117
py
DiffVAE
DiffVAE-master/autoencoder_models/GraphDiffVAE.py
from keras.layers import Input, Lambda, Average, Concatenate from keras.models import Model, Sequential from keras import metrics, optimizers from keras import backend as K from keras.regularizers import l2 import tensorflow as tf import numpy as np from autoencoder_models.base.base_VAE import BaseVAE from autoencoder...
4,042
38.252427
114
py
DiffVAE
DiffVAE-master/autoencoder_models/SimpleAutoEncoder.py
from keras.layers import Input, Dense, BatchNormalization from keras.models import Model, Sequential from keras import optimizers import numpy as np from autoencoder_models.base.base_AutoEncoder import BaseAutoEncoder class SimpleAutoEncoder(BaseAutoEncoder): def __init__(self, original_dim, latent_dim, hidden_l...
3,634
39.842697
117
py
DiffVAE
DiffVAE-master/autoencoder_models/base/gcn_layers.py
from keras import activations, initializers, constraints from keras import regularizers from keras.layers import Dropout from keras.engine import Layer import keras.backend as K #################################################################### #### Code adapted from: https://github.com/tkipf/keras-gcn ######### ###...
4,042
39.43
74
py
DiffVAE
DiffVAE-master/autoencoder_models/base/base_VAE.py
from keras import backend as K import tensorflow as tf from autoencoder_models.base.base_AutoEncoder import BaseAutoEncoder class BaseVAE(BaseAutoEncoder): def __init__(self, original_dim, latent_dim, batch_size, epochs, learning_rate): BaseAutoEncoder.__init__(self, original_dim, latent_dim, batch_size,...
610
37.1875
99
py
DiffVAE
DiffVAE-master/autoencoder_models/base/base_AutoEncoder.py
from keras.models import load_model import numpy as np def get_weights_latent_genes(decoder_filename): decoder = load_model(decoder_filename) decoder_weights = [] sequential_layer = decoder.layers[1] indices = np.arange(0, len(sequential_layer.get_weights()), step=2) for index in indices: ...
1,547
31.25
84
py
DrQA
DrQA-main/drqa/pipeline/drqa.py
#!/usr/bin/env python3 # Copyright 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. """Full DrQA pipeline.""" import torch import regex import heapq import math import time import logging from ...
12,090
37.629393
80
py
DrQA
DrQA-main/drqa/reader/model.py
#!/usr/bin/env python3 # Copyright 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. """DrQA Document Reader model""" import torch import torch.optim as optim import torch.nn.functional as F impo...
18,486
37.275362
80
py
DrQA
DrQA-main/drqa/reader/data.py
#!/usr/bin/env python3 # Copyright 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. """Data processing/loading helpers.""" import numpy as np import logging import unicodedata from torch.utils....
4,043
29.636364
80
py
DrQA
DrQA-main/drqa/reader/layers.py
#!/usr/bin/env python3 # Copyright 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. """Definitions of model layers/NN modules""" import torch import torch.nn as nn import torch.nn.functional as ...
10,175
31.615385
80
py
DrQA
DrQA-main/drqa/reader/rnn_reader.py
#!/usr/bin/env python3 # Copyright 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. """Implementation of the RNN based DrQA reader.""" import torch import torch.nn as nn from . import layers #...
5,168
37.007353
80
py
DrQA
DrQA-main/drqa/reader/vector.py
#!/usr/bin/env python3 # Copyright 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. """Functions for putting examples into torch format.""" from collections import Counter import torch def vec...
4,422
33.554688
74
py
DrQA
DrQA-main/scripts/pipeline/interactive.py
#!/usr/bin/env python3 # Copyright 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. """Interactive interface to full DrQA pipeline.""" import torch import argparse import code import prettytable...
3,782
31.612069
80
py
DrQA
DrQA-main/scripts/pipeline/predict.py
#!/usr/bin/env python3 # Copyright 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. """Run predictions using the full DrQA retriever-reader pipeline.""" import torch import os import time import...
5,081
37.5
80
py
DrQA
DrQA-main/scripts/reader/interactive.py
#!/usr/bin/env python3 # Copyright 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. """A script to run the DrQA reader model interactively.""" import torch import code import argparse import log...
2,622
29.858824
80
py
DrQA
DrQA-main/scripts/reader/predict.py
#!/usr/bin/env python3 # Copyright 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. """A script to make and save model predictions on an input dataset.""" import os import time import torch impo...
4,007
35.108108
80
py
DrQA
DrQA-main/scripts/reader/train.py
#!/usr/bin/env python3 # Copyright 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. """Main DrQA reader training script.""" import argparse import torch import numpy as np import json import os ...
21,645
38.572212
80
py
MSPRL
MSPRL-main/main.py
import json import os import random import time from datetime import timedelta import torch from config import get_config from test import test from train import train from utils.init_util import init_dir, create_valid_data_loader from valid import valid from model import build_net def main(args): print('--------...
2,234
31.391304
83
py
MSPRL
MSPRL-main/test.py
from __future__ import print_function import json import os import time from skimage.metrics import structural_similarity as compare_ssim from skimage.metrics import peak_signal_noise_ratio as compare_psnr import cv2 import torch from PIL import Image from torchvision.transforms import transforms from torchvision.uti...
2,771
30.146067
85
py
MSPRL
MSPRL-main/demo.py
from __future__ import print_function import os import torch from PIL import Image from torchvision.transforms import transforms from torchvision.utils import save_image from model import build_net def test(demo_path, demo_output, net, device): net.eval() with torch.no_grad(): for filename in os.lis...
1,453
31.311111
73
py
MSPRL
MSPRL-main/train.py
from __future__ import division import datetime import json import time import numpy as np import torch from torch.utils.tensorboard import SummaryWriter from torchvision.transforms import transforms from skimage.metrics import peak_signal_noise_ratio as compare_psnr from utils.init_util import * import torch.distrib...
6,079
32.96648
110
py
MSPRL
MSPRL-main/valid.py
from __future__ import print_function import json import os import time from skimage.metrics import structural_similarity as compare_ssim from skimage.metrics import peak_signal_noise_ratio as compare_psnr import cv2 import torch from PIL import Image from torchvision.transforms import transforms import numpy as np f...
1,771
27.126984
80
py
MSPRL
MSPRL-main/utils/init_util.py
import json import math import os import random import time import numpy as np import torch from torch import nn from torch.backends import cudnn from torch.optim.lr_scheduler import CosineAnnealingLR from torch.utils.data import DistributedSampler from dataloader import HalftoneDataSet from model import build_net ...
5,046
38.740157
120
py
MSPRL
MSPRL-main/model/MSPRL.py
from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F class MSPRL(nn.Module): def __init__(self, image_channel, num_blocks=[8, 8, 8, 8]): super(MSPRL, self).__init__() dim = 48 # ------------------------------ Content Aggregation ---------...
4,892
30.365385
113
py
MSPRL
MSPRL-main/dataloader/HalftoneDataSet.py
import os import torch from torch.utils import data from torchvision import transforms from PIL import Image import glob from dataloader.transforms import * def get_data(halftone_path, target_path): halftone_path = glob.glob(halftone_path) target_path = glob.glob(target_path) return halftone_path, target...
1,884
29.403226
85
py
MSPRL
MSPRL-main/dataloader/transforms.py
import random import torchvision.transforms as transforms import torchvision.transforms.functional as F class PairRandomCrop(transforms.RandomCrop): def __call__(self, image, label): i, j, h, w = self.get_params(image, self.size) return F.crop(image, i, j, h, w), F.crop(label, i, j, h, w) clas...
1,531
24.966102
78
py
gameanalysis
gameanalysis-master/gameanalysis/learning.py
"""Package for learning complete games from data The API of this individual module is still unstable and may change as improvements or refinements are made. There are two general game types in this module: learned games and deviation games. Learned games vary by the method, but generally expose methods for computing ...
34,156
33.50202
88
py
FGRL4KG
FGRL4KG-main/evaluate.py
#from nltk.stem.porter import * import torch #from utils import Progbar #from pykp.metric.bleu import bleu from pykp.masked_loss import masked_cross_entropy from utils.statistics import LossStatistics, RewardStatistics import time from utils.time_log import time_since #from nltk.stem.porter import * import pykp import ...
37,462
54.011747
218
py
FGRL4KG
FGRL4KG-main/train_rl.py
import torch import numpy as np import pykp.io import torch.nn as nn from utils.statistics import RewardStatistics from utils.time_log import time_since import time from sequence_generator import SequenceGenerator from utils.report import export_train_and_valid_loss, export_train_and_valid_reward import sys import logg...
19,187
52.747899
220
py
FGRL4KG
FGRL4KG-main/train_predicted_bert.py
import torch import torch.nn as nn import transformers as trf import fastNLP as fnlp import os class BertPredictModel(nn.Module): def __init__(self, from_pretrained: str, vocab=None): super().__init__() self.vocab = vocab # self.bert = fnlp.embeddings.BertEmbedding(vocab, from_pretrai...
13,618
41.827044
135
py
FGRL4KG
FGRL4KG-main/train_ml.py
import torch.nn as nn from pykp.masked_loss import masked_cross_entropy from utils.statistics import LossStatistics from utils.time_log import time_since from evaluate import evaluate_loss import time import math import logging import torch import sys import os from utils.report import export_train_and_valid_loss from ...
17,623
51.924925
439
py
FGRL4KG
FGRL4KG-main/interactive_predict.py
import torch from sequence_generator import SequenceGenerator import config import argparse from preprocess import read_tokenized_src_file from utils.data_loader import load_vocab from pykp.io import build_interactive_predict_dataset, KeyphraseDataset from torch.utils.data import DataLoader import predict import os d...
4,327
35.369748
180
py
FGRL4KG
FGRL4KG-main/beam.py
import torch import penalties import logging class Beam: def __init__(self, size, pad, bos, eos, n_best=1, cuda=False, global_scorer=None, min_length=0, stepwise_penalty=False, block_ngram_repeat=0, exclusion_toke...
11,217
43.515873
160
py
FGRL4KG
FGRL4KG-main/sequence_generator.py
""" Adapted from OpenNMT-py: https://github.com/OpenNMT/OpenNMT-py and seq2seq-keyphrase-pytorch: https://github.com/memray/seq2seq-keyphrase-pytorch """ import sys import torch import pykp import logging from beam import Beam from beam import GNMTGlobalScorer EPS = 1e-8 class SequenceGenerator(object): """Class...
25,883
53.492632
314
py
FGRL4KG
FGRL4KG-main/evaluate_prediction.py
import numpy as np import argparse import config from utils.string_helper import * from collections import defaultdict import os import logging import pykp.io import pickle import torch def check_valid_keyphrases(str_list): num_pred_seq = len(str_list) is_valid = np.zeros(num_pred_seq, dtype=bool) for i, ...
107,983
42.107385
255
py
FGRL4KG
FGRL4KG-main/predict.py
import torch from sequence_generator import SequenceGenerator import logging import config from pykp.io import KeyphraseDataset from torch.utils.data import DataLoader import time from utils.time_log import time_since from evaluate import evaluate_beam_search import pykp.io import sys import argparse from utils.data_lo...
6,177
33.322222
116
py
FGRL4KG
FGRL4KG-main/train.py
import torch import argparse import config import logging import os import json from pykp.io import KeyphraseDataset from pykp.model import Seq2SeqModel from torch.optim import Adam import pykp import train_ml import train_rl from utils.time_log import time_since from utils.data_loader import load_data_and_vocab impo...
7,724
33.181416
156
py
FGRL4KG
FGRL4KG-main/preprocess.py
import argparse from collections import Counter import torch import pickle import pykp.io import config def read_tokenized_src_file(path, remove_eos=True): """ read tokenized source text file and convert them to list of list of words :param path: :param remove_eos: concatenate the words in title and c...
15,444
45.104478
169
py
FGRL4KG
FGRL4KG-main/penalties.py
from __future__ import division import torch class PenaltyBuilder(object): """ Returns the Length and Coverage Penalty function for Beam Search. Args: length_pen (str): option name of length pen cov_pen (str): option name of cov pen """ def __init__(self, cov_pen, length_pen): ...
2,327
27.048193
74
py
FGRL4KG
FGRL4KG-main/pykp/masked_loss.py
import torch import math import logging EPS = 1e-8 def masked_cross_entropy(class_dist, target, trg_mask, trg_lens=None, coverage_attn=False, coverage=None, attn_dist=None, lambda_coverage=0, coverage_loss=False, delimiter_hidden_states=None, orthogonal_loss=False, la...
9,961
43.275556
168
py
FGRL4KG
FGRL4KG-main/pykp/rnn_encoder.py
import logging import torch import torch.nn as nn import math import logging from pykp.masked_softmax import MaskedSoftmax class RNNEncoder(nn.Module): """ Base class for rnn encoder """ def forward(self, src, src_lens, src_mask=None, title=None, title_lens=None, title_mask=None): raise NotImp...
8,270
49.742331
142
py
FGRL4KG
FGRL4KG-main/pykp/rnn_decoder.py
import logging import torch import torch.nn as nn from pykp.attention import Attention import numpy as np from pykp.masked_softmax import MaskedSoftmax import math import logging from pykp.target_encoder import TargetEncoder class RNNDecoder(nn.Module): def __init__(self, vocab_size, embed_size, hidden_size, num_l...
17,127
47.384181
185
py
FGRL4KG
FGRL4KG-main/pykp/dataloader.py
# -*- coding: utf-8 -*- """ Large chunk borrowed from PyTorch DataLoader """ import os __author__ = "Rui Meng" __email__ = "rui.meng@pitt.edu" import torch import torch.multiprocessing as multiprocessing from torch.utils.data.sampler import SequentialSampler, RandomSampler, BatchSampler import collections import re ...
14,457
36.071795
157
py
FGRL4KG
FGRL4KG-main/pykp/model.py
import logging import torch import torch.nn as nn import numpy as np import random import pykp from pykp.mask import GetMask, masked_softmax, TimeDistributedDense from pykp.rnn_encoder import * from pykp.rnn_decoder import RNNDecoder from pykp.target_encoder import TargetEncoder from pykp.attention import Attention fro...
26,114
51.864372
218
py
FGRL4KG
FGRL4KG-main/pykp/reward.py
import numpy as np from utils.string_helper import * from evaluate_prediction import * import torch def sample_list_to_str_2dlist(sample_list, oov_lists, idx2word, vocab_size, eos_idx, delimiter_word, unk_idx=None, replace_unk=False, src_str_list=None, separate_present_absent=False, present_absent_delimiter_word=None...
20,173
56.475783
220
py
FGRL4KG
FGRL4KG-main/pykp/target_encoder.py
import torch import torch.nn as nn from pykp.attention import Attention from pykp.masked_softmax import MaskedSoftmax class TargetEncoder(nn.Module): def __init__(self, embed_size, hidden_size, vocab_size, pad_idx): super(TargetEncoder, self).__init__() self.embed_size = embed_size self.hid...
1,019
31.903226
87
py
FGRL4KG
FGRL4KG-main/pykp/manager.py
import torch import torch.nn as nn class ManagerBasic(nn.Module): def __init__(self, goal_vector_size): super(ManagerBasic, self).__init__() self.goal_vector_size = goal_vector_size present_goal_vector = torch.zeros(self.goal_vector_size) absent_goal_vector = torch.zeros(self.goal_...
1,194
32.194444
87
py
FGRL4KG
FGRL4KG-main/pykp/masked_softmax.py
import torch import torch.nn as nn import torch.nn.functional as F class MaskedSoftmax(nn.Module): def __init__(self, dim): super(MaskedSoftmax, self).__init__() self.dim = dim def forward(self, logit, mask=None): if mask is None: dist = F.softmax(logit - torch.max(logit, d...
1,105
35.866667
107
py
FGRL4KG
FGRL4KG-main/pykp/attention.py
import logging import torch import torch.nn as nn import numpy as np from pykp.masked_softmax import MaskedSoftmax class Attention(nn.Module): def __init__(self, decoder_size, memory_bank_size, coverage_attn, attn_mode): super(Attention, self).__init__() # attention if attn_mode == "concat"...
9,362
51.307263
166
py
FGRL4KG
FGRL4KG-main/pykp/io.py
# -*- coding: utf-8 -*- """ Python File Template Built on the source code of seq2seq-keyphrase-pytorch: https://github.com/memray/seq2seq-keyphrase-pytorch """ import codecs import inspect import itertools import json import re import traceback from collections import Counter from collections import defaultdict import ...
34,911
44.696335
223
py
FGRL4KG
FGRL4KG-main/pykp/mask.py
import torch import numpy as np import torch.nn.functional as F class GetMask(torch.nn.Module): ''' inputs: x: any size outputs:mask: same size as input x ''' def __init__(self, pad_idx=0): super(GetMask, self).__init__() self.pad_idx = pad_idx def forward(self,...
2,287
27.246914
119
py
FGRL4KG
FGRL4KG-main/utils/data_loader.py
import torch import logging from pykp.io import KeyphraseDataset from torch.utils.data import DataLoader def load_vocab(opt): # load vocab logging.info("Loading vocab from disk: %s" % (opt.vocab)) if not opt.custom_vocab_filename_suffix: word2idx, idx2word, vocab = torch.load(opt.vocab + '/vocab.p...
5,914
60.614583
248
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/Train_Custom_Features.py
# This script trains the BiLSTM-CNN-CRF architecture with customly defined features. # You can specify which features the network should use by changing the featureNames-parameter. # Per default, the networks uses tokens and casing as features. # The input data contains a column with POS data, which we can use for trai...
2,893
36.102564
200
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/Train_MultiTask.py
# This file contain an example how to perform multi-task learning using the # BiLSTM-CNN-CRF implementation. # In the datasets variable, we specify two datasets: POS-tagging (unidep_pos) and conll2000_chunking. # The network will then train jointly on both datasets. # The network can on more datasets by adding more ent...
2,327
28.1
157
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/Train_NER_German.py
# This script trains the BiLSTM-CNN-CRF architecture for NER in German using # the GermEval 2014 dataset (https://sites.google.com/site/germeval2014ner/). # The code use the embeddings by Reimers et al. (https://www.ukp.tu-darmstadt.de/research/ukp-in-challenges/germeval-2014/) from __future__ import print_function imp...
2,582
35.380282
162
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/Train_MultiTask_Different_Levels.py
# This file contain an example how to perform multi-task learning on different levels. # In the datasets variable, we specify two datasets: POS-tagging (unidep_pos) and conll2000_chunking. # We pass a special parameter to the network (customClassifier), that allows that task are supervised at different levels. # For th...
2,613
31.675
157
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/Train_Chunking.py
# This script trains the BiLSTM-CNN-CRF architecture for Chunking in English using # the CoNLL 2000 dataset (https://www.clips.uantwerpen.be/conll2000/chunking/). # The code use the embeddings by Komninos et al. (https://www.cs.york.ac.uk/nlp/extvec/) from __future__ import print_function import os import logging impor...
2,695
35.931507
200
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/neuralnets/BiLSTM.py
""" A bidirectional LSTM with optional CRF and character-based presentation for NLP sequence tagging used for multi-task learning. Author: Nils Reimers License: Apache-2.0 """ from __future__ import print_function from util import BIOF1Validation import keras from keras.optimizers import * from keras.models import M...
28,359
43.944532
206
py
emnlp2017-bilstm-cnn-crf
emnlp2017-bilstm-cnn-crf-master/neuralnets/keraslayers/ChainCRF.py
# -*- coding: utf-8 -*- ''' Author: Philipp Gross @ https://github.com/phipleg/keras/blob/crf/keras/layers/crf.py ''' from __future__ import absolute_import import keras from keras import backend as K from keras import regularizers from keras import constraints from keras import initializers from keras.engine import...
14,712
36.822622
133
py
PatchSearch
PatchSearch-main/main_moco_files_dataset_strong_aug.py
import argparse import builtins import math import os import random import shutil import time import warnings from functools import partial import logging from pathlib import Path import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import to...
20,311
39.462151
121
py
PatchSearch
PatchSearch-main/patch_search_iterative_search.py
import re import argparse import os import copy from collections import Counter import time import shutil import torch import torch.nn.functional as F import torch.nn as nn from torch.utils.data import DataLoader, Dataset import torchvision.transforms as transforms import torchvision.datasets as datasets import torch...
25,191
38.4241
183
py
PatchSearch
PatchSearch-main/main_lincls.py
import argparse import builtins import math import os import random import shutil import time import warnings import re from pathlib import Path import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocess...
29,537
41.01707
227
py
PatchSearch
PatchSearch-main/patch_search_poison_classifier.py
import math import argparse import os import random import shutil import time import warnings import glob from functools import partial import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data from torch.utils.data import DataLoader, Da...
20,262
36.316759
204
py
PatchSearch
PatchSearch-main/tools.py
import shutil import logging import os import torch from torch import nn from torchvision import models def get_logger(logpath, filepath, package_files=[], displaying=True, saving=True, debug=False): logger = logging.getLogger() if debug: level = logging.DEBUG else: level = logging.INFO ...
4,053
27.152778
95
py
PatchSearch
PatchSearch-main/vits.py
import math import torch import torch.nn as nn from functools import partial, reduce from operator import mul from timm.models.vision_transformer import VisionTransformer, _cfg from timm.models.layers.helpers import to_2tuple from timm.models.layers import PatchEmbed __all__ = [ 'vit_small', 'vit_base', ...
5,652
39.963768
120
py
PatchSearch
PatchSearch-main/eval_utils.py
import shutil import logging import os import torch from torch import nn from torchvision import models def get_logger(logpath, filepath, package_files=[], displaying=True, saving=True, debug=False): logger = logging.getLogger() if debug: level = logging.DEBUG else: level = logging.INFO ...
3,349
27.87931
95
py
PatchSearch
PatchSearch-main/moco/builder.py
import torch import torch.nn as nn def rand_bbox(size, lam): W, H = size cut_rat = (1. - lam).sqrt() cut_w = (W * cut_rat).to(torch.long) cut_h = (H * cut_rat).to(torch.long) cx = torch.zeros_like(cut_w, dtype=cut_w.dtype).random_(0, W) cy = torch.zeros_like(cut_h, dtype=cut_h.dtype).random_(...
7,335
35.316832
114
py
PatchSearch
PatchSearch-main/moco/loader.py
from PIL import Image, ImageFilter, ImageOps import math import random import torchvision.transforms.functional as tf class TwoCropsTransform: """Take two random crops of one image""" def __init__(self, base_transform1, base_transform2): self.base_transform1 = base_transform1 self.base_transf...
987
25.702703
82
py
PatchSearch
PatchSearch-main/moco/optimizer.py
import torch class LARS(torch.optim.Optimizer): """ LARS optimizer, no rate scaling or weight decay for parameters <= 1D. """ def __init__(self, params, lr=0, weight_decay=0, momentum=0.9, trust_coefficient=0.001): defaults = dict(lr=lr, weight_decay=weight_decay, momentum=momentum, trust_coef...
1,443
37
113
py
RATFM
RATFM-master/RATFM/test.py
import os import warnings import argparse import numpy as np import torch from .utils.metrics import * from .utils.misc import * from .utils.data_sr_road import get_dataloader_sr from .models.RATFM import RATFM from .modules.transformer import build_transformer from .modules.position_encoding import build_position_en...
5,013
42.6
109
py
RATFM
RATFM-master/RATFM/train.py
import os import warnings import numpy as np import argparse import warnings from datetime import datetime import torch import torch.nn as nn import torch.optim as optim import torchvision.transforms as transforms from .utils.metrics import * from .utils.misc import * from .utils.data_sr_road import get_dataloader_sr...
8,163
41.300518
125
py
RATFM
RATFM-master/RATFM/modules/road_1dconv.py
import torch import torch.nn as nn import torch.nn.functional as F class OneD_Block(nn.Module): def __init__(self, in_channels, n_filters): super(OneD_Block, self).__init__() self.deconv1 = nn.Conv2d( in_channels, in_channels // 2, (1, 9), padding=(0, 4) ) self.deconv2 =...
2,219
33.6875
68
py
RATFM
RATFM-master/RATFM/modules/position_encoding.py
import math import torch from torch import nn from ..utils.misc import NestedTensor class PositionEmbeddingSine(nn.Module): """ This is a more standard version of the position embedding, very similar to the one used by the Attention is all you need paper, generalized to work on images. """ def __in...
3,453
38.25
103
py
RATFM
RATFM-master/RATFM/modules/transformer.py
import copy from typing import Optional import torch import torch.nn.functional as F from torch import nn, Tensor class Transformer(nn.Module): def __init__(self, d_model=512, nhead=8, num_encoder_layers=6, num_decoder_layers=6, dim_feedforward=2048, dropout=0.1, activation="relu"...
12,017
41.020979
109
py
RATFM
RATFM-master/RATFM/models/RATFM.py
import torch.nn as nn import torch.nn.functional as F import torch from torchvision.models import vgg19 from torch.nn.parameter import Parameter from torch.utils.data import Dataset from ..utils.misc import get_nested_tensor, NestedTensor from ..modules.road_1dconv import OneD_Block class ResidualBlock(nn.Module): ...
8,159
37.130841
139
py
RATFM
RATFM-master/RATFM/utils/misc.py
import os import subprocess import time from collections import defaultdict, deque import datetime import pickle from typing import Optional, List import numpy as np import matplotlib.pyplot as plt import seaborn as sns import torch import torch.distributed as dist from torch import Tensor # needed due to empty tenso...
9,387
35.529183
166
py
RATFM
RATFM-master/RATFM/utils/data_sr_road.py
import numpy as np import os import math import torch from torch.utils.data import DataLoader from torch.utils import data import random import cv2 from PIL import Image import PIL.ImageOps # import seaborn as sns uppath = os.path.abspath('.') # print(uppath) s_road_path = uppath + '/RATFM/road_map/xian1.png' t_road_p...
4,653
40.185841
182
py
cellpose
cellpose-master/setup.py
import setuptools from setuptools import setup install_deps = ['numpy>=1.20.0', 'scipy', 'natsort', 'tifffile', 'tqdm', 'numba', 'torch>=1.6', 'opencv-python-headless', 'fastremap' ] gui_deps = [ 'pyqtgraph>=0.11.0rc0', ...
1,850
22.43038
52
py
cellpose
cellpose-master/paper/cp_unets.py
import sys, os, time, string, shutil from natsort import natsorted from glob import glob from pathlib import Path import numpy as np import matplotlib.pyplot as plt import mxnet as mx import matplotlib.pyplot as plt from matplotlib import rc import cv2 from scipy import stats from cellpose import models, datasets, util...
19,670
46.745146
270
py
cellpose
cellpose-master/cellpose/resnet_torch.py
import os, sys, time, shutil, tempfile, datetime, pathlib, subprocess import numpy as np import torch import torch.nn as nn from torch import optim import torch.nn.functional as F import datetime from . import transforms, io, dynamics, utils sz = 3 def convbatchrelu(in_channels, out_channels, sz): return nn.Se...
8,856
37.012876
131
py
cellpose
cellpose-master/cellpose/__main__.py
import sys, os, argparse, glob, pathlib, time import subprocess import numpy as np from natsort import natsorted from tqdm import tqdm from cellpose import utils, models, io, core try: from cellpose.gui import gui GUI_ENABLED = True except ImportError as err: GUI_ERROR = err GUI_ENABLED = False ...
19,925
56.423631
176
py
cellpose
cellpose-master/cellpose/core.py
import os, sys, time, shutil, tempfile, datetime, pathlib, subprocess import logging import numpy as np from tqdm import trange, tqdm from urllib.parse import urlparse import tempfile import cv2 from scipy.stats import mode import fastremap from . import transforms, dynamics, utils, plot, metrics import torch # fr...
42,019
44.085837
166
py
cellpose
cellpose-master/cellpose/test_mkl.py
import os, sys os.environ["MKLDNN_VERBOSE"]="1" import numpy as np import time try: import mxnet as mx x = mx.sym.Variable('x') MXNET_ENABLED = True except: MXNET_ENABLED = False def test_mkl(): if MXNET_ENABLED: num_filter = 32 kernel = (3, 3) pad = (1, 1) shape =...
879
23.444444
109
py
cellpose
cellpose-master/cellpose/utils.py
import os, warnings, time, tempfile, datetime, pathlib, shutil, subprocess from tqdm import tqdm from urllib.request import urlopen from urllib.parse import urlparse import cv2 from scipy.ndimage import find_objects, gaussian_filter, generate_binary_structure, label, maximum_filter1d, binary_fill_holes from scipy.spati...
16,017
33.670996
126
py
cellpose
cellpose-master/cellpose/models.py
import os, sys, time, shutil, tempfile, datetime, pathlib, subprocess from pathlib import Path import numpy as np from tqdm import trange, tqdm from urllib.parse import urlparse import torch import logging models_logger = logging.getLogger(__name__) from . import transforms, dynamics, utils, plot from .core import Un...
51,328
48.11866
152
py
cellpose
cellpose-master/cellpose/dynamics.py
import time, os from scipy.ndimage.filters import maximum_filter1d import torch import scipy.ndimage import numpy as np import tifffile from tqdm import trange from numba import njit, float32, int32, vectorize import cv2 import fastremap import logging dynamics_logger = logging.getLogger(__name__) from . import utils...
26,300
33.561104
134
py
cellpose
cellpose-master/cellpose/gui/menus.py
from PyQt5.QtWidgets import QAction from . import io from .. import models from ..io import save_server def mainmenu(parent): main_menu = parent.menuBar() file_menu = main_menu.addMenu("&File") # load processed data loadImg = QAction("&Load image (*.tif, *.png, *.jpg)", parent) loadImg.setShortcut(...
4,885
39.04918
97
py
cellpose
cellpose-master/cellpose/gui/gui.py
import sys, os, pathlib, warnings, datetime, tempfile, glob, time import gc from natsort import natsorted from tqdm import tqdm, trange from PyQt5 import QtGui, QtCore, Qt, QtWidgets from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QScrollBar, QSlider, QComboBox, QGridLayout, QPushButton, QFrame, QCheck...
77,102
42.833428
923
py
cellpose
cellpose-master/cellpose/gui/guiparts.py
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt5.QtGui import QPainter, QPixmap from PyQt5.QtWidgets import QApplication, QRadioButton, QWidget, QDialog, QButtonGroup, QSlider, QStyle, QStyleOptionSlider, QGridLayout, QPushButton, QLabel, QLineEdit, QDialogButtonBox, QComboBox, QCheckBox import pyqtgraph as pg fro...
35,576
40.272622
538
py
cellpose
cellpose-master/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
3,019
31.473118
79
py
UAL-CVPR2020
UAL-CVPR2020-master/SSIM.py
import torch import torch.nn.functional as F from torch.autograd import Variable import numpy as np from math import exp def gaussian(window_size, sigma): gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)]) return gauss/gauss.sum() def create_window(window_size,...
2,639
34.675676
104
py
UAL-CVPR2020
UAL-CVPR2020-master/Adaptor.py
import torch import numpy as np import scipy.io as sio from torch.autograd import Variable import os from function import * import torch.nn as nn from torch.nn.functional import upsample from Spa_downs import * import time from SSIM import * import matplotlib.pyplot as plt names_CAVE_test = [ 'real_and_fake_apple...
6,660
38.64881
191
py
UAL-CVPR2020
UAL-CVPR2020-master/ThreeBranch_3.py
import torch import torch.nn as nn #changed the G generated by itself and add the mask to guide the Infor part class ThreeBranch_Net(nn.Module): def __init__(self, Dim=[3,34,31], Depth=3, KS_1=3, KS_2=3, KS_3=3): super(ThreeBranch_Net, self).__init__() block1_1 = [] block1_2 = [] ...
5,961
37.714286
110
py
UAL-CVPR2020
UAL-CVPR2020-master/Spa_downs.py
import numpy as np import torch import torch.nn as nn class Spa_Downs(nn.Module): ''' http://www.realitypixels.com/turk/computergraphics/ResamplingFilters.pdf ''' def __init__(self, n_planes, factor, kernel_type, phase=0, kernel_width=None, support=None, sigma=None, preserve_size=False): #...
5,468
30.796512
129
py
UAL-CVPR2020
UAL-CVPR2020-master/function.py
import torch import torch.nn as nn import numpy as np class ReshapeTo2D(nn.Module): def __init__(self): super(ReshapeTo2D, self).__init__() def forward(self,x): return torch.reshape(x, (x.shape[0], x.shape[1], x.shape[2]*x.shape[3])) class ReshapeTo3D(nn.Module): def __init__(self): ...
3,331
27.478632
110
py