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 |
|---|---|---|---|---|---|---|
EikoNet | EikoNet-master/setup.py | import codecs
import glob
import inspect
import os
import re
from setuptools import setup
import sys
import time
import numpy.distutils.misc_util
# Directory of the current file
SETUP_DIRECTORY = os.path.dirname(os.path.abspath(inspect.getfile(
inspect.currentframe())))
LOCAL_PATH = os.path.join(SETUP_DIRECTORY, ... | 3,463 | 26.492063 | 77 | py |
EikoNet | EikoNet-master/EikoNet/model.py | import matplotlib
import numpy as np
import math
import pandas as pd
from scipy.ndimage.filters import gaussian_filter
import random
from glob import glob
import time
import torch
from torch.nn import Linear
from torch import Tensor
from torch.nn import MSELoss
from torch.optim import SGD, Adam, RMSprop
from torch.aut... | 18,962 | 43.1 | 238 | py |
EikoNet | EikoNet-master/EikoNet/database.py | import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
from scipy import signal
import numpy as np
import torch
from torch.nn import Linear
from torch import Tensor
from torch.nn import MSELoss
from torch.optim import SGD, Adam, RMSprop
from torch.autograd import Variable, grad
from torch.utils.data.sa... | 14,844 | 37.161954 | 216 | py |
EikoNet | EikoNet-master/EikoNet/plot.py | import matplotlib
matplotlib.use('Agg')
import numpy as np
import math
import pandas as pd
import matplotlib
import matplotlib.pylab as plt
from scipy.ndimage.filters import gaussian_filter
import random
from glob import glob
import torch
from torch.nn import Linear
from torch import Tensor
from torch.nn import MSELos... | 7,177 | 41.72619 | 168 | py |
DisVoice | DisVoice-master/setup.py | try:
from setuptools import setup, find_packages #enables develop
except ImportError:
from distutils.core import setup, find_packages
import pathlib
install_requires = [
'kaldi_io',
'tqdm',
'matplotlib',
'numpy',
... | 2,548 | 32.986667 | 145 | py |
DisVoice | DisVoice-master/disvoice/script_mananger.py | import numpy as np
import torch
def script_manager(args, feature_method):
audio, file_features, static, plots, fmt = check_paramters(args)
features = extract_features(feature_method, audio, file_features, static, plots, fmt)
save_features(file_features, fmt, features)
def save_features(file_features, fmt... | 2,174 | 37.157895 | 124 | py |
DisVoice | DisVoice-master/disvoice/replearning/RAE.py | import torch
from torch import nn
import torch.nn.functional as F
class RAEenc(nn.Module):
def __init__(self, dim=32):
super().__init__()
self.lstm1=nn.LSTM(128,64, batch_first=True, bidirectional=True)
self.linear = nn.Linear(256, dim)
def forward(self, x):
x=x[:,0,:,:]
... | 1,340 | 24.788462 | 86 | py |
DisVoice | DisVoice-master/disvoice/replearning/CAE.py | from torch import nn
import torch
import torch.nn.functional as F
import torch
class CAEenc(nn.Module):
def __init__(self, dim=256, nc=1):
super().__init__()
self.conv1=nn.Conv2d(nc, 16, kernel_size=3, stride=1, padding=1, bias=False)
self.bn1 = nn.BatchNorm2d(16)
self.pool=nn.MaxP... | 2,526 | 36.161765 | 98 | py |
DisVoice | DisVoice-master/disvoice/replearning/AEspeech.py |
# -*- coding: utf-8 -*-
"""
Feature extraction from speech signals based on representation learning strategies
"""
import os
import sys
from scipy.io.wavfile import read
import torch
from librosa.feature import melspectrogram
import numpy as np
import warnings
import matplotlib.pyplot as plt
import pandas as pd
impo... | 15,420 | 36.612195 | 178 | py |
DisVoice | DisVoice-master/disvoice/replearning/replearning.py | import os
import sys
import numpy as np
import pandas as pd
import scipy.stats as st
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
PATH = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(PATH, '..'))
sys.path.append(PATH)
from utils import save_dict_kaldimat, ... | 9,348 | 44.383495 | 180 | py |
DisVoice | DisVoice-master/disvoice/phonation/phonation.py |
# -*- coding: utf-8 -*-
"""
Created on Jul 21 2017
@author: J. C. Vasquez-Correa
"""
from scipy.io.wavfile import read
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
import pysptk
import pandas as pd
PATH = os.path.dirname(os.path.realpath(__... | 12,887 | 38.292683 | 160 | py |
DisVoice | DisVoice-master/disvoice/articulation/articulation.py |
# -*- coding: utf-8 -*-
"""
Created on Jul 21 2017
@author: J. C. Vasquez-Correa
"""
from scipy.io.wavfile import read
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman"
import matplotlib.mlab as mlab
import pysptk
import pandas as pd
import torch
... | 19,520 | 42.092715 | 171 | py |
DisVoice | DisVoice-master/disvoice/prosody/Prosody.py |
# -*- coding: utf-8 -*-
"""
Created on Jul 21 2017, Modified Apr 10 2018.
@author: J. C. Vasquez-Correa, T. Arias-Vergara, J. S. Guerrero
"""
import matplotlib.pyplot as plt
import numpy as np
from tqdm import tqdm
import torch
import pandas as pd
import pysptk
from matplotlib import cm
from scipy.io.wavfile impor... | 24,104 | 43.721707 | 199 | py |
DisVoice | DisVoice-master/disvoice/phonological/phonological.py |
# -*- coding: utf-8 -*-
"""
Created on Jun 24 2020
@author: J. C. Vasquez-Correa
"""
import os
import sys
import numpy as np
import pandas as pd
from phonet.phonet import Phonet
from phonet.phonet import Phonological as phon
import scipy.stats as st
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Time... | 9,073 | 39.873874 | 163 | py |
DisVoice | DisVoice-master/disvoice/glottal/Glottal.py | import os
import sys
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pysptk
import torch
from scipy.integrate import cumtrapz
from scipy.io.wavfile import read
from tqdm import tqdm
PATH = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(PATH, '..'))
sys.path.appe... | 15,593 | 39.715405 | 160 | py |
DisVoice | DisVoice-master/tests/test_phonation.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.phonation.phonation as phonation
def test_extract_phonation1():
feature_extractor=phonation.Phonation()
file_audio=PATH+"/../a... | 1,094 | 32.181818 | 104 | py |
DisVoice | DisVoice-master/tests/test_replearning.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.replearning.replearning as replearning
def test_extract_replearning1():
feature_extractor=replearning.RepLearning('CAE')
file_... | 1,139 | 33.545455 | 104 | py |
DisVoice | DisVoice-master/tests/test_phonological.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.phonological.phonological as phonological
def test_extract_phonological1():
feature_extractor=phonological.Phonological()
file... | 1,139 | 33.545455 | 104 | py |
DisVoice | DisVoice-master/tests/test_prosody.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.prosody.prosody as prosody
def test_extract_prosody1():
feature_extractor=prosody.Prosody()
file_audio=PATH+"/../audios/098_u1... | 1,064 | 31.272727 | 104 | py |
DisVoice | DisVoice-master/tests/test_glottal.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.glottal.glottal as glottal
def test_extract_glottal1():
feature_extractor=glottal.Glottal()
file_audio=PATH+"/../audios/098_u1... | 1,064 | 31.272727 | 104 | py |
DisVoice | DisVoice-master/tests/test_articulation.py | import os, sys
PATH=os.path.dirname(os.path.realpath(__file__))
PATH_DISVOICE=os.path.dirname(os.path.realpath(__file__))+"/disvoice/"
sys.path.append(PATH_DISVOICE)
import disvoice.articulation.articulation as articulation
def test_extract_articulation1():
feature_extractor=articulation.Articulation()
file... | 1,143 | 33.666667 | 104 | py |
enterprise | enterprise-master/docs/conf.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# enterprise documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 9 22:26:36 2013.
#
# 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
# ... | 9,449 | 30.818182 | 89 | py |
flexible-input-slu | flexible-input-slu-main/train.py | # 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, software
# distributed under th... | 1,122 | 31.085714 | 79 | py |
flexible-input-slu | flexible-input-slu-main/models/model.py | # 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, software
# distributed under th... | 6,662 | 44.636986 | 192 | py |
flexible-input-slu | flexible-input-slu-main/models/model_combined.py | # 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, software
# distributed under th... | 9,952 | 43.235556 | 192 | py |
flexible-input-slu | flexible-input-slu-main/models/layers.py | # 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, software
# distributed under th... | 8,252 | 36.857798 | 144 | py |
flexible-input-slu | flexible-input-slu-main/acoustic_encoder/data.py | import torch
import torch.utils.data
import torchaudio
import os, glob
from collections import Counter
import soundfile as sf
import numpy as np
import configparser
import textgrid
import multiprocessing
import json
import pandas as pd
from subprocess import call
class Config:
def __init__(self):
self.use_sincnet =... | 23,121 | 41.739372 | 200 | py |
flexible-input-slu | flexible-input-slu-main/acoustic_encoder/models.py | import torch
import numpy as np
import sys
import os
import math
def flip(x, dim):
xsize = x.size()
dim = x.dim() + dim if dim < 0 else dim
x = x.contiguous()
x = x.view(-1, *xsize[dim:])
x = x.view(x.size(0), x.size(1), -1)[:, getattr(torch.arange(x.size(1)-1,
-1, -1), ('cpu','cuda')[x.is_cuda])().long(), :]
... | 30,914 | 33.464883 | 211 | py |
flexible-input-slu | flexible-input-slu-main/acoustic_encoder/main_finetune.py | import torch
import numpy as np
from models import PretrainedModel, Model
from data import get_ASR_datasets, get_SLU_datasets, read_config
from training_finetune import Trainer
import argparse
# Get args
parser = argparse.ArgumentParser()
parser.add_argument('--pretrain', action='store_true', help='run ASR pre-trainin... | 4,323 | 42.24 | 180 | py |
flexible-input-slu | flexible-input-slu-main/experiments/experiment_triplet_combinedsystem.py | # 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, software
# distributed under th... | 7,058 | 43.11875 | 96 | py |
flexible-input-slu | flexible-input-slu-main/experiments/experiment_base.py | # 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, software
# distributed under th... | 7,516 | 45.401235 | 173 | py |
flexible-input-slu | flexible-input-slu-main/experiments/experiment_triplet.py | # 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, software
# distributed under th... | 6,583 | 42.03268 | 113 | py |
flexible-input-slu | flexible-input-slu-main/experiments/experiment_base_combinedsystem.py | # 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, software
# distributed under th... | 7,952 | 46.622754 | 245 | py |
flexible-input-slu | flexible-input-slu-main/bert/model.py | from transformers import BertModel, BertConfig
import torch
import torch.nn as nn
from torch.nn.utils import rnn
import numpy as np
import torch.nn.functional as F
from data import get_dataloaders
from tqdm import tqdm
import os
def get_bert(pretrained=True, pretrained_model_name='bert-base-cased'):
"""Initialize... | 9,477 | 38.823529 | 108 | py |
flexible-input-slu | flexible-input-slu-main/bert/data.py | import torch
import torch.nn as nn
from torch.nn.utils import rnn
import numpy as np
import torch.nn.functional as F
from transformers import BertModel, BertConfig, BertTokenizer
from sklearn import preprocessing
import pandas as pd
from torch.utils.data import Dataset, DataLoader
import os
def read_data(data_root):
... | 3,962 | 38.237624 | 145 | py |
flexible-input-slu | flexible-input-slu-main/bert/train.py | # 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, software
# distributed under th... | 977 | 28.636364 | 74 | py |
flexible-input-slu | flexible-input-slu-main/dataloader/data.py | # 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, software
# distributed under th... | 18,406 | 43.569007 | 145 | py |
BLIP | BLIP-main/eval_retrieval_video.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 9,531 | 37.128 | 123 | py |
BLIP | BLIP-main/pretrain.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 6,666 | 37.537572 | 148 | py |
BLIP | BLIP-main/eval_nocaps.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 4,249 | 35.016949 | 119 | py |
BLIP | BLIP-main/utils.py | import math
def cosine_lr_schedule(optimizer, epoch, max_epoch, init_lr, min_lr):
"""Decay the learning rate"""
lr = (init_lr - min_lr) * 0.5 * (1. + math.cos(math.pi * epoch / max_epoch)) + min_lr
for param_group in optimizer.param_groups:
param_group['lr'] = lr
def warmup_lr_schedule(opti... | 8,474 | 29.485612 | 94 | py |
BLIP | BLIP-main/train_vqa.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 7,751 | 37.376238 | 128 | py |
BLIP | BLIP-main/train_nlvr.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 8,060 | 36.84507 | 123 | py |
BLIP | BLIP-main/train_retrieval.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 14,091 | 39.846377 | 129 | py |
BLIP | BLIP-main/train_caption.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import argparse
import os
import ruamel_yaml as yaml
import numpy as np
imp... | 8,388 | 39.723301 | 128 | py |
BLIP | BLIP-main/predict.py | """
Download the weights in ./checkpoints beforehand for fast inference
wget https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_base_caption.pth
wget https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model*_vqa.pth
wget https://storage.googleapis.com/sfr-vision-language... | 3,796 | 37.353535 | 114 | py |
BLIP | BLIP-main/models/blip_pretrain.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
from models.med import BertConfig, BertModel, BertLMHeadModel
from transfor... | 16,066 | 46.255882 | 184 | py |
BLIP | BLIP-main/models/blip_vqa.py | from models.med import BertConfig, BertModel, BertLMHeadModel
from models.blip import create_vit, init_tokenizer, load_checkpoint
import torch
from torch import nn
import torch.nn.functional as F
from transformers import BertTokenizer
import numpy as np
class BLIP_VQA(nn.Module):
def __init__(self, ... | 8,969 | 47.225806 | 122 | py |
BLIP | BLIP-main/models/blip_retrieval.py | from models.med import BertConfig, BertModel
from transformers import BertTokenizer
import torch
from torch import nn
import torch.nn.functional as F
from models.blip import create_vit, init_tokenizer, load_checkpoint
class BLIP_Retrieval(nn.Module):
def __init__(self,
med_confi... | 13,759 | 42 | 123 | py |
BLIP | BLIP-main/models/vit.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
* Based on timm code base
* https://github.com/rwightman/pytorch-image-models... | 14,240 | 45.691803 | 118 | py |
BLIP | BLIP-main/models/blip_itm.py | from models.med import BertConfig, BertModel
from transformers import BertTokenizer
import torch
from torch import nn
import torch.nn.functional as F
from models.blip import create_vit, init_tokenizer, load_checkpoint
class BLIP_ITM(nn.Module):
def __init__(self,
med_config = 'c... | 3,160 | 40.592105 | 119 | py |
BLIP | BLIP-main/models/blip_nlvr.py | from models.med import BertConfig
from models.nlvr_encoder import BertModel
from models.vit import interpolate_pos_embed
from models.blip import create_vit, init_tokenizer, is_url
from timm.models.hub import download_cached_file
import torch
from torch import nn
import torch.nn.functional as F
from transformers impor... | 4,398 | 41.708738 | 128 | py |
BLIP | BLIP-main/models/med.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
* Based on huggingface code base
* https://github.com/huggingface/transformer... | 41,786 | 42.710251 | 213 | py |
BLIP | BLIP-main/models/nlvr_encoder.py | import math
import os
import warnings
from dataclasses import dataclass
from typing import Optional, Tuple
import torch
from torch import Tensor, device, dtype, nn
import torch.utils.checkpoint
from torch import nn
from torch.nn import CrossEntropyLoss
import torch.nn.functional as F
from transformers.activations imp... | 36,738 | 42.529621 | 213 | py |
BLIP | BLIP-main/models/blip.py | '''
* Copyright (c) 2022, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
* By Junnan Li
'''
import warnings
warnings.filterwarnings("ignore")
from models.vit import V... | 10,946 | 44.803347 | 128 | py |
BLIP | BLIP-main/data/nlvr_dataset.py | import os
import json
import random
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class nlvr_dataset(Dataset):
def __init__(self, transform, image_root, ann_root, split):
'''
image_root (string)... | 2,722 | 33.910256 | 111 | py |
BLIP | BLIP-main/data/pretrain_dataset.py | import json
import os
import random
from torch.utils.data import Dataset
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
Image.MAX_IMAGE_PIXELS = None
from data.utils import pre_caption
import os,glob
class pretrain_dataset(Dataset):
def __init__(self, ann_file, laion_path... | 1,632 | 26.677966 | 75 | py |
BLIP | BLIP-main/data/coco_karpathy_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class coco_karpathy_train(Dataset):
def __init__(self, transform, image_root, ann_root, max_words=30, prompt=''):
'''
im... | 4,711 | 36.396825 | 118 | py |
BLIP | BLIP-main/data/utils.py | import re
import json
import os
import torch
import torch.distributed as dist
import utils
def pre_caption(caption,max_words=50):
caption = re.sub(
r"([.!\"()*#:;~])",
' ',
caption.lower(),
)
caption = re.sub(
r"\s{2,}",
' ',
caption,
)
capti... | 3,449 | 29.803571 | 117 | py |
BLIP | BLIP-main/data/vqa_dataset.py | import os
import json
import random
from PIL import Image
import torch
from torch.utils.data import Dataset
from data.utils import pre_question
from torchvision.datasets.utils import download_url
class vqa_dataset(Dataset):
def __init__(self, transform, ann_root, vqa_root, vg_root, train_files=[], split="train")... | 3,454 | 38.261364 | 122 | py |
BLIP | BLIP-main/data/nocaps_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
class nocaps_eval(Dataset):
def __init__(self, transform, image_root, ann_root, split):
urls = {'val':'https://storage.googleapis.com/sfr-vision-language-research/datase... | 1,139 | 34.625 | 111 | py |
BLIP | BLIP-main/data/video_dataset.py | from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
import torch
import numpy as np
import random
import decord
from decord import VideoReader
import json
import os
from data.utils import pre_caption
decord.bridge.set_bridge("torch")
class ImageNorm(object):... | 4,005 | 35.09009 | 122 | py |
BLIP | BLIP-main/data/__init__.py | import torch
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.transforms.functional import InterpolationMode
from data.coco_karpathy_dataset import coco_karpathy_train, coco_karpathy_caption_eval, coco_karpathy_retrieval_eval
from data.nocaps_dataset import nocaps_eval
from d... | 5,189 | 49.882353 | 127 | py |
BLIP | BLIP-main/data/flickr30k_dataset.py | import os
import json
from torch.utils.data import Dataset
from torchvision.datasets.utils import download_url
from PIL import Image
from data.utils import pre_caption
class flickr30k_train(Dataset):
def __init__(self, transform, image_root, ann_root, max_words=30, prompt=''):
'''
image_... | 3,346 | 34.989247 | 114 | py |
SecureSGD | SecureSGD-master/Cifar10/cleverhans/utils_pytorch.py | from random import getrandbits
import tensorflow as tf
import torch
from torch.autograd import Variable
# https://gist.github.com/kingspp/3ec7d9958c13b94310c1a365759aa3f4
# Pyfunc Gradient Function
def _py_func_with_gradient(func, inp, Tout, stateful=True, name=None,
grad_func=None):
"... | 2,819 | 32.571429 | 76 | py |
SecureSGD | SecureSGD-master/Cifar10/cleverhans/dataset.py | """Dataset class for CleverHans
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from cleverhans.utils_mnist import data_mnist
keras = None # Only load keras if user tries to use a dataset that requires it
class Dataset(object):
"""Abstract base... | 4,463 | 29.162162 | 79 | py |
SecureSGD | SecureSGD-master/Cifar10/cleverhans/utils_keras.py | """
Model construction utilities based on keras
"""
import warnings
from distutils.version import LooseVersion
import keras
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
from .model import Model, NoSuchLayerError
if LooseVersion(keras.__version__) >= LooseVersion('2.0.0'):
... | 8,650 | 35.348739 | 79 | py |
SecureSGD | SecureSGD-master/MNIST/cleverhans/utils_pytorch.py | from random import getrandbits
import tensorflow as tf
import torch
from torch.autograd import Variable
# https://gist.github.com/kingspp/3ec7d9958c13b94310c1a365759aa3f4
# Pyfunc Gradient Function
def _py_func_with_gradient(func, inp, Tout, stateful=True, name=None,
grad_func=None):
"... | 2,819 | 32.571429 | 76 | py |
SecureSGD | SecureSGD-master/MNIST/cleverhans/dataset.py | """Dataset class for CleverHans
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from cleverhans.utils_mnist import data_mnist
keras = None # Only load keras if user tries to use a dataset that requires it
class Dataset(object):
"""Abstract base... | 4,463 | 29.162162 | 79 | py |
SecureSGD | SecureSGD-master/MNIST/cleverhans/utils_keras.py | """
Model construction utilities based on keras
"""
import warnings
from distutils.version import LooseVersion
import keras
from keras.models import Sequential
from keras.layers import Dense, Activation, Flatten
from .model import Model, NoSuchLayerError
if LooseVersion(keras.__version__) >= LooseVersion('2.0.0'):
... | 8,650 | 35.348739 | 79 | py |
ASCL | ASCL-master/scl_loss.py | """
Author: Yonglong Tian (yonglong@mit.edu)
Date: May 07, 2020
"""
from __future__ import print_function
import torch
import torch.nn as nn
class SupConLoss(nn.Module):
"""Supervised Contrastive Learning: https://arxiv.org/pdf/2004.11362.pdf.
It also supports the unsupervised contrastive loss in SimCLR"""
... | 3,758 | 36.969697 | 80 | py |
ASCL | ASCL-master/pgd.py | import numpy as np
from numpy.testing._private.utils import requires_memory
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.optim as optim
from models import switch_status
def clamp(X, lower_limit, upper_limit):
return torch.max(torch.min(X, upper... | 9,920 | 35.744444 | 142 | py |
ASCL | ASCL-master/compact_loss_pt.py | from os import EX_SOFTWARE
import numpy as np
import torch
import torch.nn.functional as F
from utils import one_hot_tensor
def convert2onehot(labels, num_classes=10):
if len(labels.shape) == 2:
return labels
elif len(labels.shape) == 1:
return one_hot_tensor(labels, num_classes=num_clas... | 5,726 | 35.477707 | 110 | py |
ASCL | ASCL-master/contrastive_losses_v2.py | import torch
from torch._C import device
import torch.nn.functional as F
from distance import distance
def get_positive_mask(labels):
# ATTENTION HERE, positive mask will ignore the diagonal
# l = torch.matmul(labels, labels.T) # [2b,2b]
# m = torch.ones_like(l).fill_diagonal_(0) # [2b,2b]
# pos_ma... | 6,261 | 39.928105 | 169 | py |
ASCL | ASCL-master/contrastive_losses.py | import torch
from torch._C import device
import torch.nn.functional as F
from distance import distance
def get_positive_mask(labels):
# ATTENTION HERE, positive mask will ignore the diagonal
# l = torch.matmul(labels, labels.T) # [2b,2b]
# m = torch.ones_like(l).fill_diagonal_(0) # [2b,2b]
# pos_ma... | 7,496 | 40.41989 | 169 | py |
ASCL | ASCL-master/resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
... | 4,106 | 33.225 | 104 | py |
ASCL | ASCL-master/adr.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.optim as optim
from models import switch_status
from compact_loss_pt import local_loss, global_loss
from compact_loss_pt import mysoftmax_cross_entropy_with_two_logits as softmax_xent_t... | 6,169 | 33.088398 | 114 | py |
ASCL | ASCL-master/preactresnet.py | '''Pre-activation ResNet in PyTorch.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Identity Mappings in Deep Residual Networks. arXiv:1603.05027
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class PreActBlock(nn.Module):
'''Pre-activation version of the BasicBlock.... | 4,351 | 33.816 | 102 | py |
ASCL | ASCL-master/utils.py | import argparse
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader, TensorDataset
import torch.optim as optim
import torchvision
from collections import namedtuple
# Create heatmap data
class Grid(Dataset):
def __init__(self, t... | 8,285 | 30.625954 | 109 | py |
ASCL | ASCL-master/dataset.py | import random
import numpy as np
import torch
from torchvision import datasets, transforms
def load_mnist_data():
transform=transforms.Compose([
transforms.ToTensor(),
])
train_data = datasets.MNIST('../data', train=True, download=True,
transform=transform)
t... | 5,617 | 34.783439 | 100 | py |
ASCL | ASCL-master/02b_linear_train.py | """
Adversarial Training
Output:
- Pretrained model
Args:
- ds: 'mnist', 'cifar10', 'cifar100'
- model: 'cnn', 'resnet18', 'preactresnet18', 'wideresnet'
"""
from pgd import pgd_loss
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.ten... | 7,634 | 30.945607 | 120 | py |
ASCL | ASCL-master/models.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader, TensorDataset
import torch.optim as optim
from collections import OrderedDict
from small_cnn import *
from resnet import *
from preactresnet import *
from wideresnet import *
d... | 5,842 | 28.964103 | 109 | py |
ASCL | ASCL-master/train_cifar10.py | import argparse
import logging
import sys
import time
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.utils.tensorboard import SummaryWriter
import os
from wideresnet import WideResNet
from preactresnet import PreActResN... | 9,877 | 31.926667 | 188 | py |
ASCL | ASCL-master/02e_evaluate_robustness.py | # -*- coding: utf-8 -*-
"""
Robustness Evaluation
"""
import numpy as np
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, TensorDataset
from torchvision import datasets, transforms
from torch.utils.tensorboard import SummaryWriter
# from torchsummary import summary
from mysetting impo... | 11,832 | 38.052805 | 135 | py |
ASCL | ASCL-master/ascl.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from contrastive_losses_v2 import soft_lcscl
from scl_loss import SupConLoss
from compact_loss_pt import kl_loss_with_logits, my_norm
from pgd import pgd_attack
from utils import add_loss
def cla... | 24,660 | 36.365152 | 118 | py |
ASCL | ASCL-master/distance.py | import torch
import torch.functional as F
def distance(x, y, dist, pairwise=False):
"""
Pairwise distance
Args:
x, y: input pair
dist: distance type ["l2", "l1", "linf", "cosine"]
pairwise:
Note:
Need renormalize if using l1
"""
... | 1,613 | 27.315789 | 88 | py |
ASCL | ASCL-master/small_cnn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader, TensorDataset
import torch.optim as optim
from collections import OrderedDict
# Declare Classifier
class Toy2D(nn.Module):
def __init__(self, num_classes=3):
super(Toy2D, self).__init_... | 6,691 | 33.142857 | 63 | py |
ASCL | ASCL-master/trades.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torch.optim as optim
def squared_l2_norm(x):
flattened = x.view(x.unsqueeze(0).shape[0], -1)
return (flattened ** 2).sum(1)
def l2_norm(x):
return squared_l2_norm(x).sqrt()
"""
We follow the fi... | 4,128 | 35.866071 | 110 | py |
ASCL | ASCL-master/02a_adversarial_training.py | """
Adversarial Training
Output:
- Pretrained model
Args:
- ds: 'mnist', 'cifar10', 'cifar100'
- model: 'cnn', 'resnet18', 'preactresnet18', 'wideresnet'
"""
import numpy as np
import torch
import torch.nn as nn
from torch.utils.tensorboard import SummaryWriter
from mysetting import *
fr... | 5,949 | 31.336957 | 112 | py |
ASCL | ASCL-master/mytrain.py | from math import log
from ascl import ascl_pgd
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader, TensorDataset
from torch.autograd import Variable
import torch.optim as optim
from functools import partial
from trades import trade... | 10,122 | 36.080586 | 135 | py |
ASCL | ASCL-master/wideresnet.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
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)
self.relu1 = nn.ReLU(inplace=True)
se... | 4,102 | 40.444444 | 116 | py |
vad | vad-main/sgvad.py | import glob
import torch
from omegaconf import OmegaConf, DictConfig
from nemo.collections.asr.modules import AudioToMFCCPreprocessor, ConvASREncoder
import librosa
class SGVAD:
def __init__(self, preprocessor: AudioToMFCCPreprocessor,
model: ConvASREncoder,
cfg: DictConfig):
... | 2,262 | 36.716667 | 102 | py |
vad | vad-main/train.py | import pytorch_lightning as pl
from omegaconf import OmegaConf
from pytorch_lightning import seed_everything
from nemo.collections.asr.models import EncDecClassificationModel
from nemo.core.config import hydra_runner
from nemo.utils import logging
from nemo.utils.exp_manager import exp_manager
import time
@hydra_runn... | 981 | 32.862069 | 83 | py |
vad | vad-main/nemo/package_info.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 1,403 | 38 | 111 | py |
vad | vad-main/nemo/core/classes/loss.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 905 | 32.555556 | 74 | py |
vad | vad-main/nemo/core/classes/dataset.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 3,361 | 29.563636 | 98 | py |
vad | vad-main/nemo/core/classes/module.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 2,132 | 26.346154 | 108 | py |
vad | vad-main/nemo/core/classes/modelPT.py | # Copyright (c) 2021, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 59,024 | 42.754633 | 154 | py |
vad | vad-main/nemo/core/classes/common.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 37,026 | 42.870853 | 130 | py |
vad | vad-main/nemo/core/classes/exportable.py | # Copyright (c) 2020, 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 copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 7,593 | 36.408867 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.