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 |
|---|---|---|---|---|---|---|
Tim-TSENet | Tim-TSENet-main/TSENET/create_scp_light.py | import os
from random import shuffle
train_mix_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/tr_mix.scp'
train_s1_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/tr_s1.scp'
train_re_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/tr_re.scp'
test_mix_scp = '/apdcephfs/private_helinwa... | 2,844 | 34.123457 | 106 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/create_class_dict.py | #
event_ls_train = ['Snare_drum,Drum,Percussion,Musical_instrument,Music', 'Thump_and_thud',
'Writing,Domestic_sounds_and_home_sounds', 'Keys_jangling,Domestic_sounds_and_home_sounds',
'Scratching_(performance_technique),Musical_instrument,Music', 'Organ,Keyboard_(musical),Musical_i... | 8,183 | 89.933333 | 1,143 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/create_scp_debug.py | import os
train_mix_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps_debug/tr_mix.scp'
train_s1_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps_debug/tr_s1.scp'
train_s2_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps_debug/tr_s2.scp'
train_re_scp = '/apdcephf... | 5,313 | 33.506494 | 102 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/create_scp_inf.py | #
event_ls_train = ['Snare_drum,Drum,Percussion,Musical_instrument,Music', 'Thump_and_thud',
'Writing,Domestic_sounds_and_home_sounds', 'Keys_jangling,Domestic_sounds_and_home_sounds',
'Scratching_(performance_technique),Musical_instrument,Music', 'Organ,Keyboard_(musical),Musical_i... | 8,702 | 90.610526 | 1,143 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/create_scp_inf_light.py | #
train_inf_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/tr_inf.scp'
test_inf_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/tt_inf.scp'
val_inf_scp = '/apdcephfs/private_helinwang/tsss/TSENet/scps_light/val_inf.scp'
train_txt = '/apdcephfs/share_1316500/helinwang/data/tsss/esc_data_new2/train... | 2,610 | 29.011494 | 82 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/create_scp.py | import os
# assert 1==2
train_mix_scp = '/apdcephfs/share_1316500/donchaoyang/tsss/tsss_data/urban/scps/tr_mix.scp'
train_s1_scp = '/apdcephfs/share_1316500/donchaoyang/tsss/tsss_data/urban/scps/tr_s1.scp'
train_re_scp = '/apdcephfs/share_1316500/donchaoyang/tsss/tsss_data/urban/scps/tr_re.scp'
test_mix_scp = '/apdcep... | 2,717 | 34.763158 | 91 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/draw.py | import torchaudio
import matplotlib
import matplotlib.pyplot as plt
[width, height] = matplotlib.rcParams['figure.figsize']
if width < 10:
matplotlib.rcParams['figure.figsize'] = [width * 2.5, height]
if __name__ == "__main__":
# filename = "/apdcephfs/private_helinwang/tsss/tsss_mixed/train/train_1.wav"
f... | 775 | 32.73913 | 95 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/trainer/trainer_Tasnet.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from model.loss import get_loss
import torch
import os
import matplotlib.pyplot as plt
import numpy as np
import math
def time_to_frame(tm,st=True):
radio = 10.0/624
if st:
n_fame = tm//radio
else:... | 21,031 | 46.58371 | 259 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/trainer/__init__.py | from .trainer_Tasnet import *
| 30 | 14.5 | 29 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/trainer/trainer_Tasnet_one_hot.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from model.loss import get_loss,get_loss_one_hot
import torch
import os
import matplotlib.pyplot as plt
import numpy as np
def time_to_frame(tm,st=True):
radio = 10.0/624
if st:
n_fame = tm//radio
e... | 21,117 | 47.104784 | 259 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/data_loader/AudioData.py | import torch.nn.functional as F
from utils import util
import torch
import torchaudio
import sys
sys.path.append('../')
def read_wav(fname, return_rate=False):
'''
Read wavfile using Pytorch audio
input:
fname: wav file path
return_rate: Whether to return the sampli... | 2,751 | 30.272727 | 87 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/data_loader/Dataset.py | import sys
sys.path.append('../')
import torch
from torch.utils.data import DataLoader, Dataset
import torchaudio
from utils.util import handle_scp, handle_scp_inf
def read_wav(fname, return_rate=False):
'''
Read wavfile using Pytorch audio
input:
fname: wav file path
... | 3,439 | 39.952381 | 134 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/data_loader/__init__.py | from .AudioData import *
from .Dataset import * | 47 | 23 | 24 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/data_loader/AudioReader.py | import sys
sys.path.append('../')
import torchaudio
import torch
from utils.util import handle_scp
def read_wav(fname, return_rate=False):
'''
Read wavfile using Pytorch audio
input:
fname: wav file path
return_rate: Whether to return the sampling rate
outp... | 2,556 | 28.732558 | 82 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/config/option.py | import yaml
def parse(opt_path):
with open(opt_path, mode='r') as f:
opt = yaml.load(f,Loader=yaml.FullLoader)
opt['resume']['path'] = opt['resume']['path']+'/'+opt['name']
opt['logger']['path'] = opt['logger']['path']+'/'+opt['name']
return opt
if __name__ == "__main__":
parse('trai... | 327 | 24.230769 | 65 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/config/__init__.py | from .option import * | 21 | 21 | 21 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/logger/__init__.py | from .set_logger import * | 25 | 25 | 25 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/logger/set_logger.py | import logging
from datetime import datetime
import os
def get_timestamp():
return datetime.now().strftime('%y%m%d-%H%M%S')
def setup_logger(logger_name, root, level=logging.INFO, screen=False, tofile=False):
'''set up logger'''
lg = logging.getLogger(logger_name)
formatter = logging.Formatter('%(asct... | 990 | 32.033333 | 103 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/utils/util.py | import torch
import torch.nn as nn
def handle_scp(scp_path):
'''
Read scp file script
input:
scp_path: .scp file's file path
output:
scp_dict: {'key':'wave file path'}
'''
scp_dict = dict()
line = 0
lines = open(scp_path, 'r').readlines()
for l in lines:
... | 1,932 | 26.225352 | 79 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/utils/__init__.py | from .util import * | 19 | 19 | 19 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/model_t.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class GlobalLayerNorm(nn.Module):
'''
Calculate Global Layer Normalization
dim: (int or list or torch.Size) –
input shape from an expected input of size
eps: a value added to the denominator for numerical stability.... | 21,609 | 37.451957 | 165 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/PANNS.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
def init_layer(layer):
"""Initialize a Linear or Convolutional layer. """
nn.init.xavier_uniform_(layer.weight)
if hasattr(l... | 4,628 | 38.905172 | 107 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/loss.py | import torch
import numpy as np
def nll_loss(output, target):
'''Negative likelihood loss. The output should be obtained using F.log_softmax(x).
Args:
output: (N, classes_num)
target: (N, classes_num)
'''
loss = - torch.mean(target * output)
return loss
def sisnr_loss(x, s, eps=1e-8):
... | 14,345 | 42.34139 | 156 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/model.py | import torch
from torch import nn
import torch.nn.functional as F
import sys
sys.path.append('../')
from utils.util import check_parameters
from model.PANNS import CNN10
from model.tsd import TSD
import math
def init_kernel(frame_len,
frame_hop,
num_fft=None,
window="sqr... | 32,316 | 39.497494 | 165 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/__init__.py | from .loss import *
from .model import * | 40 | 19.5 | 20 | py |
Tim-TSENet | Tim-TSENet-main/TSENET/model/tsd.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torchlibrosa.stft import Spectrogram, LogmelFilterBank
def init_layer(layer):
"""Initialize a Linear or Convolutional layer. """
nn.init.xavier_uniform_(layer.weight)
if hasattr(layer, 'bias'):
if layer.bias is not None:
... | 5,798 | 33.517857 | 109 | py |
Tim-TSENet | Tim-TSENet-main/generate_dataset/generate_data_fsd_kaggle2.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
import random
from utilities import create_folder, get_filename
from models import *
from pytorch_utils import move_data_to_device
import config
... | 46,868 | 46.874362 | 170 | py |
Tim-TSENet | Tim-TSENet-main/generate_dataset/create_scp.py | import os
train_mix_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps/tr_mix.scp'
train_s1_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps/tr_s1.scp'
train_re_scp = '/apdcephfs/private_helinwang/tsss/Dual-Path-RNN-Pytorch/scps/tr_re.scp'
test_mix_scp = '/apdcephfs/private_helinwa... | 2,673 | 34.653333 | 89 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/test_tasnet_one_hot.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model import TSDNet,TSDNet_one_hot,TSDNet_plus_one_hot
from logger.set_logger import setup_logger
import logging
from config.option import parse
import torchaudio
from... | 9,953 | 48.034483 | 171 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/test_tasnet_wav.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav, read_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model import Conv_TasNet
from logger.set_logger import setup_logger
import logging
from config.option import parse
import tqdm
class Separation():
def ... | 2,864 | 37.2 | 104 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/test_tasnet.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model import TSDNet,TSDNet_one_hot
from logger.set_logger import setup_logger
import logging
from config.option import parse
import torchaudio
from utils.util import h... | 9,282 | 48.116402 | 167 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/train_Tasnet.py | import sys
sys.path.append('./')
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.utils.data import DataLoader as Loader
from data_loader.Dataset_light import Datasets
from model.model import TSDNet,TSDNet_one_hot, TSDNet_plus_one_hot
from logger import set_logger
import logging
from config import opt... | 7,358 | 46.477419 | 145 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/tsd_utils.py | import collections
import sys
from loguru import logger
from pprint import pformat
import numpy as np
import pandas as pd
import scipy
import six
import sklearn.preprocessing as pre
import torch
import tqdm
import yaml
import augment
#import dataset
from scipy.interpolate import interp1d
def parse_config_or_kwargs(c... | 13,313 | 35.377049 | 169 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/train_rnn.py | import sys
sys.path.append('./')
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.utils.data import DataLoader as Loader
from data_loader.Dataset import Datasets
from model import model_rnn
from logger import set_logger
import logging
from config import option
import argparse
import torch
from trainer... | 3,546 | 37.554348 | 114 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/train_Tasnet_tse.py | import sys
sys.path.append('./')
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.utils.data import DataLoader as Loader
from data_loader.Dataset_light import Datasets_tse # using add tse results
from model.model import TSDNet_tse,TSDNet_one_hot, TSDNet_plus_one_hot
from logger import set_logger
impor... | 7,255 | 47.373333 | 131 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/dualrnn_test_wav.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav, read_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model_rnn import Dual_RNN_model
from logger.set_logger import setup_logger
import logging
from config.option import parse
import tqdm
class Separation():
... | 2,918 | 38.986301 | 105 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/augment.py | import torch
import logging
import torch.nn as nn
import numpy as np
class TimeShift(nn.Module):
def __init__(self, mean, std):
super().__init__()
self.mean = mean
self.std = std
def forward(self, x):
if self.training:
shift = torch.empty(1).normal_(self.mean, self... | 1,333 | 23.703704 | 76 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/utils.py | 0 | 0 | 0 | py | |
Tim-TSENet | Tim-TSENet-main/TSDNET/test_tasnet_tse.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model import TSDNet,TSDNet_one_hot, TSDNet_tse
from logger.set_logger import setup_logger
import logging
from config.option import parse
import torchaudio
from utils.u... | 10,323 | 50.108911 | 214 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/metrics.py | import sed_eval
import tsd_utils as utils
import pandas as pd
from sklearn.preprocessing import binarize, MultiLabelBinarizer
import sklearn.metrics as skmetrics
import numpy as np
def get_audio_tagging_df(df):
return df.groupby('filename')['event_label'].unique().reset_index()
def audio_tagging_results(referen... | 7,386 | 38.715054 | 118 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/draw.py | import torchaudio
import matplotlib
import matplotlib.pyplot as plt
[width, height] = matplotlib.rcParams['figure.figsize']
if width < 10:
matplotlib.rcParams['figure.figsize'] = [width * 2.5, height]
if __name__ == "__main__":
# filename = "/apdcephfs/private_helinwang/tsss/tsss_mixed/train/train_1.wav"
f... | 775 | 32.73913 | 95 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/test_tasnet_one_hot_reg.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model import TSDNet,TSDNet_one_hot,TSDNet_plus_one_hot
from logger.set_logger import setup_logger
import logging
from config.option import parse
import torchaudio
from... | 11,496 | 45.358871 | 170 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/dualrnn_test.py | import os
import torch
from data_loader.AudioReader import AudioReader, write_wav
import argparse
from torch.nn.parallel import data_parallel
from model.model_rnn import Dual_RNN_model
from logger.set_logger import setup_logger
import logging
from config.option import parse
import tqdm
class Separation():
def __i... | 3,384 | 40.790123 | 105 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/trainer_Tasnet_tse.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from logger.set_logger import setup_logger
from model.loss import get_loss
import torch
import os
import matplotlib.pyplot as plt
from torch.nn.parallel import data_parallel
class Trainer(object):
def __init__(sel... | 13,121 | 44.404844 | 146 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/trainer_Tasnet_one_hot_regresion.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from logger.set_logger import setup_logger
from model.loss import get_loss, get_loss_one_hot, get_loss_one_hot_focal, get_loss_one_hot_focal_sim,get_loss_one_hot_reg,get_loss_one_hot_reg_two
import torch
import os
impo... | 14,648 | 47.506623 | 147 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/trainer_Dual_RNN.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from logger.set_logger import setup_logger
from model.loss import Loss
import torch
import os
import matplotlib.pyplot as plt
from torch.nn.parallel import data_parallel
class Trainer(object):
def __init__(self,... | 8,747 | 39.5 | 112 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/trainer_Tasnet.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from logger.set_logger import setup_logger
from model.loss import get_loss
import torch
import os
import matplotlib.pyplot as plt
from torch.nn.parallel import data_parallel
class Trainer(object):
def __init__(sel... | 12,954 | 44.297203 | 146 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/__init__.py | from .trainer_Tasnet import *
| 30 | 14.5 | 29 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/trainer/trainer_Tasnet_one_hot.py | import sys
sys.path.append('../')
from utils.util import check_parameters
import time
import logging
from logger.set_logger import setup_logger
from model.loss import get_loss, get_loss_one_hot, get_loss_one_hot_focal, get_loss_one_hot_focal_sim
import torch
import os
import matplotlib.pyplot as plt
from torch.nn.para... | 15,168 | 48.734426 | 146 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/data_loader/AudioData.py | import torch.nn.functional as F
from utils import util
import torch
import torchaudio
import sys
sys.path.append('../')
def read_wav(fname, return_rate=False):
'''
Read wavfile using Pytorch audio
input:
fname: wav file path
return_rate: Whether to return the sampli... | 2,751 | 30.272727 | 87 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/data_loader/Dataset.py | import sys
sys.path.append('../')
from data_loader.AudioData import AudioReader
import torch
from torch.utils.data import Dataset
import numpy as np
class Datasets(Dataset):
'''
Load audio data
mix_scp: file path of mix audio (type: str)
ref_scp: file path of ground truth audio (type: list[... | 1,666 | 36.886364 | 183 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/data_loader/__init__.py | from .AudioData import *
from .Dataset import * | 47 | 23 | 24 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/data_loader/AudioReader.py | import sys
sys.path.append('../')
import torchaudio
import torch
from utils.util import handle_scp
def read_wav(fname, return_rate=False):
'''
Read wavfile using Pytorch audio
input:
fname: wav file path
return_rate: Whether to return the sampling rate
outp... | 2,556 | 28.732558 | 82 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/data_loader/Dataset_light.py | import sys
sys.path.append('../')
import torch
from torch.utils.data import DataLoader, Dataset
import torch.nn.functional as F
import random
import numpy as np
import soundfile as sf
import torchaudio
from utils.util import handle_scp, handle_scp_inf
from model.model import STFT
import os
import pickle
import math
nFr... | 9,413 | 37.740741 | 191 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/config/option.py | import yaml
def parse(opt_path):
with open(opt_path, mode='r') as f:
opt = yaml.load(f,Loader=yaml.FullLoader)
opt['resume']['path'] = opt['resume']['path']+'/'+opt['name']
opt['logger']['path'] = opt['logger']['path']+'/'+opt['name']
return opt
if __name__ == "__main__":
parse('trai... | 327 | 24.230769 | 65 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/config/__init__.py | from .option import * | 21 | 21 | 21 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/logger/__init__.py | from .set_logger import * | 25 | 25 | 25 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/logger/set_logger.py | import logging
from datetime import datetime
import os
def get_timestamp():
return datetime.now().strftime('%y%m%d-%H%M%S')
def setup_logger(logger_name, root, level=logging.INFO, screen=False, tofile=False):
'''set up logger'''
lg = logging.getLogger(logger_name)
formatter = logging.Formatter('%(asct... | 990 | 32.033333 | 103 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/utils/util.py | import torch
import torch.nn as nn
def handle_scp(scp_path):
'''
Read scp file script
input:
scp_path: .scp file's file path
output:
scp_dict: {'key':'wave file path'}
'''
scp_dict = dict()
line = 0
lines = open(scp_path, 'r').readlines()
for l in lines:
... | 1,932 | 26.225352 | 79 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/utils/get_sed_label.py | import pandas as pd
save_name = []
save_onset = []
save_offset = []
save_event = []
with open('/apdcephfs/share_1316500/donchaoyang/tsss/tsss_data/fsd_2018/scps/val_inf_new.scp', 'r') as file:
for line in file:
split_line = line.strip().split(' ')
save_name.append(split_line[0])
#target_audi... | 789 | 38.5 | 108 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/utils/__init__.py | from .util import * | 19 | 19 | 19 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/model_rnn.py | import sys
sys.path.append('../')
import torch.nn.functional as F
from torch import nn
import torch
from utils.util import check_parameters
import warnings
warnings.filterwarnings('ignore')
class GlobalLayerNorm(nn.Module):
'''
Calculate Global Layer Normalization
dim: (int or list or torch.Size) ... | 15,142 | 35.314149 | 131 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/PANNS.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
def init_layer(layer):
"""Initialize a Linear or Convolutional layer. """
nn.init.xavier_uniform_(layer.weight)
if hasattr(l... | 5,456 | 39.422222 | 107 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/loss.py | import torch
from itertools import permutations
import numpy as np
from pypesq import pesq
import torch.nn as nn
class FocalLoss(nn.Module):
def __init__(self,alpha=0.35, gamma=2):
super(FocalLoss,self).__init__()
self.gamma = gamma
self.alpha = alpha
self.eps = 1e-9
#self.bc... | 7,028 | 29.428571 | 121 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/model.py | import torch
from torch import nn
import torch.nn.functional as F
import sys
sys.path.append('../')
from utils.util import check_parameters
from model.PANNS import CNN10
from model.tsd import TSD, TSD2, TSD2_tse, TSD_plus, TSD_plus_sim, TSD_IS,TSD_regresion,TSD_regresion_two_cls
import math
def init_kernel(frame_len,
... | 31,331 | 38.067332 | 177 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/model_tf.py | import torch
from torch import nn
import torch.nn.functional as F
import sys
import pickle
sys.path.append('../')
from utils.util import check_parameters
from model.PANNS import ResNet38, CNN10
from model.tsd import TSD
def init_kernel(frame_len,
frame_hop,
num_fft=None,
... | 17,741 | 34.342629 | 129 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/__init__.py | from .loss import *
from .model import * | 40 | 19.5 | 20 | py |
Tim-TSENet | Tim-TSENet-main/TSDNET/model/tsd.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
def init_layer(layer):
"""Initialize a Linear or Convolutional layer. """
nn.init.xavier_uniform_(layer.weight)
if hasattr(lay... | 37,974 | 41.100887 | 109 | py |
SOF-VSR | SOF-VSR-master/TIP/modules.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
class SOFVSR(nn.Module):
def __init__(self, cfg, n_frames=3, is_training=True):
super(SOFVSR, self).__init__()
self.scale = cfg.scale
self.is_training = is_training
... | 8,356 | 37.334862 | 132 | py |
SOF-VSR | SOF-VSR-master/TIP/data_utils.py | from PIL import Image
from torch.utils.data.dataset import Dataset
from modules import optical_flow_warp
import numpy as np
import os
import torch
import random
class TrainsetLoader(Dataset):
def __init__(self, cfg):
super(TrainsetLoader).__init__()
self.trainset_dir = cfg.trainset_dir
self... | 7,589 | 36.389163 | 143 | py |
SOF-VSR | SOF-VSR-master/TIP/train.py | from torch.autograd import Variable
from torch.utils.data import DataLoader
from modules import SOFVSR
from data_utils import TrainsetLoader, OFR_loss
import torch.backends.cudnn as cudnn
import argparse
import torch
import numpy as np
import torch.nn.functional as F
import os
def parse_args():
parser = argparse.... | 3,333 | 31.686275 | 100 | py |
SOF-VSR | SOF-VSR-master/TIP/demo_Vid4.py | from torch.autograd import Variable
from torch.utils.data import DataLoader
from data_utils import TestsetLoader, ycbcr2rgb
from modules import SOFVSR
from torchvision.transforms import ToPILImage
import numpy as np
import os
import argparse
import torch
def parse_args():
parser = argparse.ArgumentParser()
pa... | 4,835 | 39.3 | 154 | py |
SOF-VSR | SOF-VSR-master/ACCV/modules.py | import torch
import torch.nn as nn
import numpy as np
from torch.autograd import Variable
import torch.nn.functional as F
import matplotlib.pyplot as plt
def optical_flow_warp(image, image_optical_flow):
"""
Arguments
image_ref: reference images tensor, (b, c, h, w)
image_optical_flow: optical ... | 8,788 | 46.766304 | 169 | py |
SOF-VSR | SOF-VSR-master/ACCV/data_utils.py | import numpy as np
from PIL import Image
import os
import torch
from torch.utils.data.dataset import Dataset
import math
import random
class TrainsetLoader(Dataset):
def __init__(self, trainset_dir, upscale_factor, patch_size, n_iters):
super(TrainsetLoader).__init__()
self.trainset_dir = trainset_... | 6,999 | 40.666667 | 143 | py |
SOF-VSR | SOF-VSR-master/ACCV/train.py | import os
import torch
from torch.autograd import Variable
from torch.utils.data import DataLoader
import torch.backends.cudnn as cudnn
from modules import SOFVSR, optical_flow_warp
import argparse
from data_utils import TrainsetLoader
import numpy as np
import matplotlib.pyplot as plt
def parse_args():
parser = ... | 3,641 | 38.16129 | 129 | py |
SOF-VSR | SOF-VSR-master/ACCV/demo_Vid4.py | import torch
from torch.autograd import Variable
from torch.utils.data import DataLoader
from data_utils import TestsetLoader, ycbcr2rgb
import numpy as np
from torchvision.transforms import ToPILImage
import os
import argparse
from modules import SOFVSR
import math
def parse_args():
parser = argparse.ArgumentPars... | 3,762 | 37.010101 | 106 | py |
SOF-VSR | SOF-VSR-master/ACCV/metrics/evaluation.py | import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
from math import log10
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size // 2) ** 2 / float(2 * sigma ** 2)) for x in range(window_size)])
return gauss / gauss.s... | 2,423 | 40.793103 | 114 | py |
finmag | finmag-master/install/memory-warning.py | import sys
from psutil import virtual_memory
mem = virtual_memory()
mem.total # total physical virtual_memory
GB = float(1024**3) # float need if we run with python 2
if mem.total / GB < 3.8:
print("Warning: building native modules may fail due to not enough physical memory.")
print("You have {:.1f} GB av... | 944 | 41.954545 | 108 | py |
finmag | finmag-master/install/user-only-system/test_libraries.py | def test_dolfin():
import dolfin
print("Found dolfin %s" % dolfin.__version__)
def test_scipy():
import scipy
print("Found scipy %s" % scipy.__version__)
def test_numpy():
import numpy
print("Found numpy %s" % numpy.__version__)
def test_matplotlib():
import matplotlib
print("Found ma... | 1,011 | 25.631579 | 76 | py |
finmag | finmag-master/examples/exchange_demag/simple_1D_finmag.py | import dolfin as df
from finmag.field import Field
from finmag.energies import Exchange
import numpy as np
import matplotlib.pylab as plt
import os
import subprocess
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
# run nmag
subprocess.call("nsim {} --clean".format(os.path.join(MODULE_DIR, "simple_1D_nmag.py"... | 2,129 | 32.809524 | 100 | py |
finmag | finmag-master/examples/exchange_demag/run_nmag.py | import nmag
from nmag import SI
mat_Py = nmag.MagMaterial(name="Py",
Ms=SI(0.86e6,"A/m"),
exchange_coupling=SI(13.0e-12, "J/m"),
llg_damping=0.5)
sim = nmag.Simulation("bar")
sim.load_mesh("bar30_30_100.nmesh.h5",
[("Py", mat... | 1,158 | 30.324324 | 90 | py |
finmag | finmag-master/examples/exchange_demag/simple_1D_nmag.py | import numpy as np
import nmag, os
from nmag import SI
import nmeshlib.unidmesher as unidmesher
def main():
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
L = 10
mesh_unit = SI(1e-9, "m") # mesh unit (1 nm)
layers = [(0.0, L)] # the mesh
discretization = 0.1 # discretiza... | 1,054 | 25.375 | 89 | py |
finmag | finmag-master/examples/exchange_demag/test_exchange_demag.py | import os
import logging
import matplotlib
matplotlib.use('Agg')
import pylab as p
import numpy as np
import dolfin as df
from finmag import Simulation as Sim
from finmag.energies import Exchange, Demag
from finmag.util.meshes import from_geofile, mesh_volume
import pytest
logger = logging.getLogger(name='finmag')
M... | 10,063 | 36.412639 | 114 | py |
finmag | finmag-master/examples/exchange_demag/ztest_exchange_demag_new.py | """ What is this file? It appears that Gabrial has taken the test_exchange_demag.py and
tried to add the GCR solver for the nmag 2 example. The test fails as the system seems to
hang somewhere.
He then copied that file from test_exchange_demag.py to ztest_exchange_demag_new.py. Note
the z in the beginning which prev... | 11,768 | 39.723183 | 123 | py |
finmag | finmag-master/examples/exchange_demag/timings/run_nmag.py | import os, time
import nmag
from nmag import SI
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
setupstart=time.time()
mat_Py = nmag.MagMaterial(name="Py",
Ms=SI(0.86e6,"A/m"),
exchange_coupling=SI(13.0e-12, "J/m"),
llg_damping=0.5)... | 906 | 23.513514 | 64 | py |
finmag | finmag-master/examples/exchange_demag/timings/run_finmag.py | import commands
import os
import time
import pprint
import dolfin as df
from aeon import timer
from finmag.util.meshes import from_geofile
from finmag import Simulation
from finmag.energies import Exchange, Demag
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
####
# Run the nmag2 example on nmag and finmag ... | 2,248 | 31.594203 | 114 | py |
finmag | finmag-master/examples/time-dependent-applied-field/test_appfield.py | import os
import numpy as np
import pylab
import pytest
import dolfin as df
from finmag.field import Field
from finmag.physics.llg import LLG
from finmag.energies import TimeZeeman
from finmag.drivers.llg_integrator import llg_integrator
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
@pytest.mark.requires_X... | 4,134 | 31.81746 | 102 | py |
finmag | finmag-master/examples/scheduling/sim_with_scheduling.py | import logging
import dolfin as df
from finmag import Simulation
from finmag.energies import Exchange, Demag, Zeeman
log = logging.getLogger(name="finmag")
log.setLevel(logging.ERROR) # To better show output of this program.
# Three example functions that will be added to the schedule.
# They will get called with the... | 1,445 | 27.352941 | 93 | py |
finmag | finmag-master/examples/scheduling/sim_with_progressbar.py | import sys
import logging
from sim_with_scheduling import example_simulation
log = logging.getLogger(name="finmag")
log.setLevel(logging.ERROR) # To better show output of this program.
# This script will update a progress bar on the screen while the simulation runs.
sim = example_simulation()
# Sets up the progress... | 814 | 24.46875 | 81 | py |
finmag | finmag-master/examples/scheduling/sim_with_notification.py | try:
import pynotify
except ImportError:
print "You need the Python bindings to libnotify for this example to work."
print "On Ubuntu, install the package 'python-notify'."
raise
from sim_with_scheduling import example_simulation
# This script will show a notification on the screen when the simulation... | 1,082 | 32.84375 | 83 | py |
finmag | finmag-master/examples/magnetic_grain/suess_2001.py | import time
import numpy as np
import matplotlib.pyplot as plt
from finmag.util.meshes import cylinder
from finmag.util.consts import flux_density_to_field_strength
from finmag.util.helpers import spherical_to_cartesian
from finmag import Simulation
from finmag.energies import Exchange, Zeeman, UniaxialAnisotropy, Dema... | 1,659 | 26.213115 | 77 | py |
finmag | finmag-master/examples/edge_damping/damping.py | import numpy as np
import dolfin as df
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
def damping_expression(alpha, xmin, xmax, width):
"""
Exponentially increasing damping at the edges along the x-axis.
Will increase alpha from its starting value `alpha` to 1 in a region
les... | 2,211 | 30.15493 | 107 | py |
finmag | finmag-master/examples/std_prob_3/run.py | import os
import time
import logging
import numpy as np
import dolfin as df
from scipy.optimize import bisect
from finmag import Simulation
from finmag.energies import UniaxialAnisotropy, Exchange, Demag
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
"""
Micromag Standard Problem #3
specification:
http:... | 3,406 | 32.732673 | 92 | py |
finmag | finmag-master/examples/std_prob_3/table_for_doc.py | import os
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
def write_table():
with open(os.path.join(MODULE_DIR, "data_energies.txt")) as f:
lines = f.readlines()
vor = lines[-2].split()
flo = lines[-1].split()
with open(os.path.join(MODULE_DIR, "table_template.txt")) as f:
tabl... | 653 | 31.7 | 72 | py |
finmag | finmag-master/examples/dispersion_curves/dispersion.py | import os
import subprocess
import numpy as np
import dolfin as df
from numpy import fft
from finmag import Simulation as Sim
from finmag.energies import Exchange, Demag, TimeZeeman
from finmag.util.meshes import from_geofile
meshfile = "width_modulated_bar.geo"
mesh = from_geofile(meshfile)
x0 = -540; x1 = -x0; dx_hi... | 3,525 | 31.348624 | 95 | py |
finmag | finmag-master/examples/std_prob_4/plot_averages.py | import os
import numpy as np
import matplotlib.pyplot as plt
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
# plots of average magnetisation components
averages_martinez = os.path.join(MODULE_DIR, "m_averages_ref_martinez.txt")
ref_t, ref_mx, ref_my, ref_mz = np.loadtxt(averages_martinez, unpack=True)
plt.p... | 942 | 33.925926 | 83 | py |
finmag | finmag-master/examples/std_prob_4/test_std_prob_4.py | import os
import pytest
import numpy as np
import dolfin as df
import matplotlib.pyplot as plt
from aeon import timer
from math import sqrt
from finmag.util.meshes import from_geofile
from finmag.util.consts import mu0
from finmag import Simulation
from finmag.energies import Zeeman, Demag, Exchange
MODULE_DIR = os.pa... | 4,362 | 29.089655 | 119 | py |
finmag | finmag-master/examples/llb/macrospin.py | import dolfin as df
import numpy as np
import matplotlib.pyplot as plt
from finmag.energies import Zeeman
from finmag.energies import Demag
from finmag.physics.llb.exchange import Exchange
from finmag.physics.llb.anisotropy import LLBAnisotropy
from finmag.physics.llb.material import Material
from finmag.physics.llb.l... | 3,279 | 20.578947 | 77 | py |
finmag | finmag-master/examples/nmag_example_2/run_nmag.py | import time
import nmag
from nmag import SI
start = time.time()
mat_Py = nmag.MagMaterial(name="Py",
Ms=SI(0.86e6,"A/m"),
exchange_coupling=SI(13.0e-12, "J/m"),
llg_damping=0.5)
sim = nmag.Simulation("nmag_bar")
sim.load_mesh("bar.nmesh.h... | 645 | 22.925926 | 65 | py |
finmag | finmag-master/examples/nmag_example_2/run_finmag.py | from aeon import timer
from finmag import Simulation
from finmag.energies import Exchange, Demag
from finmag.util.meshes import from_geofile
def run_simulation(verbose=False):
mesh = from_geofile('bar.geo')
sim = Simulation(mesh, Ms=0.86e6, unit_length=1e-9, name="finmag_bar")
sim.set_m((1, 0, 1))
si... | 830 | 26.7 | 97 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.