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 |
|---|---|---|---|---|---|---|
location-mode-prediction | location-mode-prediction-main/main_baselines.py | import torch
from utils.dataloader import sp_loc_dataset, collate_fn
from baselines.baselines import baselines
if __name__ == "__main__":
previous_day = 7
source_root = r"./data/"
dataset = "gc"
dataset_train = sp_loc_dataset(source_root, dataset=dataset, data_type="train", previous_day=previous_day... | 1,126 | 44.08 | 120 | py |
location-mode-prediction | location-mode-prediction-main/baselines/baselines.py | import numpy as np
import torch
class baselines:
def __init__(self, train_loader, val_loader, test_loader):
self.train_loader = train_loader
self.val_loader = val_loader
self.test_loader = test_loader
self.persistent_forcast()
self.frequent_forcast()
self.markov_for... | 4,029 | 33.741379 | 116 | py |
location-mode-prediction | location-mode-prediction-main/models/embed.py | import torch
import torch.nn as nn
from torch import Tensor
import math
class PositionalEncoding(nn.Module):
def __init__(self, emb_size: int, dropout: float, maxlen: int = 5000):
super(PositionalEncoding, self).__init__()
den = torch.exp(-torch.arange(0, emb_size, 2) * math.log(10000) / emb_size... | 4,502 | 36.214876 | 118 | py |
location-mode-prediction | location-mode-prediction-main/models/model_mode.py | import torch.nn as nn
import numpy as np
import torch, math
from torch import Tensor
import torch.nn.functional as F
from models.embed import AllEmbedding
class TransEncoderMode(nn.Module):
def __init__(self, config) -> None:
super(TransEncoderMode, self).__init__()
self.d_input = config.base_em... | 3,554 | 32.224299 | 85 | py |
location-mode-prediction | location-mode-prediction-main/models/model.py | import torch.nn as nn
import numpy as np
import torch, math
from torch import Tensor
import torch.nn.functional as F
from models.embed import AllEmbedding
class TransEncoder(nn.Module):
def __init__(self, config) -> None:
super(TransEncoder, self).__init__()
self.d_input = config.base_emb_size
... | 4,203 | 33.743802 | 119 | py |
location-mode-prediction | location-mode-prediction-main/models/RNNs.py | import torch
import torch.nn as nn
from models.embed import AllEmbedding
from models.model import FullyConnected
class RNNs(nn.Module):
"""Baseline LSTM model."""
def __init__(self, config):
super(RNNs, self).__init__()
self.attention = config.attention
self.d_input = config.base_emb_... | 3,388 | 32.22549 | 105 | py |
location-mode-prediction | location-mode-prediction-main/utils/dataloader.py | import pandas as pd
import numpy as np
import geopandas as gpd
from tqdm import tqdm
from pathlib import Path
import pickle as pickle
from shapely import wkt
from joblib import Parallel, delayed
from sklearn.preprocessing import OrdinalEncoder
import os
import torch
from torch.nn.utils.rnn import pad_sequence
import ... | 16,469 | 36.949309 | 115 | py |
location-mode-prediction | location-mode-prediction-main/utils/utils.py | from msilib.schema import Error
import yaml
import random, torch, os
import numpy as np
import pandas as pd
from utils.train import trainNet, test, get_performance_dict
# from utils.train_mobTcast import trainNet_tcast, test_tcast
from utils.train_mode import trainNet_mode, test_mode
from utils.dataloader import sp_l... | 5,020 | 30.980892 | 120 | py |
location-mode-prediction | location-mode-prediction-main/utils/earlystopping.py | import numpy as np
import torch
class EarlyStopping:
"""Early stops the training if validation loss doesn't improve after a given patience."""
def __init__(self, logdir, patience=7, verbose=False, delta=0):
"""
Args:
patience (int): How long to wait after last time validation loss... | 1,966 | 36.113208 | 139 | py |
location-mode-prediction | location-mode-prediction-main/utils/train_mode.py | import sys, os
import pandas as pd
import numpy as np
import torch
from torch.optim.lr_scheduler import StepLR
from sklearn.metrics import f1_score
import time
from transformers import get_linear_schedule_with_warmup
from utils.earlystopping import EarlyStopping
from utils.dataloader import load_pk_file
from utils.... | 9,211 | 30.333333 | 113 | py |
location-mode-prediction | location-mode-prediction-main/utils/train.py | import sys, os
import pandas as pd
import numpy as np
import torch
from torch.optim.lr_scheduler import StepLR
from sklearn.metrics import f1_score
import time
from transformers import get_linear_schedule_with_warmup
from utils.earlystopping import EarlyStopping
from utils.dataloader import load_pk_file
def get_p... | 13,109 | 30.666667 | 113 | py |
dolly | dolly-master/train_dolly.py | # Databricks notebook source
# MAGIC %md
# MAGIC ## Train Dolly
# MAGIC
# MAGIC This fine-tunes EleutherAI Pythia models
# MAGIC (e.g. [pythia-2.8b](https://huggingface.co/EleutherAI/pythia-2.8b),
# MAGIC [pythia-6.9b](https://huggingface.co/EleutherAI/pythia-6.9b), or
# MAGIC [pythia-12b](https://huggingface.co/Eleuth... | 7,919 | 37.446602 | 187 | py |
dolly | dolly-master/training/generate.py | import logging
import re
from typing import List, Tuple
import torch
import numpy as np
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
Pipeline,
PreTrainedModel,
PreTrainedTokenizer,
)
from transformers.utils import is_tf_available
if is_tf_available():
import tensorflow as t... | 9,994 | 40.473029 | 120 | py |
dolly | dolly-master/training/trainer.py | # Copyright 2023 Databricks, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing... | 12,499 | 36.202381 | 146 | py |
IIM | IIM-main/test.py | import os
import torch
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.transforms as standard_transforms
import misc.transforms as own_transforms
import tqdm
from model.locator import Crowd_locator
from misc.utils import *
from PIL import Image, ImageOps
import cv2
from collecti... | 7,046 | 37.508197 | 135 | py |
IIM | IIM-main/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'JHU' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'HR_Net' # optiona... | 1,666 | 28.245614 | 87 | py |
IIM | IIM-main/train.py | import os
import numpy as np
import torch
import datasets
from config import cfg
from importlib import import_module
#------------prepare enviroment------------
seed = cfg.SEED
if seed is not None:
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
os.environ["CUDA_VISIBLE_DEVICES"]... | 756 | 22.65625 | 60 | py |
IIM | IIM-main/trainer.py | import numpy as np
import torch
from torch import optim
from torch.autograd import Variable
from torch.optim.lr_scheduler import StepLR
import torch.nn.functional as F
from model.locator import Crowd_locator
from config import cfg
from misc.utils import *
import datasets
import cv2
from tqdm import tqdm
from misc.compu... | 14,226 | 47.064189 | 188 | py |
IIM | IIM-main/saved_exp_results/FDST-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'FDST' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'H... | 1,684 | 28.561404 | 87 | py |
IIM | IIM-main/saved_exp_results/SHHA-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'SHHA' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'VGG16_FPN' # opt... | 1,671 | 28.333333 | 87 | py |
IIM | IIM-main/saved_exp_results/SHHB-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'SHHB' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'H... | 1,684 | 28.561404 | 87 | py |
IIM | IIM-main/saved_exp_results/SHHA-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'SHHA' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'H... | 1,684 | 28.561404 | 87 | py |
IIM | IIM-main/saved_exp_results/JHU-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'JHU' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'HR_Net' # optiona... | 1,666 | 28.245614 | 87 | py |
IIM | IIM-main/saved_exp_results/JHU-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'JHU' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'VGG16_FPN' # opti... | 1,669 | 28.298246 | 87 | py |
IIM | IIM-main/saved_exp_results/QNRF-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'QNRF' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'VGG16_FPN' # opt... | 1,671 | 28.333333 | 87 | py |
IIM | IIM-main/saved_exp_results/FDST-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'FDST' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'VGG16_FPN' # opt... | 1,671 | 28.333333 | 87 | py |
IIM | IIM-main/saved_exp_results/SHHB-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'SHHB' # dataset selection: NWPU, SHHA, SHHB, QNRF, FDST
__C.NET = 'VGG16_FPN' # opt... | 1,671 | 28.333333 | 87 | py |
IIM | IIM-main/saved_exp_results/QNRF-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'QNRF' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'H... | 1,684 | 28.561404 | 87 | py |
IIM | IIM-main/saved_exp_results/NWPU-VGG16/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'NWPU' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'V... | 1,706 | 29.482143 | 87 | py |
IIM | IIM-main/saved_exp_results/NWPU-HR/config.py | import os
from easydict import EasyDict as edict
import time
import torch
# init
__C = edict()
cfg = __C
#------------------------------TRAIN------------------------
__C.SEED = 3035 # random seed, for reproduction
__C.DATASET = 'NWPU' # dataset selection: GCC, SHHA, SHHB, UCF50, QNRF, WE, Mall, UCSD
__C.NET = 'H... | 1,694 | 28.736842 | 87 | py |
IIM | IIM-main/datasets/basedataset.py | # -*- coding: utf-8 -*-
import torch.utils.data as data
import os
from PIL import Image
import numpy as np
import torch
import math
import json
class Dataset(data.Dataset):
def __init__(self, datasetname, mode, **argv):
self.mode = mode
self.datasetname = datasetname
self.img_path = []
... | 8,083 | 37.495238 | 127 | py |
IIM | IIM-main/datasets/FIXrandaugment.py | # code in this file is adpated from
# https://github.com/ildoonet/pytorch-randaugment/blob/master/RandAugment/augmentations.py
# https://github.com/google-research/fixmatch/blob/master/third_party/auto_augment/augmentations.py
# https://github.com/google-research/fixmatch/blob/master/libml/ctaugment.py
import logging
i... | 7,008 | 25.854406 | 99 | py |
IIM | IIM-main/datasets/__init__.py | # -*- coding: utf-8 -*-
import os
from importlib import import_module
import misc.transforms as own_transforms
import torchvision.transforms as standard_transforms
from . import basedataset
from . import setting
from torch.utils.data import DataLoader
from torch.utils.data import RandomSampler
import pdb
from config i... | 3,750 | 34.72381 | 128 | py |
IIM | IIM-main/datasets/dataset_prepare/prepare_SHHA.py | from PIL import Image
import os
import cv2 as cv
import matplotlib.pyplot as plt
from pylab import plot
import numpy as np
import json
from functions import euclidean_dist, generate_cycle_mask, average_del_min
import scipy.io as scio
import glob
import torch
import torch.nn.functional as F
mode = 'train'
Root = '/med... | 17,041 | 37.040179 | 170 | py |
IIM | IIM-main/datasets/dataset_prepare/prepare_QNRF.py | from PIL import Image
import os
import cv2 as cv
import matplotlib.pyplot as plt
from pylab import plot
import numpy as np
import json
import math
from functions import euclidean_dist, generate_cycle_mask, average_del_min
import scipy.io as scio
import glob
import torch
import torch.nn.functional as F
mode = 'train'
... | 17,624 | 36.183544 | 143 | py |
IIM | IIM-main/datasets/dataset_prepare/functions.py | import numpy as np
def euclidean_dist( test_matrix, train_matrix):
"""
Args:
x: pytorch Variable, with shape [m, d]
y: pytorch Variable, with shape [n, d]
Returns:
dist: pytorch Variable, with shape [m, n]
"""
num_test = test_matrix.shape[0]
num_train = train_matrix.shape[0]
... | 1,305 | 32.487179 | 87 | py |
IIM | IIM-main/datasets/dataset_prepare/scale_map.py | import json
from matplotlib import pyplot as plt
import matplotlib
import os
import random
import torch
from torch.autograd import Variable
import torchvision.transforms as standard_transforms
import misc.transforms as own_transforms
import pandas as pd
import numpy as np
import pdb
from tqdm import tqdm
import cv2 a... | 5,535 | 37.985915 | 103 | py |
IIM | IIM-main/datasets/dataset_prepare/prepare_SHHB.py | from PIL import Image
import os
import cv2 as cv
import matplotlib.pyplot as plt
from pylab import plot
import numpy as np
import json
import math
from functions import euclidean_dist, generate_cycle_mask, average_del_min
import scipy.io as scio
import glob
import torch
import torch.nn.functional as F
mode = 'train'
... | 17,382 | 37.714922 | 170 | py |
IIM | IIM-main/datasets/dataset_prepare/models/CC.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from importlib import import_module
from . import counters
import pdb
class CrowdCounter(nn.Module):
def __init__(self,gpus,model_name):
super(CrowdCounter, self).__init__()
# pdb.set_trace()
ccnet = getattr(getattr... | 1,075 | 25.243902 | 80 | py |
IIM | IIM-main/datasets/dataset_prepare/models/counters/Res50_SCAR.py | import torch.nn as nn
import torch
from torchvision import models
import torch.nn.functional as F
from misc.utils import *
import pdb
# model_path = '../PyTorch_Pretrained/resnet101-5d3b4d8f.pth'
class Res50_SCAR(nn.Module):
def __init__(self, pretrained=True):
super(Res50_SCAR, self).__init__()
... | 6,959 | 31.676056 | 124 | py |
IIM | IIM-main/misc/inflation.py | # -*- coding: utf-8 -*-
import torch
import pdb
import torch. nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import math
import numpy
class inflation(nn.Module):
def __init__(self,K=15,stride=1,padding=None):
super(inflation,self).__init__()
weight = numpy.zeros((K,K))
t = (K-1)/2... | 1,144 | 25.627907 | 107 | py |
IIM | IIM-main/misc/utils.py | import os
import sys
import math
import numpy as np
import time
import random
import shutil
import cv2
from PIL import Image
import pdb
import torch
from torch import nn
import torchvision.utils as vutils
import torchvision.transforms as standard_transforms
def read_pred_and_gt(pred_file,gt_file):
# read pred
... | 12,051 | 32.949296 | 169 | py |
IIM | IIM-main/misc/transforms.py | import numbers
import random
import numpy as np
from PIL import Image, ImageOps, ImageFilter
from config import cfg
import torch
import numpy
import pdb
import cv2
from torchvision.transforms import functional as TrF
from misc import inflation
class ProcessSub(object):
def __init__(self,T=0.1,K=51):
self.T... | 5,324 | 28.91573 | 105 | py |
IIM | IIM-main/model/locator.py | from model.HR_Net.seg_hrnet import get_seg_model
from model.VGG.VGG16_FPN import VGG16_FPN
import torch.nn as nn
import torch.nn.functional as F
import torch
import numpy as np
from model.PBM import BinarizedModule
from torchvision import models
class Crowd_locator(nn.Module):
def __init__(self, net_name, gpu_id,... | 3,281 | 34.290323 | 147 | py |
IIM | IIM-main/model/PBM.py | import torch
from torch.autograd import Function
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
class BinarizedF(Function):
@staticmethod
def forward(ctx, input, threshold):
ctx.save_for_backward(input,threshold)
a = torch.ones_like(input).cuda()
b = torch.ze... | 3,936 | 27.948529 | 108 | py |
IIM | IIM-main/model/VGG/VGG16_FPN.py | from torchvision import models
import sys
import torch.nn.functional as F
import torch.nn as nn
from misc.utils import *
mode = 'Vgg_bn'
class VGG16_FPN(nn.Module):
def __init__(self, pretrained=True):
super(VGG16_FPN, self).__init__()
if mode == 'Vgg_bn':
vgg = models.vgg16_bn(pretrai... | 6,263 | 31.455959 | 124 | py |
IIM | IIM-main/model/HR_Net/seg_hrnet.py | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Ke Sun (sunk@mail.ustc.edu.cn)
# ------------------------------------------------------------------------------
from __future__ import absolute_import
from __future_... | 18,467 | 36.689796 | 93 | py |
VidLanKD | VidLanKD-main/vlm/run_glue.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 30,293 | 43.16035 | 150 | py |
VidLanKD | VidLanKD-main/vlm/run_vlm_distributed.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 30,750 | 41.182442 | 161 | py |
VidLanKD | VidLanKD-main/vlm/model.py | import math
import torch
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss, MSELoss, SmoothL1Loss
from torch import nn
from transformers import *
from transformers.modeling_bert import BertOnlyMLMHead
from vteacher.loss import *
BertLayerNorm = torch.nn.LayerNorm
# The GLUE function is copied f... | 8,758 | 33.214844 | 123 | py |
VidLanKD | VidLanKD-main/vlm/data.py | import copy
import os
import random
import h5py
import torch
from torch.utils.data import DataLoader, Dataset
import tqdm
class CoLDataset(Dataset):
IGNORE_ID = -100
sent_strategy = 'first'
def __init__(self, file_path, tokenizer_name, tokenizer, block_size=512,
split_sent=False, verbos... | 3,728 | 30.075 | 120 | py |
VidLanKD | VidLanKD-main/vlm/run_lm_distributed.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 25,616 | 40.586039 | 161 | py |
VidLanKD | VidLanKD-main/vlm/run_glue_epochs.py | import argparse
import math
import os
from pathlib import Path
from pprint import pprint
import subprocess
import threading
import time
import torch
parser = argparse.ArgumentParser()
parser.add_argument(
"--load", default=None, type=str,
help="The model loaded, e.g., snap/vlm/wiki103_small"
)
parser.add_argu... | 3,812 | 25.296552 | 78 | py |
VidLanKD | VidLanKD-main/vteacher/run_vlm_distributed.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 32,117 | 42.111409 | 161 | py |
VidLanKD | VidLanKD-main/vteacher/loss.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
class NSTLoss(nn.Module):
'''
Like What You Like: Knowledge Distill via Neuron Selectivity Transfer
https://arxiv.org/pdf/1707.01219.pdf
'''
def __init__(self):
super(NSTLoss, self).__init__()
def forward(self... | 8,872 | 37.746725 | 108 | py |
VidLanKD | VidLanKD-main/vteacher/model.py | import math
import torch
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss, MSELoss, SmoothL1Loss
from torch import nn
from transformers import *
from transformers.modeling_bert import *
from vteacher.loss import paired_hinge_rank_loss, batchwise_hinge_rank_loss, contrastive_loss
BertLayerNorm = ... | 17,600 | 35.365702 | 198 | py |
VidLanKD | VidLanKD-main/vteacher/data.py | import copy
import os
import random
import json
import math
import time
import glob
import numpy as np
import h5py
import torch
from torch.utils.data import DataLoader, Dataset
import tqdm
feature_dir = '.'
feature_dir_data = '.'
def find_overlap(s1, s2):
for i in range(len(s1)):
test1, test2 = s1[i:], s... | 10,672 | 38.238971 | 137 | py |
VidLanKD | VidLanKD-main/vteacher/file_utils.py | import os
import logging
import shutil
import tempfile
import json
from urllib.parse import urlparse
from pathlib import Path
from typing import Optional, Tuple, Union, IO, Callable, Set
from hashlib import sha256
from functools import wraps
from tqdm import tqdm
import boto3
from botocore.exceptions import ClientErr... | 7,838 | 32.643777 | 98 | py |
dybm | dybm-master/src/benchmarks/CompareLSTMandDyBM.py | # (C) Copyright IBM Corp. 2016
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 12,349 | 33.497207 | 95 | py |
dybm | dybm-master/src/pydybm/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# pydybm documentation build configuration file, created by
# sphinx-quickstart on Sat Oct 7 01:24:11 2017.
#
# 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
# aut... | 6,040 | 28.758621 | 81 | py |
plix | plix-main/setup.py | from setuptools import setup, find_packages
with open("README.md") as readme_file:
README = readme_file.read()
setup_args = dict(
name="plixkws",
version="1.0",
description="Plug-and-Play Multilingual Few-shot Spoken Words Recognition",
long_description_content_type="text/markdown",
long_descr... | 855 | 26.612903 | 97 | py |
plix | plix-main/test_model.py | import torch
from plixkws import model, util
fws_model = model.load(encoder_name="base", language="en", device="cpu")
support = {
"paths": ["./test_clips/aandachtig.wav", "./test_clips/stroom.wav",
"./test_clips/persbericht.wav", "./test_clips/klinkers.wav",
"./test_clips/zinsbouw.wav"],
"labe... | 857 | 36.304348 | 83 | py |
plix | plix-main/plixkws/protonet.py | import torch
from torch import nn
import torch.nn.functional as F
class ProtoNet(nn.Module):
def __init__(self, backbone: nn.Module):
super().__init__()
self.backbone = backbone
def forward(self, support: dict, query: dict):
"""
ProtoNet forward-pass.
Args:
... | 2,099 | 36.5 | 114 | py |
plix | plix-main/plixkws/model.py |
import os
import wget
import json
from pathlib import Path
import numpy as np
import torch
import torch.nn as nn
from . import backbone as bk
from . import protonet as pt
from . import util
def load(encoder_name: str = "base", language: str = "multi",
models_dir: str = "models", device: str = "cuda"):
... | 1,470 | 30.297872 | 90 | py |
plix | plix-main/plixkws/backbone.py | import torch
from torch import nn
from torchaudio.transforms import MelSpectrogram
import timm
class Backbone(nn.Module):
"""
A feature extractor that produces D-dimensional embeddings from audio samples.
Args:
encoder_name (str): Name of the encoder to initialize.
sample_rate (int):... | 1,374 | 34.25641 | 83 | py |
plix | plix-main/plixkws/util.py | import numpy as np
import librosa
import torch
import torch.nn.functional as F
def pad_or_trim(array, length, *, axis = -1):
"""
Pad or trim the audio array to length.
"""
if torch.is_tensor(array):
if array.shape[axis] > length:
array = array.index_select(dim=axis, index=torch.aran... | 1,536 | 31.702128 | 97 | py |
moc | moc-master/benchmark/python_recoures_dice/cf-dice.py | import csv
import DiCE.dice_ml as dice_ml
from DiCE.dice_ml.utils import helpers # helper functions
import pandas as pd
import os
import tensorflow as tf
import json
import click
import re
import numpy as np
from datetime import datetime
from tensorflow import keras
@click.command()
@click.option('--openmlid', type=st... | 5,019 | 42.275862 | 114 | py |
moc | moc-master/benchmark/python_recoures_dice/cf-recourse.py | import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from recourse import action_set
from recourse import flipset
import click
import os
import json
import tensorflow as tf
from tensorflow import keras
import random
@click.command()
@click.option('--openmlid', help = 'ID of openml... | 3,518 | 38.1 | 147 | py |
PMIndiaSum | PMIndiaSum-main/baselines/tester.py | import torch
import argparse
from tqdm import tqdm
import pandas as pd
from rouge_score import rouge_scorer
import nltk
nltk.download('punkt')
from nltk.tokenize import sent_tokenize
from transformers import MBartForConditionalGeneration, AutoConfig, PreTrainedTokenizerFast
# Required args
parser = argparse.ArgumentP... | 5,004 | 51.135417 | 158 | py |
PMIndiaSum | PMIndiaSum-main/baselines/trainer.py | import datasets
import logging
import os
import sys
import transformers
from dataclasses import dataclass, field
from datasets import load_dataset, load_metric
from transformers import (AutoModelForSeq2SeqLM, AutoTokenizer, DataCollatorForSeq2Seq, EarlyStoppingCallback,
HfArgumentParser, Seq2S... | 8,480 | 52.677215 | 220 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/losses.py | import keras.backend as K
from keras.losses import categorical_crossentropy
def hard_dice_coef(y_true, y_pred, smooth=1e-3):
y_true_f = K.flatten(K.round(y_true[..., 0]))
y_pred_f = K.flatten(K.round(y_pred[..., 0]))
intersection = K.sum(y_true_f * y_pred_f)
return 100. * (2. * intersection + smooth) ... | 2,534 | 33.256757 | 167 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/pred_test.py | import os
from params import args
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
from keras.preprocessing.image import img_to_array, load_img
from keras.applications.imagenet_utils import preprocess_input
from models.model_factory import make_model
from os import path, mkdir, listdir
import numpy as np
np.random.... | 4,419 | 33 | 118 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/resnetv2.py | # -*- coding: utf-8 -*-
"""Inception-ResNet V2 model for Keras.
Model naming and structure follows TF-slim implementation (which has some additional
layers and different number of filters from the original arXiv paper):
https://github.com/tensorflow/models/blob/master/research/slim/nets/inception_resnet_v2.py
Pre-tra... | 16,036 | 40.654545 | 92 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/train.py | import gc
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import os
from params import args
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
from aug.transforms import aug_mega_hardcore
from keras.losses import binary_crossentropy
from keras.utils.training_utils import multi_gpu_model
from datasets.dsb_bin... | 6,151 | 41.136986 | 158 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/pred_oof.py | import os
from params import args
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
from keras.applications.imagenet_utils import preprocess_input
from keras.preprocessing.image import img_to_array, load_img
from models.model_factory import make_model
from os import path, mkdir, listdir
import numpy as np
np.random.s... | 4,714 | 31.517241 | 115 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/resnets.py | # -*- coding: utf-8 -*-
"""
keras_resnet.models._2d
~~~~~~~~~~~~~~~~~~~~~~~
This module implements popular two-dimensional residual models.
"""
import keras.backend
import keras.layers
import keras.models
import keras.regularizers
def ResNet(inputs, blocks, block, include_top=True, classes=1000, numerical_names=Non... | 15,036 | 34.381176 | 167 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/models/xception_padding.py | # -*- coding: utf-8 -*-
"""Xception V1 model for Keras.
On ImageNet, this model gets to a top-1 validation accuracy of 0.790
and a top-5 validation accuracy of 0.945.
Do note that the input image format for this model is different than for
the VGG16 and ResNet models (299x299 instead of 224x224),
and that the input p... | 12,153 | 44.014815 | 151 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/models/unets.py |
from keras import Model, Input
from keras.applications import DenseNet169
from keras.layers import UpSampling2D, Conv2D, BatchNormalization, Activation, concatenate, Add
from keras.utils import get_file
from models.xception_padding import Xception
from resnets import ResNet101, ResNet152, ResNet50
from resnetv2 impor... | 13,036 | 41.190939 | 120 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/datasets/base.py |
import os
import random
import time
from abc import abstractmethod
import cv2
import numpy as np
from keras.applications import imagenet_utils
from keras.preprocessing.image import Iterator, load_img, img_to_array
from params import args
class BaseMaskDatasetIterator(Iterator):
def __init__(self,
... | 4,456 | 37.756522 | 125 | py |
dsb2018_topcoders | dsb2018_topcoders-master/selim/datasets/dsb_binary.py | import random
import os
import cv2
import numpy as np
import pandas as pd
from skimage import measure
from skimage.filters import median
from skimage.morphology import dilation, watershed, square, erosion
from tqdm import tqdm
from datasets.base import BaseMaskDatasetIterator
from params import args
class DSB2018Bin... | 10,391 | 43.987013 | 170 | py |
dsb2018_topcoders | dsb2018_topcoders-master/victor/train_inception_softmax.py | from os import path, mkdir
import numpy as np
np.random.seed(1)
import random
random.seed(1)
import tensorflow as tf
tf.set_random_seed(1)
import timeit
import cv2
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint, LearningRateScheduler #, TensorBoard
from models import get_inception_resnet_... | 17,273 | 40.825666 | 159 | py |
dsb2018_topcoders | dsb2018_topcoders-master/victor/train_densenet_softmax.py | from os import path, mkdir
import numpy as np
np.random.seed(1)
import random
random.seed(1)
import tensorflow as tf
tf.set_random_seed(1)
import timeit
import cv2
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint, LearningRateScheduler #, TensorBoard
from models import get_densenet121_unet_... | 17,213 | 40.680387 | 159 | py |
dsb2018_topcoders | dsb2018_topcoders-master/victor/tune_inception_softmax_final.py | from os import path, mkdir
import numpy as np
np.random.seed(1)
import random
random.seed(1)
import tensorflow as tf
tf.set_random_seed(1)
import timeit
import cv2
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint, LearningRateScheduler #, TensorBoard
from models import get_inception_resnet_... | 15,485 | 39.752632 | 289 | py |
dsb2018_topcoders | dsb2018_topcoders-master/victor/models.py | from keras import backend as K
from keras.models import Model
from keras.layers import Input, BatchNormalization, Conv2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D, concatenate, Concatenate, UpSampling2D, Activation
from keras.losses import categorical_crossentropy
from keras.applications.inception_resnet_v2 import... | 9,130 | 40.130631 | 167 | py |
dsb2018_topcoders | dsb2018_topcoders-master/victor/tune_densenet_softmax_final.py | from os import path, mkdir
import numpy as np
np.random.seed(1)
import random
random.seed(1)
import tensorflow as tf
tf.set_random_seed(1)
import timeit
import cv2
from keras.optimizers import Adam
from keras.callbacks import ModelCheckpoint, LearningRateScheduler #, TensorBoard
from models import get_densenet121_unet_... | 15,669 | 39.595855 | 289 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/bowl_train.py | import torch
import os
import cv2
from scipy.misc import imread
import numpy as np
from utils import get_csv_folds, update_config, get_folds
from config import Config
from dataset.reading_image_provider import ReadingImageProvider, CachingImageProvider, InFolderImageProvider
from dataset.raw_image import RawImageType
... | 4,338 | 35.462185 | 112 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_utils/callbacks.py | import torch
from copy import deepcopy
import os
from tensorboardX import SummaryWriter
from torch.optim.lr_scheduler import _LRScheduler
from bisect import bisect_right
class Callback(object):
"""
Abstract base class used to build new callbacks.
"""
def __init__(self):
self.trainer = None
... | 7,421 | 33.045872 | 134 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_utils/loss.py | import torch
from torch import nn
from torch.nn import functional as F
import torch.nn.functional as F
eps = 1e-3
def dice_round(preds, trues, is_average=True):
preds = torch.round(preds)
return dice_loss(preds, trues, is_average=is_average)
def multi_class_dice_round(preds, trues, is_average=True):
pred... | 3,590 | 30.778761 | 116 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_utils/eval.py | import os
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
# torch.backends.cudnn.benchmark = True
import tqdm
from augmentations.tta import transforms as TTA
from augmentations.transforms import ToTensor
from dataset.neur... | 5,122 | 35.333333 | 137 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_utils/train.py | import os
from collections import defaultdict
import torch
import torch.nn.functional as F
from torch import nn
from torch import optim
from torch.autograd import Variable
from torch.optim.lr_scheduler import ExponentialLR
from torch.utils.data.dataloader import DataLoader as PytorchDataLoader
from tqdm import tqdm
fr... | 15,361 | 43.398844 | 171 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/augmentations/functional.py | import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import numpy as np
import math
from scipy.ndimage.filters import gaussian_filter
from functools import wraps
import torch
import torchvision.transforms.functional as F
def vflip(img):
return cv2.flip(img, 0)
def hflip(img):
return cv2.flip(img, 1)
... | 13,193 | 31.497537 | 117 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/augmentations/tta.py | import numpy as np
import cv2
import os
import torch
from torch.nn import functional as F
class TTAOp:
def __init__(self, sigmoid=True):
self.sigmoid = sigmoid
def __call__(self, model, batch):
forwarded = torch.autograd.Variable(torch.from_numpy(self.forward(batch.numpy())), volatile=True).c... | 2,681 | 22.321739 | 112 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/abstract_model.py | import math
import torch
import os
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
from pytorch_zoo import resnet, vgg, inception
from pytorch_zoo.inplace_abn.models.wider_resnet import init_wider_resnet
from pytorch_zoo.dpn import dpn92
class Upscale:
transposed_con... | 15,796 | 35.995316 | 173 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/inception.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
__all__ = ['Inception3', 'inception_v3']
model_urls = {
# Inception v3 ported from TensorFlow
'inception_v3_google': 'https://download.pytorch.org/models/inception_v3_google-1a9a5a14.pth',
}
def in... | 10,405 | 36.297491 | 101 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/resnet.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/models/r... | 5,831 | 28.604061 | 83 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/vgg.py | import math
import torch.nn as nn
__all__ = [
'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn',
'vgg19_bn', 'vgg19',
]
model_urls = {
'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30ac9.pth',
'vgg13': 'https://download.pytorch.org/models/vgg13-c768596a.pth',
'vgg16':... | 5,063 | 30.849057 | 113 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/unet.py | import math
import torch
import torch.nn as nn
from pytorch_zoo.abstract_model import EncoderDecoder, get_slice, Upscale, UnetDecoderBlock, ConvBottleneck, SumBottleneck, UnetBNDecoderBlock, PathAggregationEncoderDecoder, UnetDoubleDecoderBlock, DPEncoderDecoder
import torch.nn.functional as F
class Unet(EncoderDecode... | 13,942 | 35.692105 | 215 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/resnet38unet.py | import math
import torch
import torch.nn as nn
from pytorch_zoo.abstract_model import EncoderDecoder, get_slice, Upscale, UnetDecoderBlock, ConvBottleneck, SumBottleneck, UnetBNDecoderBlock
import torch.nn.functional as F
class Resnet(EncoderDecoder):
def __init__(self, num_classes, num_channels, encoder_name):
... | 2,432 | 32.328767 | 142 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/inception_resnet_v2.py | import torch
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import os
import sys
__all__ = ['InceptionResNetV2', 'inceptionresnetv2']
model_urls = {
'inceptionresnetv2': 'http://webia.lip6.fr/~cadene/Downloads/inceptionresnetv2-d579a627.pth'
}
class BasicConv2d(nn.Module):
def __init__(self... | 9,887 | 30.692308 | 96 | py |
dsb2018_topcoders | dsb2018_topcoders-master/albu/src/pytorch_zoo/dpn.py | """ PyTorch implementation of DualPathNetworks
Ported to PyTorch by [Ross Wightman](https://github.com/rwightman/pytorch-dpn-pretrained)
Based on original MXNet implementation https://github.com/cypw/DPNs with
many ideas from another PyTorch implementation https://github.com/oyam/pytorch-DPNs.
This implementation is ... | 18,591 | 38.223629 | 109 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.