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
SSeg
SSeg-master/loss.py
""" Loss.py """ import logging import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from config import cfg def get_loss(args): """ Get the criterion based on the loss function args: commandline arguments return: criterion, criterion_val """ if args.img_wt_los...
6,799
34.602094
99
py
SSeg
SSeg-master/config.py
""" # Code adapted from: # https://github.com/facebookresearch/Detectron/blob/master/detectron/core/config.py Source License # Copyright (c) 2017-present, Facebook, 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 obta...
4,003
31.032
90
py
SSeg
SSeg-master/demo.py
import os import sys import argparse from PIL import Image import numpy as np import cv2 import torch from torch.backends import cudnn import torchvision.transforms as transforms import network from optimizer import restore_snapshot from datasets import cityscapes from config import assert_and_infer_cfg parser = arg...
2,091
32.741935
140
py
SSeg
SSeg-master/eval.py
""" Evaluation Script Support Two Modes: Pooling based inference and sliding based inference Pooling based inference is simply whole image inference. """ import os import logging import sys import argparse import re import queue import threading from math import ceil from datetime import datetime from tqdm import tqdm ...
21,561
34.580858
94
py
SSeg
SSeg-master/train.py
""" training code """ from __future__ import absolute_import from __future__ import division import argparse import logging import os import torch #from apex import amp from config import cfg, assert_and_infer_cfg from utils.misc import AverageMeter, prep_experiment, evaluate_eval, fast_hist import datasets import los...
12,946
39.713836
100
py
SSeg
SSeg-master/optimizer.py
""" Pytorch Optimizer and Scheduler Related Task """ import math import logging import torch from torch import optim from config import cfg def get_optimizer(args, net): """ Decide Optimizer (Adam or SGD) """ param_groups = net.parameters() if args.sgd: optimizer = optim.SGD(param_groups,...
3,394
33.642857
92
py
SSeg
SSeg-master/datasets/kitti.py
""" KITTI Dataset Loader http://www.cvlibs.net/datasets/kitti/eval_semseg.php?benchmark=semantics2015 """ import os import sys import numpy as np from PIL import Image from torch.utils import data import logging import datasets.uniform as uniform import datasets.cityscapes_labels as cityscapes_labels import json from ...
9,775
34.809524
133
py
SSeg
SSeg-master/datasets/sampler.py
""" # Code adapted from: # https://github.com/pytorch/pytorch/blob/master/torch/utils/data/distributed.py # # BSD 3-Clause License # # Copyright (c) 2017, # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions ar...
4,347
38.527273
118
py
SSeg
SSeg-master/datasets/uavid.py
""" Mapillary Dataset Loader """ from PIL import Image from torch.utils import data import os import numpy as np import json import datasets.uniform as uniform from config import cfg num_classes = 8 ignore_label = 255 root = cfg.DATASET.UAVID_DIR config_fn = os.path.join(root, 'config.json') id_to_ignore_or_group = {}...
6,702
33.551546
86
py
SSeg
SSeg-master/datasets/cityscapes.py
""" Cityscapes Dataset Loader """ import logging import json import os import numpy as np from PIL import Image from torch.utils import data import torchvision.transforms as transforms import datasets.uniform as uniform import datasets.cityscapes_labels as cityscapes_labels from config import cfg trainid_to_name = c...
19,309
38.488753
100
py
SSeg
SSeg-master/datasets/nullloader.py
""" Null Loader """ import numpy as np import torch from torch.utils import data num_classes = 19 ignore_label = 255 class NullLoader(data.Dataset): """ Null Dataset for Performance """ def __init__(self,crop_size): self.imgs = range(200) self.crop_size = crop_size def __getitem__...
576
23.041667
158
py
SSeg
SSeg-master/datasets/camvid.py
""" Camvid Dataset Loader """ import os import sys import numpy as np from PIL import Image from torch.utils import data import logging import datasets.uniform as uniform import json from config import cfg # trainid_to_name = cityscapes_labels.trainId2name # id_to_trainid = cityscapes_labels.label2trainid num_classe...
10,286
35.349823
133
py
SSeg
SSeg-master/datasets/__init__.py
""" Dataset setup and loaders """ from datasets import cityscapes from datasets import mapillary from datasets import kitti from datasets import camvid from datasets import uavid import torchvision.transforms as standard_transforms import transforms.joint_transforms as joint_transforms import transforms.transforms as ...
12,145
40.172881
133
py
SSeg
SSeg-master/datasets/mapillary.py
""" Mapillary Dataset Loader """ from PIL import Image from torch.utils import data import os import numpy as np import json import datasets.uniform as uniform from config import cfg num_classes = 65 ignore_label = 65 root = cfg.DATASET.MAPILLARY_DIR config_fn = os.path.join(root, 'config.json') id_to_ignore_or_group ...
6,713
33.430769
86
py
SSeg
SSeg-master/network/Resnet.py
""" # Code Adapted from: # https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py # # BSD 3-Clause License # # Copyright (c) 2017, # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are me...
8,386
31.890196
90
py
SSeg
SSeg-master/network/wider_resnet.py
""" # Code adapted from: # https://github.com/mapillary/inplace_abn/ # # BSD 3-Clause License # # Copyright (c) 2017, mapillary # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistribution...
14,157
34.752525
87
py
SSeg
SSeg-master/network/deepv3.py
""" # Code Adapted from: # https://github.com/sthalles/deeplab_v3 # # MIT License # # Copyright (c) 2018 Thalles Santos Silva # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restric...
10,730
33.728155
138
py
SSeg
SSeg-master/network/SEresnext.py
""" # Code adapted from: # https://github.com/Cadene/pretrained-models.pytorch # # BSD 3-Clause License # # Copyright (c) 2017, Remi Cadene # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Re...
15,124
36.071078
98
py
SSeg
SSeg-master/network/mynn.py
""" Custom Norm wrappers to enable sync BN, regular BN and for weight initialization """ import torch.nn as nn from config import cfg from apex import amp def Norm2d(in_channels): """ Custom Norm Function to allow flexible switching """ layer = getattr(cfg.MODEL, 'BNFUNC') normalization_layer = la...
1,076
25.925
80
py
SSeg
SSeg-master/network/__init__.py
""" Network Initializations """ import logging import importlib import torch def get_net(args, criterion): """ Get Network Architecture based on arguments provided """ net = get_model(network=args.arch, num_classes=args.dataset_cls.num_classes, criterion=criterion) num_params...
1,130
23.586957
80
py
SSeg
SSeg-master/utils/misc.py
""" Miscellanous Functions """ import sys import re import os import shutil import torch from datetime import datetime import logging from subprocess import call import shlex from tensorboardX import SummaryWriter import numpy as np import torchvision.transforms as standard_transforms import torchvision.utils as vutil...
11,777
37.616393
102
py
SSeg
SSeg-master/utils/my_data_parallel.py
""" # Code adapted from: # https://github.com/pytorch/pytorch/blob/master/torch/nn/parallel/data_parallel.py # # BSD 3-Clause License # # Copyright (c) 2017, # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following condition...
8,606
40.985366
111
py
SSeg
SSeg-master/sdcnet/main.py
#!/usr/bin/env python import argparse import os import numpy as np import shutil import torch import torch.backends.cudnn import torch.nn.parallel import torch.optim import torch.utils.data from tensorboardX import SummaryWriter import cv2 from tqdm import tqdm ### masks warning : RuntimeError: Set changed size duri...
26,977
40.062405
127
py
SSeg
SSeg-master/sdcnet/sdc_aug.py
import os import sys import argparse import cv2 import numpy as np from PIL import Image import shutil import torch import torch.nn as nn from torch.autograd import Variable from models.sdc_net2d import * parser = argparse.ArgumentParser() parser.add_argument('--pretrained', default='', type=str, metavar='PATH', he...
15,478
45.623494
131
py
SSeg
SSeg-master/sdcnet/utility/tools.py
import os import subprocess import time from inspect import isclass class TimerBlock: def __init__(self, title): print(("{}".format(title))) def __enter__(self): self.start = time.clock() return self def __exit__(self, exc_type, exc_value, traceback): self.end = time.clock...
3,701
37.164948
155
py
SSeg
SSeg-master/sdcnet/models/model_utils.py
from __future__ import division from __future__ import print_function import torch.nn as nn def conv2d(channels_in, channels_out, kernel_size=3, stride=1, bias = True): return nn.Sequential( nn.Conv2d(channels_in, channels_out, kernel_size=kernel_size, stride=stride, padding=(kernel_size-1)//2, bias=bias)...
649
39.625
124
py
SSeg
SSeg-master/sdcnet/models/sdc_net2d.py
''' Portions of this code are adapted from: https://github.com/NVIDIA/flownet2-pytorch/blob/master/networks/FlowNetS.py https://github.com/ClementPinard/FlowNetPytorch/blob/master/models/FlowNetS.py ''' from __future__ import division from __future__ import print_function import torch import torch.nn as nn from torch....
9,288
40.842342
119
py
SSeg
SSeg-master/sdcnet/datasets/frame_loader.py
from __future__ import division from __future__ import print_function import os import natsort import numpy as np import cv2 import torch from torch.utils import data from datasets.dataset_utils import StaticRandomCrop class FrameLoader(data.Dataset): def __init__(self, args, root, is_training = False, transfor...
3,766
35.931373
107
py
SSeg
SSeg-master/sdcnet/datasets/dataset_utils.py
from __future__ import division from __future__ import print_function import torch class StaticRandomCrop(object): """ Helper function for random spatial crop """ def __init__(self, size, image_shape): h, w = image_shape self.th, self.tw = size self.h1 = torch.randint(0, h - se...
519
27.888889
79
py
SSeg
SSeg-master/sdcnet/spatialdisplconv_package/test_spatialdisplconv.py
import torch import time from spatialdisplconv import SpatialDisplConv assert torch.cuda.is_available() cuda_device = torch.device("cuda") # device object representing GPU n = 8 h = 224 w = 224 offset = 9 # 11 #input1 = N, 3, H + 11, W + 11 #input2 = N, 11, H, W #input3 = N, 11, H, W #input4 = N, 2, H, W # Note t...
1,305
23.185185
98
py
SSeg
SSeg-master/sdcnet/spatialdisplconv_package/spatialdisplconv.py
from torch.nn.modules.module import Module from torch.autograd import Function, Variable import spatialdisplconv_cuda class SpatialDisplConvFunction(Function): @staticmethod def forward(ctx, input1, input2, input3, input4, kernel_size = 1): assert input1.is_contiguous(), "spatialdisplconv forward - in...
2,270
32.397059
95
py
SSeg
SSeg-master/sdcnet/spatialdisplconv_package/setup.py
#!/usr/bin/env python3 import os import torch from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension cxx_args = ['-std=c++11'] nvcc_args = [ '-gencode', 'arch=compute_50,code=sm_50', '-gencode', 'arch=compute_52,code=sm_52', '-gencode', 'arch=compute_60,code=sm_6...
791
25.4
67
py
SSeg
SSeg-master/transforms/joint_transforms.py
""" # Code borrowded from: # https://github.com/zijundeng/pytorch-semantic-segmentation/blob/master/utils/joint_transforms.py # # # MIT License # # Copyright (c) 2017 ZijunDeng # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "So...
22,631
35.8
109
py
SSeg
SSeg-master/transforms/transforms.py
""" # Code borrowded from: # https://github.com/zijundeng/pytorch-semantic-segmentation/blob/master/utils/transforms.py # # # MIT License # # Copyright (c) 2017 ZijunDeng # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software...
11,778
32.274011
94
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/eval_multipro.py
# System libs import os import argparse from distutils.version import LooseVersion from multiprocessing import Queue, Process # Numerical libs import numpy as np import math import torch import torch.nn as nn from scipy.io import loadmat # Our libs from mit_semseg.config import cfg from mit_semseg.dataset import ValDat...
7,059
30.517857
115
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/test.py
# System libs import os import argparse from distutils.version import LooseVersion # Numerical libs import numpy as np import torch import torch.nn as nn from scipy.io import loadmat import csv # Our libs from mit_semseg.dataset import TestDataset from mit_semseg.models import ModelBuilder, SegmentationModule from mit_...
5,870
28.502513
82
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/setup.py
import setuptools with open('README.md', 'r') as fh: long_description = fh.read() setuptools.setup( name='mit_semseg', version='1.0.0', author='MIT CSAIL', description='Pytorch implementation for Semantic Segmentation/Scene Parsing on MIT ADE20K dataset', long_description=long_description, ...
817
26.266667
103
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/eval.py
# System libs import os import time import argparse from distutils.version import LooseVersion # Numerical libs import numpy as np import torch import torch.nn as nn from scipy.io import loadmat # Our libs from mit_semseg.config import cfg from mit_semseg.dataset import ValDataset from mit_semseg.models import ModelBui...
5,992
29.891753
100
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/train.py
# System libs import os import time # import math import random import argparse from distutils.version import LooseVersion # Numerical libs import torch import torch.nn as nn # Our libs from mit_semseg.config import cfg from mit_semseg.dataset import TrainDataset from mit_semseg.models import ModelBuilder, Segmentation...
9,224
32.667883
107
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/dataset.py
import os import json import torch from torchvision import transforms import numpy as np from PIL import Image def imresize(im, size, interp='bilinear'): if interp == 'nearest': resample = Image.NEAREST elif interp == 'bilinear': resample = Image.BILINEAR elif interp == 'bicubic': ...
11,898
39.063973
108
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/hrnet.py
""" This HRNet implementation is modified from the following repository: https://github.com/HRNet/HRNet-Semantic-Segmentation """ import logging import torch import torch.nn as nn import torch.nn.functional as F from .utils import load_url from mit_semseg.lib.nn import SynchronizedBatchNorm2d BatchNorm2d = Synchroniz...
16,811
36.695067
164
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/resnet.py
import torch.nn as nn import math from .utils import load_url from mit_semseg.lib.nn import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d __all__ = ['ResNet', 'resnet18', 'resnet50', 'resnet101'] # resnet101 is coming soon! model_urls = { 'resnet18': 'http://sceneparsing.csail.mit.edu/model/pret...
6,770
30.202765
99
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/utils.py
import sys import os try: from urllib import urlretrieve except ImportError: from urllib.request import urlretrieve import torch def load_url(url, model_dir='./pretrained', map_location=None): if not os.path.exists(model_dir): os.makedirs(model_dir) filename = url.split('/')[-1] cached_fil...
577
29.421053
78
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/resnext.py
import torch.nn as nn import math from .utils import load_url from mit_semseg.lib.nn import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d __all__ = ['ResNeXt', 'resnext101'] # support resnext 101 model_urls = { #'resnext50': 'http://sceneparsing.csail.mit.edu/model/pretrained_resnet/resnext50-im...
5,367
31.731707
101
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/models.py
import torch import torch.nn as nn from . import resnet, resnext, mobilenet, hrnet from mit_semseg.lib.nn import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d class SegmentationModuleBase(nn.Module): def __init__(self): super(SegmentationModuleBase, self).__init__() def pixel_acc(self...
21,185
35.091993
114
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/models/mobilenet.py
""" This MobileNetV2 implementation is modified from the following repository: https://github.com/tonylins/pytorch-mobilenet-v2 """ import torch.nn as nn import math from .utils import load_url from mit_semseg.lib.nn import SynchronizedBatchNorm2d BatchNorm2d = SynchronizedBatchNorm2d __all__ = ['mobilenetv2'] mo...
4,938
30.864516
100
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/modules/replicate.py
# -*- coding: utf-8 -*- # File : replicate.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import functools from torch.nn.parallel.da...
3,226
32.968421
115
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/modules/unittest.py
# -*- coding: utf-8 -*- # File : unittest.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import unittest import numpy as np from tor...
835
26.866667
157
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/modules/batchnorm.py
# -*- coding: utf-8 -*- # File : batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import collections import torch import tor...
13,813
40.860606
127
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/modules/tests/test_sync_batchnorm.py
# -*- coding: utf-8 -*- # File : test_sync_batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. import unittest import torch import torch.nn as nn from torch.autograd import Variable from sync_batchnorm import Synchroniz...
3,571
30.892857
109
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/modules/tests/test_numeric_batchnorm.py
# -*- coding: utf-8 -*- # File : test_numeric_batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. import unittest import torch import torch.nn as nn from torch.autograd import Variable from sync_batchnorm.unittest impor...
1,615
27.350877
85
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/nn/parallel/data_parallel.py
# -*- coding: utf8 -*- import torch.cuda as cuda import torch.nn as nn import torch import collections from torch.nn.parallel._functions import Gather __all__ = ['UserScatteredDataParallel', 'user_scattered_collate', 'async_copy_to'] def async_copy_to(obj, dev, main_stream=None): if torch.is_tensor(obj): ...
3,399
29.088496
82
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/utils/th.py
import torch from torch.autograd import Variable import numpy as np import collections __all__ = ['as_variable', 'as_numpy', 'mark_volatile'] def as_variable(obj): if isinstance(obj, Variable): return obj if isinstance(obj, collections.Sequence): return [as_variable(v) for v in obj] elif i...
1,237
28.47619
60
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/utils/data/sampler.py
import torch class Sampler(object): """Base class for all Samplers. Every Sampler subclass has to provide an __iter__ method, providing a way to iterate over indices of dataset elements, and a __len__ method that returns the length of the returned iterators. """ def __init__(self, data_sourc...
3,761
27.5
88
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/utils/data/dataloader.py
import torch import torch.multiprocessing as multiprocessing from torch._C import _set_worker_signal_handlers, \ _remove_worker_pids, _error_if_any_worker_fails try: from torch._C import _set_worker_pids except: from torch._C import _update_worker_pids as _set_worker_pids from .sampler import SequentialSamp...
16,207
37.046948
102
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/utils/data/dataset.py
import bisect import warnings from torch._utils import _accumulate from torch import randperm class Dataset(object): """An abstract class representing a Dataset. All other datasets should subclass it. All subclasses should override ``__len__``, that provides the size of the dataset, and ``__getitem__``,...
3,465
28.12605
118
py
semantic-segmentation-pytorch
semantic-segmentation-pytorch-master/mit_semseg/lib/utils/data/distributed.py
import math import torch from .sampler import Sampler from torch.distributed import get_world_size, get_rank class DistributedSampler(Sampler): """Sampler that restricts data loading to a subset of the dataset. It is especially useful in conjunction with :class:`torch.nn.parallel.DistributedDataParallel`...
1,964
32.305085
86
py
pyhiro
pyhiro-master/test/transformations.py
# -*- coding: utf-8 -*- # transformations.py # Copyright (c) 2006-2017, Christoph Gohlke # Copyright (c) 2006-2017, The Regents of the University of California # Produced at the Laboratory for Fluorescence Dynamics # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modifica...
66,387
33.380114
79
py
pyhiro
pyhiro-master/trimesh/transformations.py
# -*- coding: utf-8 -*- # transformations.py # Copyright (c) 2006-2015, Christoph Gohlke # Copyright (c) 2006-2015, The Regents of the University of California # Produced at the Laboratory for Fluorescence Dynamics # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modifica...
64,578
33.442133
79
py
infinite_ae_cf
infinite_ae_cf-main/main.py
import os os.environ["XLA_PYTHON_CLIENT_PREALLOCATE"] = "false" os.environ["TF_FORCE_UNIFIED_MEMORY"] = "1" os.environ["XLA_PYTHON_CLIENT_ALLOCATOR"] = "platform" import time import copy import random import numpy as np from utils import log_end_epoch, get_item_propensity, get_common_path def train(hyper_params, dat...
2,996
36.4625
133
py
infinite_ae_cf
infinite_ae_cf-main/model.py
import jax import functools from jax import scipy as sp from jax import numpy as jnp from neural_tangents import stax def make_kernelized_rr_forward(hyper_params): _, _, kernel_fn = FullyConnectedNetwork( depth=hyper_params['depth'], num_classes=hyper_params['num_items'] ) # NOTE: Un-commen...
1,532
36.390244
113
py
infinite_ae_cf
infinite_ae_cf-main/data.py
from scipy.sparse import csr_matrix import jax.numpy as jnp import numpy as np import copy import h5py import gc class Dataset: def __init__(self, hyper_params): self.data = load_raw_dataset(hyper_params['dataset']) self.set_of_active_users = list(set(self.data['train'][:, 0].tolist())) ...
4,938
35.051095
119
py
infinite_ae_cf
infinite_ae_cf-main/eval.py
import jax import numpy as np import jax.numpy as jnp from numba import jit, float64 INF = float(1e6) def evaluate(hyper_params, kernelized_rr_forward, data, item_propensity, train_x, topk = [ 10, 100 ], test_set_eval = False): preds, y_binary, metrics = [], [], {} for kind in [ 'HR', 'NDCG', 'PSP' ]: ...
4,052
39.53
132
py
GCNet
GCNet-main/baseline-cca/dccae.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import Dataset, DataLoader import numpy as np from sklearn.manifold import TSNE from sklearn.decomposition import PCA import os import cv2 import glob import time import tqdm import random from functoo...
23,393
36.671498
158
py
GCNet
GCNet-main/baseline-cca/dcca.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.utils.data import Dataset, DataLoader import numpy as np from sklearn.manifold import TSNE from sklearn.decomposition import PCA import os import cv2 import glob import time import tqdm from functools import part...
21,798
36.519793
158
py
GCNet
GCNet-main/feature_extraction/audio/extract_panns_embedding.py
""" PANNs: https://arxiv.org/abs/1912.10211 official github repo: https://github.com/qiuqiangkong/audioset_tagging_cnn """ import os import numpy as np import argparse import librosa import torch import glob import time import math from panns.models import * from panns.pytorch_utils import move_data_to_device from uti...
6,800
39.482143
129
py
GCNet
GCNet-main/feature_extraction/audio/extract_wav2vec_embedding.py
# *_*coding:utf-8 *_* """ wav2vec: https://arxiv.org/abs/1904.05862 official github repo: https://github.com/pytorch/fairseq/tree/master/examples/wav2vec """ import time import os import glob import numpy as np import pandas as pd import torch from fairseq.models.wav2vec import Wav2VecModel # Note: use fairseq version ...
5,363
45.241379
192
py
GCNet
GCNet-main/feature_extraction/audio/extract_wav2vec2_embedding.py
# *_*coding:utf-8 *_* """ wav2vec 2.0: https://arxiv.org/abs/2006.11477 official github repo: https://github.com/pytorch/fairseq/tree/master/examples/wav2vec """ import time import os import glob import torch import numpy as np from transformers import Wav2Vec2Processor, Wav2Vec2Model from util import frame_audio, writ...
6,942
46.554795
157
py
GCNet
GCNet-main/feature_extraction/audio/panns/inference.py
import os import sys sys.path.insert(1, os.path.join(sys.path[0], '../utils')) import numpy as np import argparse import librosa import matplotlib.pyplot as plt import torch from utilities import create_folder, get_filename from models import * from pytorch_utils import move_data_to_device import config def audio_ta...
7,592
34.481308
101
py
GCNet
GCNet-main/feature_extraction/audio/panns/main.py
import os import sys sys.path.insert(1, os.path.join(sys.path[0], '../utils')) import numpy as np import argparse import time import logging import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torch.utils.data from utilities import (create_folder, get_filename, creat...
13,353
37.595376
118
py
GCNet
GCNet-main/feature_extraction/audio/panns/losses.py
import torch import torch.nn.functional as F def clip_bce(output_dict, target_dict): """Binary crossentropy loss. """ return F.binary_cross_entropy( output_dict['clipwise_output'], target_dict['target']) def get_loss_func(loss_type): if loss_type == 'clip_bce': return clip_bce
313
21.428571
62
py
GCNet
GCNet-main/feature_extraction/audio/panns/evaluate.py
from sklearn import metrics from pytorch_utils import forward class Evaluator(object): def __init__(self, model): """Evaluator. Args: model: object """ self.model = model def evaluate(self, data_loader): """Forward evaluation data and calculate stat...
1,113
25.52381
87
py
GCNet
GCNet-main/feature_extraction/audio/panns/finetune_template.py
import os import sys sys.path.insert(1, os.path.join(sys.path[0], '../utils')) import numpy as np import argparse import h5py import math import time import logging import matplotlib.pyplot as plt import torch torch.backends.cudnn.benchmark=True torch.manual_seed(0) import torch.nn as nn import torch.nn.functional as ...
4,049
30.889764
88
py
GCNet
GCNet-main/feature_extraction/audio/panns/models.py
import torch import torch.nn as nn import torch.nn.functional as F from torchlibrosa.stft import Spectrogram, LogmelFilterBank from torchlibrosa.augmentation import SpecAugmentation from panns.pytorch_utils import do_mixup, interpolate, pad_framewise_output def init_layer(layer): """Initialize a Linear or Convo...
121,514
35.645054
115
py
GCNet
GCNet-main/feature_extraction/audio/panns/pytorch_utils.py
import numpy as np import time import torch import torch.nn as nn def move_data_to_device(x, device): if 'float' in str(x.dtype): x = torch.Tensor(x) elif 'int' in str(x.dtype): x = torch.LongTensor(x) else: return x return x.to(device) def do_mixup(x, mixup_lambda): """...
8,309
32.10757
127
py
GCNet
GCNet-main/feature_extraction/visual/extract_emonet_embedding.py
# *_*coding:utf-8 *_* import os import argparse from tqdm import tqdm import torch import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed import torchvision.transforms as transforms import numpy as np from emonet.models.emonet import EmoNet from dataset import FaceDatas...
3,336
35.67033
123
py
GCNet
GCNet-main/feature_extraction/visual/dataset.py
# *_*coding:utf-8 *_* import os import glob from PIL import Image from skimage import io import torch.utils.data as data class FaceDataset(data.Dataset): def __init__(self, vid, face_dir, transform=None): super(FaceDataset, self).__init__() self.vid = vid self.path = os.path.join(face_dir,...
2,209
31.985075
95
py
GCNet
GCNet-main/feature_extraction/visual/extract_manet_embedding.py
# *_*coding:utf-8 *_* import os import argparse from tqdm import tqdm import torch import torch.nn.parallel import torch.optim import torch.utils.data import torch.utils.data.distributed import torchvision.transforms as transforms import numpy as np import matplotlib.pyplot as plt from manet.model.manet import manet f...
5,923
36.974359
123
py
GCNet
GCNet-main/feature_extraction/visual/extract_ferplus_embedding.py
# *_*coding:utf-8 *_* from __future__ import division import os import time import six import sys from tqdm import tqdm import argparse import pickle import torch import torch.nn as nn import numpy as np import pandas as pd import torch.utils.data from os.path import join as pjoin import torch.backends.cudnn as cudnn ...
8,918
37.61039
144
py
GCNet
GCNet-main/feature_extraction/visual/emonet/evaluation.py
import numpy as np import torch def evaluate_metrics(ground_truth, predictions, metrics, verbose=True, print_tex=True): results = {} for name, metric in metrics.items(): results[name] = metric(ground_truth, predictions) if verbose: print(', '.join(f'{name}={results[name]:.2f}' for name in m...
7,930
37.31401
171
py
GCNet
GCNet-main/feature_extraction/visual/emonet/models/emonet.py
######################################################### # # # Authors: Jean Kossaifi, Antoine Toisoul, Adrian Bulat # # # ######################################################### import torch import torch.nn ...
8,683
35.64135
145
py
GCNet
GCNet-main/feature_extraction/visual/emonet/data/affecnet.py
from pathlib import Path import pickle import numpy as np import torch import math from torch.utils.data import Dataset from skimage import io class AffectNet(Dataset): _expressions = {0: 'neutral', 1:'happy', 2:'sad', 3:'surprise', 4:'fear', 5:'disgust', 6:'anger', 7:'contempt', 8:'none'} _expressions_indic...
5,964
43.185185
141
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/run_imagenet_benchmarks.py
# -*- coding: utf-8 -*- """This script evaluates imported PyTorch models on the ImageNet validation set e.g. python run_imagenet_benchmarks.py --model_subset pt_tpu --gpus 2 """ import os import argparse from torchvision.models import densenet from imagenet.evaluation import imagenet_benchmark from pathlib import Pat...
6,947
35.761905
88
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/run_fer_benchmarks.py
# -*- coding: utf-8 -*- """This module evaluates imported PyTorch models on fer2013 """ import os import argparse from os.path import join as pjoin from fer2013.fer import fer2013_benchmark from utils.benchmark_helpers import load_module_2or3 # MODEL_DIR = os.path.expanduser('~/data/models/pytorch/mcn_imports') # FER...
2,973
33.183908
73
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/lfw_eval.py
# -*- coding: utf-8 -*- """LFW benchmark for face verification. This is designed to be used as a sanity check for imported models. Example Invocation: ipy lfw_eval.py ipy lfw_eval.py -- --limit 200 --model_name vgg_face_dag ipy lfw_eval.py -- --model_name vgg_m_face_bn_dag This code is primarily based on the code of ...
10,780
31.375375
79
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/imagenet/evaluation.py
# -*- coding: utf-8 -*- """Imagenet validation set benchmark The module evaluates the performance of a pytorch model on the ILSVRC 2012 validation set. Based on PyTorch imagenet example: https://github.com/pytorch/examples/tree/master/imagenet """ from __future__ import division import os import time from PIL ...
4,937
31.486842
86
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/utils/benchmark_helpers.py
# -*- coding: utf-8 -*- """Utilties shared among the benchmarking protocols """ import os import sys import six import torchvision.transforms as transforms def compose_transforms(meta, resize=256, center_crop=True, override_meta_imsize=False): """Compose preprocessing transforms for model ...
2,669
37.142857
81
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/model/vgg_m_face_bn_fer_dag.py
# *_*coding:utf-8 *_* import torch import torch.nn as nn class Vgg_m_face_bn_fer_dag(nn.Module): def __init__(self): super(Vgg_m_face_bn_fer_dag, self).__init__() self.meta = {'mean': [131.45376586914062, 103.98748016357422, 91.46234893798828], 'std': [1, 1, 1], ...
3,509
42.875
112
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/model/senet50_ferplus_dag.py
# *_*coding:utf-8 *_* import torch import torch.nn as nn class Senet50_ferplus_dag(nn.Module): def __init__(self): super(Senet50_ferplus_dag, self).__init__() self.meta = {'mean': [131.0912, 103.8827, 91.4953], 'std': [1, 1, 1], 'imageSize': [224, 224, 3...
39,468
71.955638
123
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/model/alexnet_face_fer_bn_dag.py
# *_*coding:utf-8 *_* import torch import torch.nn as nn class Alexnet_face_fer_bn_dag(nn.Module): def __init__(self): super(Alexnet_face_fer_bn_dag, self).__init__() self.meta = {'mean': [131.09375, 103.88607788085938, 91.47599792480469], 'std': [1, 1, 1], ...
3,522
43.0375
108
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/model/vgg_vd_face_fer_dag.py
# *_*coding:utf-8 *_* import torch import torch.nn as nn class Vgg_vd_face_fer_dag(nn.Module): def __init__(self): super(Vgg_vd_face_fer_dag, self).__init__() self.meta = {'mean': [129.186279296875, 104.76238250732422, 93.59396362304688], 'std': [1, 1, 1], ...
4,424
42.382353
108
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/model/resnet50_ferplus_dag.py
# *_*coding:utf-8 *_* import torch import torch.nn as nn class Resnet50_ferplus_dag(nn.Module): def __init__(self): super(Resnet50_ferplus_dag, self).__init__() self.meta = {'mean': [131.0912, 103.8827, 91.4953], 'std': [1, 1, 1], 'imageSize': [224, 224,...
52,441
71.035714
123
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/fer2013/fer_loader.py
# -*- coding: utf-8 -*- """Contains two data loaders. One is for the Fer 2013 emotion dataset described in the paper: Goodfellow, Ian J., et al. "Challenges in representation learning: A report on three machine learning contests." International Conference on Neural Information Processing. Springer, Berlin, Heidelberg,...
8,345
39.712195
79
py
GCNet
GCNet-main/feature_extraction/visual/pytorch-benchmarks/fer2013/fer.py
# -*- coding: utf-8 -*- """Fer2013 benchmark The module evaluates the performance of a pytorch model on the FER2013 benchmark. """ from __future__ import division import os import time import torch import numpy as np import torch.utils.data import torch.backends.cudnn as cudnn from fer2013.fer_loader import Fer2013...
4,347
31.691729
72
py
GCNet
GCNet-main/feature_extraction/visual/manet/main.py
import argparse import os import time import shutil import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import torch.utils.data import torch.utils.data.distributed import matplotlib.pyplot as plt import torchvision.datasets as datasets import torchvision.t...
14,215
38.709497
119
py
GCNet
GCNet-main/feature_extraction/visual/manet/model/manet.py
from manet.model.attention import * def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=dilation, groups=groups, bias=False, dilation=dilation) def conv1x1(in...
9,989
34.425532
114
py
GCNet
GCNet-main/feature_extraction/visual/manet/model/attention.py
import torch import torch.nn as nn import torch.nn.functional as F class BasicConv(nn.Module): def __init__(self, in_planes, out_planes, kernel_size, stride=1, padding=0, dilation=1, groups=1, relu=True, bn=True, bias=False): super(BasicConv, self).__init__() self.out_channels = out_planes ...
3,163
35.790698
154
py
GCNet
GCNet-main/feature_extraction/text/extract_text_embedding_LZ.py
# *_*coding:utf-8 *_* import os import glob import math import pandas as pd import numpy as np import torch import time from tqdm import tqdm import itertools from transformers import AutoModel, AutoTokenizer # version: 4.5.1, pip install transformers import re import argparse from util import write_feature_to_csv, lo...
15,582
46.947692
185
py
GCNet
GCNet-main/feature_extraction/text/extract_text_embedding.py
# *_*coding:utf-8 *_* import os import glob import math import pandas as pd import numpy as np import torch import time from tqdm import tqdm import itertools from transformers import AutoModel, AutoTokenizer # version: 4.5.1, pip install transformers import re import argparse from util import write_feature_to_csv, loa...
17,177
47.66289
185
py
GCNet
GCNet-main/gcnet/dataloader_iemocap.py
import os import time import glob import tqdm import pickle import random import argparse import numpy as np import pandas as pd import torch from torch.utils.data import Dataset from torch.nn.utils.rnn import pad_sequence ## gain name2features def read_data(label_path, feature_root): ## gain (names, speakers) ...
6,858
38.877907
166
py