repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
pytorch-playground
pytorch-playground-master/svhn/dataset.py
import torch from torchvision import datasets, transforms from torch.utils.data import DataLoader import os def get(batch_size, data_root='/tmp/public_dataset/pytorch', train=True, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'svhn-data')) num_workers = kwargs.setdefault('num_wor...
1,565
34.590909
93
py
pytorch-playground
pytorch-playground-master/svhn/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/svhn/train.py
import argparse import os import time from utee import misc import torch import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable import dataset import model from IPython import embed parser = argparse.ArgumentParser(description='PyTorch SVHN Example') parser.add_argument('--ch...
5,590
43.023622
125
py
pytorch-playground
pytorch-playground-master/stl10/model.py
import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo import os from utee import misc from collections import OrderedDict print = misc.logger.info model_urls = { 'stl10': 'http://ml.cs.tsinghua.edu.cn/~chenxi/pytorch-models/stl10-866321e9.pth', } class SVHN(nn.Module): def __init__(self...
2,071
30.876923
89
py
pytorch-playground
pytorch-playground-master/stl10/dataset.py
import torch from torchvision import datasets, transforms from torch.utils.data import DataLoader from IPython import embed import os def get(batch_size, data_root='/mnt/local0/public_dataset/pytorch/', train=True, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'stl10-data')) num_w...
1,678
36.311111
101
py
pytorch-playground
pytorch-playground-master/stl10/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/stl10/train.py
import argparse import os import time from utee import misc import torch import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable import dataset import model from IPython import embed parser = argparse.ArgumentParser(description='PyTorch SVHN Example') parser.add_argument('--ch...
5,473
42.102362
124
py
pytorch-playground
pytorch-playground-master/imagenet/inception.py
import torch import torch.nn as nn import torch.nn.functional as F from utee import misc from collections import OrderedDict __all__ = ['Inception3', 'inception_v3'] model_urls = { 'inception_v3_google': 'https://download.pytorch.org/models/inception_v3_google-1a9a5a14.pth', } def inception_v3(pretrained=Fals...
11,908
34.549254
98
py
pytorch-playground
pytorch-playground-master/imagenet/resnet.py
import torch.nn as nn import math from utee import misc from collections import OrderedDict __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': 'https://download.pytor...
5,916
32.055866
109
py
pytorch-playground
pytorch-playground-master/imagenet/squeezenet.py
import math import torch import torch.nn as nn from utee import misc from collections import OrderedDict __all__ = ['SqueezeNet', 'squeezenet1_0', 'squeezenet1_1'] model_urls = { 'squeezenet1_0': 'https://download.pytorch.org/models/squeezenet1_0-a815701f.pth', 'squeezenet1_1': 'https://download.pytorch.org...
5,022
35.398551
101
py
pytorch-playground
pytorch-playground-master/imagenet/vgg.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo import math __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.or...
4,505
32.132353
113
py
pytorch-playground
pytorch-playground-master/imagenet/dataset.py
from utee import misc import os import os.path import numpy as np import joblib def get(batch_size, data_root='/tmp/public_dataset/pytorch', train=False, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'imagenet-data')) print("Building IMAGENET data loader, 50000 for train, 50000 f...
1,927
29.603175
113
py
pytorch-playground
pytorch-playground-master/imagenet/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/imagenet/alexnet.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo __all__ = ['AlexNet', 'alexnet'] model_urls = { 'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth', } class AlexNet(nn.Module): def __init__(self, num_classes=1000): super(AlexNet, self).__init__() self...
1,637
29.333333
84
py
pytorch-playground
pytorch-playground-master/mnist/model.py
import torch.nn as nn from collections import OrderedDict import torch.utils.model_zoo as model_zoo from utee import misc print = misc.logger.info model_urls = { 'mnist': 'http://ml.cs.tsinghua.edu.cn/~chenxi/pytorch-models/mnist-b07bb66b.pth' } class MLP(nn.Module): def __init__(self, input_dims, n_hiddens, ...
1,660
34.340426
85
py
pytorch-playground
pytorch-playground-master/mnist/dataset.py
from torch.utils.data import DataLoader import torch from torchvision import datasets, transforms import os def get(batch_size, data_root='/tmp/public_dataset/pytorch', train=True, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'mnist-data')) kwargs.pop('input_size', None) num_...
1,398
41.393939
93
py
pytorch-playground
pytorch-playground-master/mnist/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/mnist/train.py
import argparse import os import time from utee import misc import torch import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable import dataset import model parser = argparse.ArgumentParser(description='PyTorch MNIST Example') parser.add_argument('--wd', type=float, default=0....
5,502
41.992188
125
py
pytorch-playground
pytorch-playground-master/cifar/model.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo from IPython import embed from collections import OrderedDict from utee import misc print = misc.logger.info model_urls = { 'cifar10': 'http://ml.cs.tsinghua.edu.cn/~chenxi/pytorch-models/cifar10-d875770b.pth', 'cifar100': 'http://ml.cs.tsinghua....
2,809
36.972973
122
py
pytorch-playground
pytorch-playground-master/cifar/dataset.py
import torch from torchvision import datasets, transforms from torch.utils.data import DataLoader import os def get10(batch_size, data_root='/tmp/public_dataset/pytorch', train=True, val=True, **kwargs): data_root = os.path.expanduser(os.path.join(data_root, 'cifar10-data')) num_workers = kwargs.setdefault('nu...
2,937
40.380282
96
py
pytorch-playground
pytorch-playground-master/cifar/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/cifar/train.py
import argparse import os import time from utee import misc import torch import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable import dataset import model from IPython import embed parser = argparse.ArgumentParser(description='PyTorch CIFAR-X Example') parser.add_argument('...
5,777
42.119403
125
py
pytorch-playground
pytorch-playground-master/utee/quant.py
from torch.autograd import Variable import torch from torch import nn from collections import OrderedDict import math from IPython import embed def compute_integral_part(input, overflow_rate): abs_value = input.abs().view(-1) sorted_value = abs_value.sort(dim=0, descending=True)[0] split_idx = int(overflow...
6,302
32.705882
124
py
pytorch-playground
pytorch-playground-master/utee/misc.py
import cv2 import os import shutil import pickle as pkl import time import numpy as np import hashlib from IPython import embed class Logger(object): def __init__(self): self._logger = None def init(self, logdir, name='log'): if self._logger is None: import logging if ...
7,772
32.943231
114
py
pytorch-playground
pytorch-playground-master/utee/__init__.py
0
0
0
py
pytorch-playground
pytorch-playground-master/utee/selector.py
from utee import misc import os from imagenet import dataset print = misc.logger.info from IPython import embed known_models = [ 'mnist', 'svhn', # 28x28 'cifar10', 'cifar100', # 32x32 'stl10', # 96x96 'alexnet', # 224x224 'vgg16', 'vgg16_bn', 'vgg19', 'vgg19_bn', # 224x224 'resnet18', 'resnet3...
5,245
29.5
80
py
pytorch-playground
pytorch-playground-master/script/convert.py
import os import numpy as np import tqdm from utee import misc import argparse import cv2 import joblib parser = argparse.ArgumentParser(description='Extract the ILSVRC2012 val dataset') parser.add_argument('--in_file', default='val224_compressed.pkl', help='input file path') parser.add_argument('--out_root', default=...
1,337
25.76
113
py
coling2018-xling_argument_mining
coling2018-xling_argument_mining-master/code/annotationProjection/readDocs.py
import sys def readDoc(fn,index0=1): hh=[] hd = {} h=[] for line in open(fn): line = line.strip() if line=="": if h!=[]: hh.append(h) str=" ".join([x[0] for x in h]) hd[str] = h h=[] else: x = line.split("\t") word,label = x[index0],x[-1] h.app...
434
17.125
39
py
coling2018-xling_argument_mining
coling2018-xling_argument_mining-master/code/annotationProjection/projectArguments.py
import sys from readDocs import readDoc as rd # project argument spans from source to target document # Steffen Eger # 03/2018 # SAMPLE USAGE: # python2 projectArguments.py train_full.dat test_full.dat dev_full.dat essays.aligned essays.aligned.bidirectional # # Inputs: # $x_full.dat: train, test, dev annota...
5,486
27.878947
132
py
checklist
checklist-master/setup.py
from setuptools import setup, find_packages from setuptools.command.develop import develop from setuptools.command.install import install from setuptools.command.bdist_egg import bdist_egg from setuptools.command.egg_info import egg_info from setuptools.command.build_py import build_py from subprocess import check_cal...
3,011
33.62069
131
py
checklist
checklist-master/checklist/perturb.py
import numpy as np import collections import re import os import json import pattern from pattern.en import tenses from .editor import recursive_apply, MunchWithAdd def load_data(): cur_folder = os.path.dirname(__file__) basic = json.load(open(os.path.join(cur_folder, 'data', 'lexicons', 'basic.json'))) na...
21,734
36.217466
113
py
checklist
checklist-master/checklist/test_suite.py
import collections from collections import defaultdict, OrderedDict import dill import json from .abstract_test import load_test, read_pred_file from .test_types import MFT, INV, DIR from .viewer.suite_summarizer import SuiteSummarizer class TestSuite: def __init__(self, format_example_fn=None, print_fn=None): ...
16,352
39.477723
136
py
checklist
checklist-master/checklist/test_types.py
from .abstract_test import AbstractTest from .expect import Expect class MFT(AbstractTest): def __init__(self, data, expect=None, labels=None, meta=None, agg_fn='all', templates=None, name=None, capability=None, description=None): """Minimum Functionality Test Parameters -...
4,974
44.227273
92
py
checklist
checklist-master/checklist/editor.py
import collections import itertools import string import numpy as np import re import copy import os import json import munch import pickle import csv from .viewer.template_editor import TemplateEditor from .multilingual import multilingual_params, get_language_code class MunchWithAdd(munch.Munch): def __add__(se...
29,139
37.041775
150
py
checklist
checklist-master/checklist/expect.py
import numpy as np import itertools def iter_with_optional(data, preds, confs, labels, meta, idxs=None): # If this is a single example if type(data) not in [list, np.array, np.ndarray]: return [(data, preds, confs, labels, meta)] if type(meta) not in [list, np.array, np.ndarray]: meta = ite...
18,549
35.089494
140
py
checklist
checklist-master/checklist/abstract_test.py
from abc import ABC, abstractmethod import dill from munch import Munch import numpy as np import inspect from .expect import iter_with_optional, Expect from .viewer.test_summarizer import TestSummarizer def load_test(file): dill._dill._reverse_typemap['ClassType'] = type with open(file, 'rb') as infile: ...
21,832
37.848754
155
py
checklist
checklist-master/checklist/multilingual.py
import collections from iso639 import languages def get_language_code(language): to_try = [languages.name, languages.inverted, languages.part1] l_to_try = [language.capitalize(), language.lower()] for l in l_to_try: for t in to_try: if l in t: if not t[l].part1: ...
5,646
48.104348
83
py
checklist
checklist-master/checklist/pred_wrapper.py
import numpy as np class PredictorWrapper: @staticmethod def wrap_softmax(softmax_fn): """Wraps softmax such that it outputs predictions and confidences Parameters ---------- softmax_fn : fn Takes lists of inputs, outputs softmax probabilities (2d np.array) ...
1,310
27.5
99
py
checklist
checklist-master/checklist/__init__.py
0
0
0
py
checklist
checklist-master/checklist/text_generation.py
from transformers import AutoTokenizer, AutoModelForMaskedLM import collections import itertools import numpy as np import re from transformers import GPT2Config from transformers import GPT2LMHeadModel, GPT2Tokenizer from tqdm.auto import tqdm import torch import torch.nn.functional as F from pattern.en import wordnet...
15,163
44.951515
175
py
checklist
checklist-master/checklist/viewer/viewer.py
from .template_editor import TemplateEditor from .test_summarizer import TestSummarizer from .suite_summarizer import SuiteSummarizer
133
43.666667
45
py
checklist
checklist-master/checklist/viewer/template_editor.py
import ipywidgets as widgets from traitlets import Unicode, List, Dict import os import typing import itertools try: from IPython.core.display import display, Javascript except: raise Exception("This module must be run in IPython.") DIRECTORY = os.path.abspath(os.path.dirname(__file__)) # import logging # lo...
4,125
39.058252
123
py
checklist
checklist-master/checklist/viewer/fake_data.py
tag_dict = {'pos_adj': 'good', 'air_noun': 'flight', 'intens': 'very'} raw_templates = [ ['It', 'is', ['good', 'a:pos_adj'], ['flight', 'air_noun'], '.'], ['It', ['', 'a:mask'], ['very', 'a:intens'], ['good', 'pos_adj'], ['', 'mask'],'.'] ] suggests = [ ['was', 'day'], ['been', 'day'], ['been', 'we...
3,770
29.658537
96
py
checklist
checklist-master/checklist/viewer/suite_summarizer.py
import ipywidgets as widgets from traitlets import Unicode, List, Dict import os import typing from spacy.lang.en import English from copy import deepcopy try: from IPython.core.display import display, Javascript except: raise Exception("This module must be run in IPython.") DIRECTORY = os.path.abspath(os.path....
2,105
36.607143
87
py
checklist
checklist-master/checklist/viewer/__init__.py
def _jupyter_nbextension_paths(): return [{ 'section': 'notebook', 'src': 'static', 'dest': 'viewer', 'require': 'viewer/extension' }]
175
21
37
py
checklist
checklist-master/checklist/viewer/test_summarizer.py
import ipywidgets as widgets from traitlets import Unicode, List, Dict import os import typing from spacy.lang.en import English from copy import deepcopy try: from IPython.core.display import display, Javascript except: raise Exception("This module must be run in IPython.") DIRECTORY = os.path.abspath(os.path....
5,039
38.375
106
py
checklist
checklist-master/checklist/viewer/static/__init__.py
0
0
0
py
checklist
checklist-master/docs/source/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...
4,326
30.355072
102
py
CQMaxwell
CQMaxwell-main/RKRefErrorDatadelta10.py
import bempp.api import numpy as np import math from RKconv_op import * print("Bempp version used : " + bempp.api.__version__) def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def...
11,402
34.194444
133
py
CQMaxwell
CQMaxwell-main/libVersions.py
import bempp.api import scipy import numpy import matplotlib print("Bempp version :", bempp.api.__version__) print("Scipy version :", scipy.__version__) print("Numpy version :", numpy.__version__) print("Matplotlib version :", matplotlib.__version__)
251
27
53
py
CQMaxwell
CQMaxwell-main/RKconv_op.py
class Conv_Operator: import numpy as np tol=10**-16 def __init__(self,apply_elliptic_operator,order=2): self.order=order self.delta=lambda zeta : self.char_functions(zeta,order) self.apply_elliptic_operator=apply_elliptic_operator def get_integration_parameters(self,N,T): tol=self.tol dt=(T*1.0)/N L...
8,340
27.467577
248
py
CQMaxwell
CQMaxwell-main/FramesAndConditions.py
import numpy as np import bempp.api import math from RKconv_op import * def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def create_rhs(grid,N,T,m): #grid=bempp.api.shapes.spher...
10,911
33.1
113
py
CQMaxwell
CQMaxwell-main/RKRefErrorDatadelta01.py
import bempp.api import numpy as np import math from RKconv_op import * print("Bempp version used : " + bempp.api.__version__) def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def...
11,463
34.058104
133
py
CQMaxwell
CQMaxwell-main/d10RKRefErrorData.py
import bempp.api import numpy as np import math from RKconv_op import * def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def create_rhs(grid,dx,N,T,m): # grid=bempp.api.shapes.cu...
11,396
33.853211
133
py
CQMaxwell
CQMaxwell-main/Old Scripts/RKtemp.py
import bempp.api import math from RKconv_op import * print("Bempp version used : " + bempp.api.__version__) def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def create_rhs(grid,dx...
11,384
34.247678
133
py
CQMaxwell
CQMaxwell-main/Old Scripts/load-test.py
import scipy.io import numpy as np #v=1j*np.zeros((2,1)) #scipy.io.savemat('data/test.mat',dict(v=v)) mat_contents=scipy.io.loadmat('data/cond.mat') freqCond=mat_contents['freqCond'] freqs = np.concatenate((freqCond[0,1:],np.conj(freqCond[0,1:]))) conds = np.concatenate((freqCond[1,1:],freqCond[1,1:])) norms = np.conc...
1,273
23.5
64
py
CQMaxwell
CQMaxwell-main/Old Scripts/test_RK.py
import numpy as np def freq_der(s,b): return s**1*np.exp(-1*s)*b import math from RKconv_op import * def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def create_rhs(N,T,m): i...
2,333
24.933333
106
py
CQMaxwell
CQMaxwell-main/Old Scripts/MaxwellFrames.py
import bempp.api import numpy as np import math from RKconv_op import * def create_timepoints(c,N,T): m=len(c) time_points=np.zeros((1,m*N)) for j in range(m): time_points[0,j:m*N:m]=c[j]*1.0/N*np.ones((1,N))+np.linspace(0,1-1.0/N,N) return T*time_points def create_rhs(grid,N,T,m): #grid=bempp.api.shapes.spher...
9,655
33
113
py
Semi-Online-KD
Semi-Online-KD-master/main.py
import argparse import yaml import os import torch from trainer import build_trainer from utils.utils import save_code, save_opts def main(): parser = argparse.ArgumentParser(description='KnowledgeDistillation') parser.add_argument('--configs', '-c', dest='params', default='./configs/sokd.yaml') parser.a...
1,116
31.852941
88
py
Semi-Online-KD
Semi-Online-KD-master/trainer/base_trainer.py
from datetime import datetime from tensorboardX import SummaryWriter import os import logging from utils.utils import create_logger, output_process, fix_random class BaseTrainer(object): def __init__(self, experimental_name='debug', seed=None): # BASE self.current_time = datetime.now().strftime(...
1,135
31.457143
93
py
Semi-Online-KD
Semi-Online-KD-master/trainer/vanilla.py
import torch.nn as nn import torch from tqdm import tqdm from trainer.base_trainer import BaseTrainer from models import model_dict from utils.utils import count_parameters_in_MB, AverageMeter, accuracy, save_checkpoint from dataset import get_dataloader class Vanilla(BaseTrainer): def __init__(self, params, exp...
7,150
41.820359
131
py
Semi-Online-KD
Semi-Online-KD-master/trainer/__init__.py
from trainer.sokd import SemiOnlineKnowledgeDistillation from trainer.vanilla import Vanilla def build_trainer(**kwargs): maps = dict( sokd=SemiOnlineKnowledgeDistillation, vanilla=Vanilla, ) return maps[kwargs['distillation_type']](kwargs)
273
20.076923
56
py
Semi-Online-KD
Semi-Online-KD-master/trainer/sokd.py
import torch from trainer.vanilla import Vanilla from utils.utils import accuracy, AverageMeter, save_checkpoint from kd_losses import SoftTarget from models import model_dict class SemiOnlineKnowledgeDistillation(Vanilla): def __init__(self, params): # Model self.teacher_name = params.get('teach...
8,214
46.212644
126
py
Semi-Online-KD
Semi-Online-KD-master/dataset/__init__.py
from torchvision import transforms from torchvision import datasets import torch def get_dataset(data_name, data_path): """ Get dataset according to data name and data path. """ transform_train, transform_test = data_transform(data_name) if data_name.lower() == 'cifar100': train_dataset = ...
1,750
38.795455
113
py
Semi-Online-KD
Semi-Online-KD-master/models/__init__.py
from .wrn import wrn_40_1, wrn_40_2 model_dict = { 'wrn_40_1': wrn_40_1, 'wrn_40_2': wrn_40_2 }
106
12.375
35
py
Semi-Online-KD
Semi-Online-KD-master/models/wrn.py
import math import torch import torch.nn as nn import torch.nn.functional as F from copy import deepcopy __all__ = ['wrn'] class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, stride, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes) ...
5,436
33.411392
116
py
Semi-Online-KD
Semi-Online-KD-master/kd_losses/st.py
from __future__ import absolute_import from __future__ import print_function from __future__ import division import torch import torch.nn as nn import torch.nn.functional as F class SoftTarget(nn.Module): ''' Distilling the Knowledge in a Neural Network https://arxiv.org/pdf/1503.02531.pdf ''' def __init__(self,...
563
23.521739
53
py
Semi-Online-KD
Semi-Online-KD-master/kd_losses/__init__.py
from .st import SoftTarget
27
13
26
py
Semi-Online-KD
Semi-Online-KD-master/utils/utils.py
import logging import colorlog import os import time import shutil import torch import random import numpy as np from shutil import copyfile def create_logger(): """ Setup the logging environment """ log = logging.getLogger() # root logger log.setLevel(logging.DEBUG) format_str = '%(ascti...
4,987
27.340909
85
py
Semi-Online-KD
Semi-Online-KD-master/utils/__init__.py
0
0
0
py
Simplified_DMC
Simplified_DMC-master/location_dmc.py
import argparse import os import torch from torch.utils.data import DataLoader from torch import optim import numpy as np from data.MUSIC_dataset import MUSIC_Dataset, MUSIC_AV_Classify from model.base_model import resnet18 from model.dmc_model import DMC_NET from sklearn import cluster, metrics import numpy as np f...
8,957
41.254717
138
py
Simplified_DMC
Simplified_DMC-master/data/pair_video_audio.py
import os import pdb audio_dir = './MUSIC/solo/audio' video_dir = './MUSIC/solo/video' all_audios = os.listdir(audio_dir) audios = [ audio for audio in all_audios if audio.endswith('.flac')] all_videos = os.listdir(video_dir) videos = [video for video in all_videos if video.endswith('.mp4')] fid = open('solo_pair...
469
22.5
69
py
Simplified_DMC
Simplified_DMC-master/data/MUSIC_dataset.py
import numpy as np import librosa from PIL import Image, ImageEnhance import pickle import random import os import torchvision.transforms as transforms import json import torch def augment_image(image): if(random.random() < 0.5): image = image.transpose(Image.FLIP_LEFT_RIGHT) enhancer = ImageEnhance.Br...
9,784
42.29646
117
py
Simplified_DMC
Simplified_DMC-master/data/base_sampler.py
import torch from torch.utils.data.sampler import Sampler Class BaseSampler(Sampler): def __init__(self): super(BaseSampler,self).__init__() def __len__(self): def __iter__(self):
203
17.545455
44
py
Simplified_DMC
Simplified_DMC-master/data/cut_audios.py
import numpy as np import librosa import pickle import os import pdb with open('data_indicator/music/solo/solo_pairs.txt','r') as fid: audios = [line.strip().split(' ')[0] for line in fid.readlines()] audio_dir = './MUSIC/solo/audio' save_dir = './MUSIC/solo/audio_frames' #def audio_extract(wav_name, sr=22000): ...
1,685
33.408163
93
py
Simplified_DMC
Simplified_DMC-master/data/data_split.py
import os import json solo_videos = './MUSIC_label/MUSIC_solo_videos.json' solo_videos = json.load(open(solo_videos, 'r')) solo_videos = solo_videos['videos'] trains = [] vals = [] for _, item in solo_videos.items(): for i, vid in enumerate(item): if i < 5: vals.append(vid) else: ...
825
24.030303
71
py
Simplified_DMC
Simplified_DMC-master/data/__init__.py
2
0
0
py
Simplified_DMC
Simplified_DMC-master/data/cut_videos.py
import os import cv2 import pdb def video2frame(video_path, frame_save_path, frame_interval=1): vid = cv2.VideoCapture(video_path) fps = vid.get(cv2.CAP_PROP_FPS) #pdb.set_trace() success, image = vid.read() count = 0 while success: count +=1 if count % frame_interval == 0: ...
2,377
32.492958
99
py
Simplified_DMC
Simplified_DMC-master/model/base_model.py
import torch import torch.nn as nn __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'wide_resnet50_2', 'wide_resnet101_2'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'r...
9,147
38.261803
106
py
Simplified_DMC
Simplified_DMC-master/model/audio_net.py
import torch import torch.nn as nn import torch.nn.functional as F class Unet(nn.Module): def __init__(self, fc_dim=64, num_downs=5, ngf=64, use_dropout=False): super(Unet, self).__init__() # construct unet structure unet_block = UnetBlock( ngf * 8, ngf * 8, input_nc=None, ...
3,744
33.675926
74
py
Simplified_DMC
Simplified_DMC-master/model/vision_net.py
import torch import torch.nn as nn import torch.nn.functional as F class Resnet(nn.Module): def __init__(self, original_resnet): super(Resnet, self).__init__() self.features = nn.Sequential( *list(original_resnet.children())[:-1]) # for param in self.features.parameters(): ...
4,152
27.445205
69
py
Simplified_DMC
Simplified_DMC-master/model/base_model_v1.py
import torch import torch.nn as nn __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d', 'wide_resnet50_2', 'wide_resnet101_2'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'r...
9,008
38.169565
106
py
Simplified_DMC
Simplified_DMC-master/model/dmc_model.py
import torch import torch.nn as nn import random class Cluster_layer(nn.Module): def __init__(self, input_dim = 512, num_cluster=2, iters=4, beta=-30, **kwargs): super(Cluster_layer, self).__init__() self.input_dim = input_dim self.num_cluster = num_cluster self.iters = iters ...
3,338
35.293478
152
py
Simplified_DMC
Simplified_DMC-master/model/__init__.py
1
0
0
py
synfeal
synfeal-main/utils.py
import numpy as np import os import cv2 import torch import torch import math import yaml from sklearn.metrics import mean_squared_error from torchsummary import summary from yaml.loader import SafeLoader from colorama import Fore from scipy.spatial.transform import Rotation as R from models.loss_functions import Bet...
7,993
29.51145
146
py
synfeal
synfeal-main/dataset.py
import cv2 import torch.utils.data as data import numpy as np import torch import os import yaml from PIL import Image from yaml.loader import SafeLoader from utils import read_pcd, matrixToXYZ, matrixToQuaternion, normalize_quat # pytorch datasets: https://pytorch.org/tutorials/beginner/basics/data_tutorial.html c...
4,547
34.53125
137
py
synfeal
synfeal-main/utils_ros.py
import copy import math import tf import rospy import os from geometry_msgs.msg import Pose, Point from visualization_msgs.msg import * from std_msgs.msg import Header, ColorRGBA from synfeal_collection.src.pypcd import PointCloud def write_pcd(filename, msg, mode='binary'): pc = PointCloud.from_msg(msg) ...
7,402
30.105042
122
py
synfeal
synfeal-main/deprecated/raycast_example.py
#!/usr/bin/env python3 # stdlib import sys import argparse # 3rd-party import trimesh import numpy as np import time def main(): # parser = argparse.ArgumentParser(description='Data Collector') # parser.add_argument('-m', '--mode', type=str, default='interactive', # help='interactive/...
1,910
24.144737
109
py
synfeal
synfeal-main/deprecated/rotation_to_direction.py
#!/usr/bin/env python3 from scipy.spatial.transform import Rotation as R #rotate_y90 = R.from_euler('y', 90, degrees=True).as_matrix() rotate_y90 = R.from_euler('x', 40, degrees=True).as_quat() matrix = R.from_quat(rotate_y90).as_matrix() print(matrix) print(matrix[:,0])
274
26.5
61
py
synfeal
synfeal-main/synfeal_collection/src/automatic_data_collection.py
#!/usr/bin/env python3 # stdlib import random import os from xml.parsers.expat import model # 3rd-party import rospy import tf import numpy as np import trimesh from geometry_msgs.msg import Pose #from interactive_markers.interactive_marker_server import * #from interactive_markers.menu_handler import * from visualiz...
17,567
39.018223
125
py
synfeal
synfeal-main/synfeal_collection/src/interactive_data_collection.py
#!/usr/bin/env python3 import copy import rospy from std_msgs.msg import Header, ColorRGBA from geometry_msgs.msg import Point, Pose, Vector3, Quaternion from interactive_markers.interactive_marker_server import * from interactive_markers.menu_handler import * from visualization_msgs.msg import * from gazebo_msgs.srv ...
9,016
42.350962
108
py
synfeal
synfeal-main/synfeal_collection/src/save_dataset.py
#!/usr/bin/env python3 import rospy import os from visualization_msgs.msg import * from cv_bridge import CvBridge from tf.listener import TransformListener from utils import write_intrinsic, write_img, write_transformation from utils_ros import read_pcd, write_pcd from sensor_msgs.msg import PointCloud2, Image, PointF...
6,373
37.630303
127
py
synfeal
synfeal-main/synfeal_collection/src/pypcd_no_ros.py
""" The MIT License (MIT) Copyright (c) 2015 Daniel Maturana, Carnegie Mellon University 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 restriction, including without limitation the righ...
18,853
36.859438
114
py
synfeal
synfeal-main/synfeal_collection/src/__init__.py
0
0
0
py
synfeal
synfeal-main/synfeal_collection/src/pypcd.py
""" The MIT License (MIT) Copyright (c) 2015 Daniel Maturana, Carnegie Mellon University 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 restriction, including without limitation the righ...
18,804
36.837022
114
py
synfeal
synfeal-main/models/pointnet.py
import torch import torch.nn as nn import torch.nn.parallel import torch.utils.data from torch.autograd import Variable import numpy as np import torch.nn.functional as F # this is a regularization to avoid overfitting! It adds another term to the cost function to penalize the complexity of the models. def feature_t...
5,796
34.564417
143
py
synfeal
synfeal-main/models/pointnet_classification.py
import torch import torch.nn as nn import torch.nn.parallel import torch.utils.data from torch.autograd import Variable import numpy as np import torch.nn.functional as F class STN3d(nn.Module): def __init__(self): super(STN3d, self).__init__() self.conv1 = torch.nn.Conv1d(3, 64, 1) self.co...
4,884
32.006757
128
py
synfeal
synfeal-main/models/loss_functions.py
import torch from torch import nn class BetaLoss(nn.Module): def __init__(self, beta= 512): super(BetaLoss, self).__init__() self.beta = beta #self.loss_fn = torch.nn.L1Loss() # PoseNet said that L1 was the best self.loss_fn = torch.nn.MSELoss() def forward(self, pred, targ): ...
1,656
39.414634
261
py
synfeal
synfeal-main/models/poselstm.py
from turtle import forward from unicodedata import bidirectional import torch import torch.nn as nn import torch.nn.parallel import torch.utils.data from torch.autograd import Variable import numpy as np import torch.nn.functional as F from torchvision import transforms, models # based on: https://github.com/hazirbas...
6,396
33.766304
120
py
synfeal
synfeal-main/models/posenet.py
import torch import torch.nn as nn import torch.nn.parallel import torch.utils.data from torch.autograd import Variable import numpy as np import torch.nn.functional as F from torchvision import transforms, models #https://github.com/youngguncho/PoseNet-Pytorch/blob/6c583a345a20ba17f67b76e54a26cf78e2811604/posenet_si...
7,521
34.314554
116
py