Delete lib_v5 directory
@ -1,170 +0,0 @@
|
||||
import os
|
||||
import random
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
import torch.utils.data
|
||||
from tqdm import tqdm
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class VocalRemoverValidationSet(torch.utils.data.Dataset):
|
||||
|
||||
def __init__(self, patch_list):
|
||||
self.patch_list = patch_list
|
||||
|
||||
def __len__(self):
|
||||
return len(self.patch_list)
|
||||
|
||||
def __getitem__(self, idx):
|
||||
path = self.patch_list[idx]
|
||||
data = np.load(path)
|
||||
|
||||
X, y = data['X'], data['y']
|
||||
|
||||
X_mag = np.abs(X)
|
||||
y_mag = np.abs(y)
|
||||
|
||||
return X_mag, y_mag
|
||||
|
||||
|
||||
def make_pair(mix_dir, inst_dir):
|
||||
input_exts = ['.wav', '.m4a', '.mp3', '.mp4', '.flac']
|
||||
|
||||
X_list = sorted([
|
||||
os.path.join(mix_dir, fname)
|
||||
for fname in os.listdir(mix_dir)
|
||||
if os.path.splitext(fname)[1] in input_exts])
|
||||
y_list = sorted([
|
||||
os.path.join(inst_dir, fname)
|
||||
for fname in os.listdir(inst_dir)
|
||||
if os.path.splitext(fname)[1] in input_exts])
|
||||
|
||||
filelist = list(zip(X_list, y_list))
|
||||
|
||||
return filelist
|
||||
|
||||
|
||||
def train_val_split(dataset_dir, split_mode, val_rate, val_filelist):
|
||||
if split_mode == 'random':
|
||||
filelist = make_pair(
|
||||
os.path.join(dataset_dir, 'mixtures'),
|
||||
os.path.join(dataset_dir, 'instruments'))
|
||||
|
||||
random.shuffle(filelist)
|
||||
|
||||
if len(val_filelist) == 0:
|
||||
val_size = int(len(filelist) * val_rate)
|
||||
train_filelist = filelist[:-val_size]
|
||||
val_filelist = filelist[-val_size:]
|
||||
else:
|
||||
train_filelist = [
|
||||
pair for pair in filelist
|
||||
if list(pair) not in val_filelist]
|
||||
elif split_mode == 'subdirs':
|
||||
if len(val_filelist) != 0:
|
||||
raise ValueError('The `val_filelist` option is not available in `subdirs` mode')
|
||||
|
||||
train_filelist = make_pair(
|
||||
os.path.join(dataset_dir, 'training/mixtures'),
|
||||
os.path.join(dataset_dir, 'training/instruments'))
|
||||
|
||||
val_filelist = make_pair(
|
||||
os.path.join(dataset_dir, 'validation/mixtures'),
|
||||
os.path.join(dataset_dir, 'validation/instruments'))
|
||||
|
||||
return train_filelist, val_filelist
|
||||
|
||||
|
||||
def augment(X, y, reduction_rate, reduction_mask, mixup_rate, mixup_alpha):
|
||||
perm = np.random.permutation(len(X))
|
||||
for i, idx in enumerate(tqdm(perm)):
|
||||
if np.random.uniform() < reduction_rate:
|
||||
y[idx] = spec_utils.reduce_vocal_aggressively(X[idx], y[idx], reduction_mask)
|
||||
|
||||
if np.random.uniform() < 0.5:
|
||||
# swap channel
|
||||
X[idx] = X[idx, ::-1]
|
||||
y[idx] = y[idx, ::-1]
|
||||
if np.random.uniform() < 0.02:
|
||||
# mono
|
||||
X[idx] = X[idx].mean(axis=0, keepdims=True)
|
||||
y[idx] = y[idx].mean(axis=0, keepdims=True)
|
||||
if np.random.uniform() < 0.02:
|
||||
# inst
|
||||
X[idx] = y[idx]
|
||||
|
||||
if np.random.uniform() < mixup_rate and i < len(perm) - 1:
|
||||
lam = np.random.beta(mixup_alpha, mixup_alpha)
|
||||
X[idx] = lam * X[idx] + (1 - lam) * X[perm[i + 1]]
|
||||
y[idx] = lam * y[idx] + (1 - lam) * y[perm[i + 1]]
|
||||
|
||||
return X, y
|
||||
|
||||
|
||||
def make_padding(width, cropsize, offset):
|
||||
left = offset
|
||||
roi_size = cropsize - left * 2
|
||||
if roi_size == 0:
|
||||
roi_size = cropsize
|
||||
right = roi_size - (width % roi_size) + left
|
||||
|
||||
return left, right, roi_size
|
||||
|
||||
|
||||
def make_training_set(filelist, cropsize, patches, sr, hop_length, n_fft, offset):
|
||||
len_dataset = patches * len(filelist)
|
||||
|
||||
X_dataset = np.zeros(
|
||||
(len_dataset, 2, n_fft // 2 + 1, cropsize), dtype=np.complex64)
|
||||
y_dataset = np.zeros(
|
||||
(len_dataset, 2, n_fft // 2 + 1, cropsize), dtype=np.complex64)
|
||||
|
||||
for i, (X_path, y_path) in enumerate(tqdm(filelist)):
|
||||
X, y = spec_utils.cache_or_load(X_path, y_path, sr, hop_length, n_fft)
|
||||
coef = np.max([np.abs(X).max(), np.abs(y).max()])
|
||||
X, y = X / coef, y / coef
|
||||
|
||||
l, r, roi_size = make_padding(X.shape[2], cropsize, offset)
|
||||
X_pad = np.pad(X, ((0, 0), (0, 0), (l, r)), mode='constant')
|
||||
y_pad = np.pad(y, ((0, 0), (0, 0), (l, r)), mode='constant')
|
||||
|
||||
starts = np.random.randint(0, X_pad.shape[2] - cropsize, patches)
|
||||
ends = starts + cropsize
|
||||
for j in range(patches):
|
||||
idx = i * patches + j
|
||||
X_dataset[idx] = X_pad[:, :, starts[j]:ends[j]]
|
||||
y_dataset[idx] = y_pad[:, :, starts[j]:ends[j]]
|
||||
|
||||
return X_dataset, y_dataset
|
||||
|
||||
|
||||
def make_validation_set(filelist, cropsize, sr, hop_length, n_fft, offset):
|
||||
patch_list = []
|
||||
patch_dir = 'cs{}_sr{}_hl{}_nf{}_of{}'.format(cropsize, sr, hop_length, n_fft, offset)
|
||||
os.makedirs(patch_dir, exist_ok=True)
|
||||
|
||||
for i, (X_path, y_path) in enumerate(tqdm(filelist)):
|
||||
basename = os.path.splitext(os.path.basename(X_path))[0]
|
||||
|
||||
X, y = spec_utils.cache_or_load(X_path, y_path, sr, hop_length, n_fft)
|
||||
coef = np.max([np.abs(X).max(), np.abs(y).max()])
|
||||
X, y = X / coef, y / coef
|
||||
|
||||
l, r, roi_size = make_padding(X.shape[2], cropsize, offset)
|
||||
X_pad = np.pad(X, ((0, 0), (0, 0), (l, r)), mode='constant')
|
||||
y_pad = np.pad(y, ((0, 0), (0, 0), (l, r)), mode='constant')
|
||||
|
||||
len_dataset = int(np.ceil(X.shape[2] / roi_size))
|
||||
for j in range(len_dataset):
|
||||
outpath = os.path.join(patch_dir, '{}_p{}.npz'.format(basename, j))
|
||||
start = j * roi_size
|
||||
if not os.path.exists(outpath):
|
||||
np.savez(
|
||||
outpath,
|
||||
X=X_pad[:, :, start:start + cropsize],
|
||||
y=y_pad[:, :, start:start + cropsize])
|
||||
patch_list.append(outpath)
|
||||
|
||||
return VocalRemoverValidationSet(patch_list)
|
@ -1,423 +0,0 @@
|
||||
import json
|
||||
|
||||
def get_vr_download_list(list):
|
||||
with open("lib_v5/filelists/download_lists/vr_download_list.txt", "r") as f:
|
||||
text=f.read().splitlines()
|
||||
|
||||
list = text
|
||||
|
||||
return list
|
||||
|
||||
def get_mdx_download_list(list):
|
||||
with open("lib_v5/filelists/download_lists/mdx_download_list.txt", "r") as f:
|
||||
text=f.read().splitlines()
|
||||
|
||||
list = text
|
||||
|
||||
return list
|
||||
|
||||
def get_demucs_download_list(list):
|
||||
with open("lib_v5/filelists/download_lists/demucs_download_list.txt", "r") as f:
|
||||
text=f.read().splitlines()
|
||||
|
||||
list = text
|
||||
|
||||
return list
|
||||
|
||||
def get_mdx_demucs_en_list(list):
|
||||
with open("lib_v5/filelists/ensemble_list/mdx_demuc_en_list.txt", "r") as f:
|
||||
text=f.read().splitlines()
|
||||
|
||||
list = text
|
||||
|
||||
return list
|
||||
|
||||
def get_vr_en_list(list):
|
||||
with open("lib_v5/filelists/ensemble_list/vr_en_list.txt", "r") as f:
|
||||
text=f.read().splitlines()
|
||||
|
||||
list = text
|
||||
|
||||
return list
|
||||
|
||||
def get_download_links(links, downloads=''):
|
||||
|
||||
f = open(f"lib_v5/filelists/download_lists/download_links.json")
|
||||
download_links = json.load(f)
|
||||
|
||||
if downloads == 'Demucs v3: mdx':
|
||||
url_1 = download_links['Demucs_v3_mdx_url_1']
|
||||
url_2 = download_links['Demucs_v3_mdx_url_2']
|
||||
url_3 = download_links['Demucs_v3_mdx_url_3']
|
||||
url_4 = download_links['Demucs_v3_mdx_url_4']
|
||||
url_5 = download_links['Demucs_v3_mdx_url_5']
|
||||
|
||||
links = url_1, url_2, url_3, url_4, url_5
|
||||
|
||||
|
||||
if downloads == 'Demucs v3: mdx_q':
|
||||
url_1 = download_links['Demucs_v3_mdx_q_url_1']
|
||||
url_2 = download_links['Demucs_v3_mdx_q_url_2']
|
||||
url_3 = download_links['Demucs_v3_mdx_q_url_3']
|
||||
url_4 = download_links['Demucs_v3_mdx_q_url_4']
|
||||
url_5 = download_links['Demucs_v3_mdx_q_url_5']
|
||||
|
||||
links = url_1, url_2, url_3, url_4, url_5
|
||||
|
||||
if downloads == 'Demucs v3: mdx_extra':
|
||||
url_1 = download_links['Demucs_v3_mdx_extra_url_1']
|
||||
url_2 = download_links['Demucs_v3_mdx_extra_url_2']
|
||||
url_3 = download_links['Demucs_v3_mdx_extra_url_3']
|
||||
url_4 = download_links['Demucs_v3_mdx_extra_url_4']
|
||||
url_5 = download_links['Demucs_v3_mdx_extra_url_5']
|
||||
|
||||
links = url_1, url_2, url_3, url_4, url_5
|
||||
|
||||
if downloads == 'Demucs v3: mdx_extra_q':
|
||||
url_1 = download_links['Demucs_v3_mdx_extra_q_url_1']
|
||||
url_2 = download_links['Demucs_v3_mdx_extra_q_url_2']
|
||||
url_3 = download_links['Demucs_v3_mdx_extra_q_url_3']
|
||||
url_4 = download_links['Demucs_v3_mdx_extra_q_url_4']
|
||||
url_5 = download_links['Demucs_v3_mdx_extra_q_url_5']
|
||||
|
||||
links = url_1, url_2, url_3, url_4, url_5
|
||||
|
||||
if downloads == 'Demucs v3: UVR Models':
|
||||
url_1 = download_links['Demucs_v3_UVR_url_1']
|
||||
url_2 = download_links['Demucs_v3_UVR_url_2']
|
||||
url_3 = download_links['Demucs_v3_UVR_url_3']
|
||||
url_4 = download_links['Demucs_v3_UVR_url_4']
|
||||
url_5 = download_links['Demucs_v3_UVR_url_5']
|
||||
|
||||
links = url_1, url_2, url_3, url_4, url_5
|
||||
|
||||
if downloads == 'Demucs v2: demucs':
|
||||
url_1 = download_links['Demucs_v2_demucs_url_1']
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v2: demucs_extra':
|
||||
url_1 = download_links['Demucs_v2_demucs_extra_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v2: demucs48_hq':
|
||||
url_1 = download_links['Demucs_v2_demucs48_hq_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v2: tasnet':
|
||||
url_1 = download_links['Demucs_v2_tasnet_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v2: tasnet_extra':
|
||||
url_1 = download_links['Demucs_v2_tasnet_extra_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v2: demucs_unittest':
|
||||
url_1 = download_links['Demucs_v2_demucs_unittest_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: demucs':
|
||||
url_1 = download_links['Demucs_v1_demucs_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: demucs_extra':
|
||||
url_1 = download_links['Demucs_v1_demucs_extra_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: light':
|
||||
url_1 = download_links['Demucs_v1_light_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: light_extra':
|
||||
url_1 = download_links['Demucs_v1_light_extra_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: tasnet':
|
||||
url_1 = download_links['Demucs_v1_tasnet_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'Demucs v1: tasnet_extra':
|
||||
url_1 = download_links['Demucs_v1_tasnet_extra_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'model_repo':
|
||||
url_1 = download_links['model_repo_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'single_model_repo':
|
||||
url_1 = download_links['single_model_repo_url_1']
|
||||
|
||||
links = url_1
|
||||
|
||||
if downloads == 'exclusive':
|
||||
url_1 = download_links['exclusive_url_1']
|
||||
url_2 = download_links['exclusive_url_2']
|
||||
|
||||
links = url_1, url_2, url_3
|
||||
|
||||
if downloads == 'refresh':
|
||||
url_1 = download_links['refresh_url_1']
|
||||
url_2 = download_links['refresh_url_2']
|
||||
url_3 = download_links['refresh_url_3']
|
||||
|
||||
links = url_1, url_2, url_3
|
||||
|
||||
if downloads == 'app_patch':
|
||||
url_1 = download_links['app_patch']
|
||||
|
||||
links = url_1
|
||||
|
||||
return links
|
||||
|
||||
def provide_model_param_hash(model_hash):
|
||||
#v5 Models
|
||||
if model_hash == '47939caf0cfe52a0e81442b85b971dfd':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '4e4ecb9764c50a8c414fee6e10395bbe':
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2.json')
|
||||
param_name=str('4band_v2')
|
||||
elif model_hash == 'e60a1e84803ce4efc0a6551206cc4b71':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == 'a82f14e75892e55e994376edbf0c8435':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '6dd9eaa6f0420af9f1d403aaafa4cc06':
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2_sn.json')
|
||||
param_name=str('4band_v2_sn')
|
||||
elif model_hash == '5c7bbca45a187e81abbbd351606164e5':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
elif model_hash == 'd6b2cb685a058a091e5e7098192d3233':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
elif model_hash == 'c1b9f38170a7c90e96f027992eb7c62b':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == 'c3448ec923fa0edf3d03a19e633faa53':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '68aa2c8093d0080704b200d140f59e54':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100.json')
|
||||
param_name=str('3band_44100.json')
|
||||
elif model_hash == 'fdc83be5b798e4bd29fe00fe6600e147':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid.json')
|
||||
elif model_hash == '2ce34bc92fd57f55db16b7a4def3d745':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid.json')
|
||||
elif model_hash == '52fdca89576f06cf4340b74a4730ee5f':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100.json')
|
||||
elif model_hash == '41191165b05d38fc77f072fa9e8e8a30':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100.json')
|
||||
elif model_hash == '89e83b511ad474592689e562d5b1f80e':
|
||||
model_params_set=str('lib_v5/modelparams/2band_32000.json')
|
||||
param_name=str('2band_32000.json')
|
||||
elif model_hash == '0b954da81d453b716b114d6d7c95177f':
|
||||
model_params_set=str('lib_v5/modelparams/2band_32000.json')
|
||||
param_name=str('2band_32000.json')
|
||||
|
||||
#v4 Models
|
||||
|
||||
elif model_hash == '6a00461c51c2920fd68937d4609ed6c8':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr16000_hl512.json')
|
||||
param_name=str('1band_sr16000_hl512')
|
||||
elif model_hash == '0ab504864d20f1bd378fe9c81ef37140':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == '7dd21065bf91c10f7fccb57d7d83b07f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == '80ab74d65e515caa3622728d2de07d23':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == 'edc115e7fc523245062200c00caa847f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif model_hash == '28063e9f6ab5b341c5f6d3c67f2045b7':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif model_hash == 'b58090534c52cbc3e9b5104bad666ef2':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif model_hash == '0cdab9947f1b0928705f518f3c78ea8f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif model_hash == 'ae702fed0238afb5346db8356fe25f13':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl1024.json')
|
||||
param_name=str('1band_sr44100_hl1024')
|
||||
else:
|
||||
try:
|
||||
with open(f"lib_v5/filelists/model_cache/vr_param_cache/{model_hash}.txt", "r") as f:
|
||||
name = f.read()
|
||||
model_params_set=str(f'lib_v5/modelparams/{name}')
|
||||
param_name=str(name)
|
||||
('using text of hash worked')
|
||||
except:
|
||||
model_params_set=str('Not Found Using Hash')
|
||||
param_name=str('Not Found Using Hash')
|
||||
|
||||
model_params = model_params_set, param_name
|
||||
|
||||
return model_params
|
||||
|
||||
def provide_model_param_name(ModelName):
|
||||
#1 Band
|
||||
if '1band_sr16000_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr16000_hl512.json')
|
||||
param_name=str('1band_sr16000_hl512')
|
||||
elif '1band_sr32000_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif '1band_sr33075_hl384' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif '1band_sr44100_hl256' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl256.json')
|
||||
param_name=str('1band_sr44100_hl256')
|
||||
elif '1band_sr44100_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif '1band_sr44100_hl1024' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl1024.json')
|
||||
param_name=str('1band_sr44100_hl1024')
|
||||
|
||||
#2 Band
|
||||
elif '2band_44100_lofi' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/2band_44100_lofi.json')
|
||||
param_name=str('2band_44100_lofi')
|
||||
|
||||
#3 Band
|
||||
|
||||
elif '3band_44100_mid' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid')
|
||||
elif '3band_44100_msb2' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
|
||||
#4 Band
|
||||
|
||||
elif '4band_44100_msb' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_msb.json')
|
||||
param_name=str('4band_44100_msb')
|
||||
elif '4band_44100_msb2' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_msb2.json')
|
||||
param_name=str('4band_44100_msb2')
|
||||
elif '4band_44100_reverse' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_reverse.json')
|
||||
param_name=str('4band_44100_reverse')
|
||||
elif 'tmodelparam' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/tmodelparam.json')
|
||||
param_name=str('User Model Param Set')
|
||||
else:
|
||||
model_params_set=str('Not Found Using Name')
|
||||
param_name=str('Not Found Using Name')
|
||||
|
||||
model_params = model_params_set, param_name
|
||||
|
||||
return model_params
|
||||
|
||||
def provide_mdx_model_param_name(modelhash):
|
||||
with open("lib_v5/filelists/hashes/mdx_original_hashes.txt", "r") as f:
|
||||
mdx_original=f.read()
|
||||
with open("lib_v5/filelists/hashes/mdx_new_hashes.txt", "r") as f:
|
||||
mdx_new=f.read()
|
||||
with open("lib_v5/filelists/hashes/mdx_new_inst_hashes.txt", "r") as f:
|
||||
mdx_new_inst=f.read()
|
||||
|
||||
if modelhash in mdx_original:
|
||||
MDX_modeltype = 'mdx_original'
|
||||
elif modelhash in mdx_new:
|
||||
MDX_modeltype = 'mdx_new'
|
||||
elif modelhash in mdx_new_inst:
|
||||
MDX_modeltype = 'mdx_new_inst'
|
||||
else:
|
||||
MDX_modeltype = 'None'
|
||||
|
||||
if MDX_modeltype == 'mdx_original':
|
||||
modeltype = 'v'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_14_kHz'
|
||||
stemset_n = '(Vocals)'
|
||||
compensate = 1.03597672895
|
||||
source_val = 3
|
||||
n_fft_scale_set=6144
|
||||
dim_f_set=2048
|
||||
elif MDX_modeltype == 'mdx_new':
|
||||
modeltype = 'v'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_17_kHz'
|
||||
stemset_n = '(Vocals)'
|
||||
compensate = 1.08
|
||||
source_val = 3
|
||||
n_fft_scale_set=7680
|
||||
dim_f_set=3072
|
||||
elif MDX_modeltype == 'mdx_new_inst':
|
||||
modeltype = 'v'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_17_kHz'
|
||||
stemset_n = '(Instrumental)'
|
||||
compensate = 1.08
|
||||
source_val = 3
|
||||
n_fft_scale_set=7680
|
||||
dim_f_set=3072
|
||||
elif modelhash == '6f7eefc2e6b9d819ba88dc0578056ca5':
|
||||
modeltype = 'o'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_Full_Band'
|
||||
stemset_n = '(Other)'
|
||||
compensate = 1.03597672895
|
||||
source_val = 2
|
||||
n_fft_scale_set=8192
|
||||
dim_f_set=2048
|
||||
elif modelhash == '72a27258a69b2381b60523a50982e9f1':
|
||||
modeltype = 'd'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_Full_Band'
|
||||
stemset_n = '(Drums)'
|
||||
compensate = 1.03597672895
|
||||
source_val = 1
|
||||
n_fft_scale_set=4096
|
||||
dim_f_set=2048
|
||||
elif modelhash == '7051d7315c04285e94a97edcac3f2f76':
|
||||
modeltype = 'b'
|
||||
noise_pro = 'MDX-NET_Noise_Profile_Full_Band'
|
||||
stemset_n = '(Bass)'
|
||||
compensate = 1.03597672895
|
||||
source_val = 0
|
||||
n_fft_scale_set=16384
|
||||
dim_f_set=2048
|
||||
else:
|
||||
try:
|
||||
f = open(f"lib_v5/filelists/model_cache/mdx_model_cache/{modelhash}.json")
|
||||
mdx_model_de = json.load(f)
|
||||
modeltype = mdx_model_de["modeltype"]
|
||||
noise_pro = mdx_model_de["noise_pro"]
|
||||
stemset_n = mdx_model_de["stemset_n"]
|
||||
compensate = mdx_model_de["compensate"]
|
||||
source_val = mdx_model_de["source_val"]
|
||||
n_fft_scale_set = mdx_model_de["n_fft_scale_set"]
|
||||
dim_f_set = mdx_model_de["dim_f_set"]
|
||||
except:
|
||||
modeltype = 'Not Set'
|
||||
noise_pro = 'Not Set'
|
||||
stemset_n = 'Not Set'
|
||||
compensate = 'Not Set'
|
||||
source_val = 'Not Set'
|
||||
n_fft_scale_set='Not Set'
|
||||
dim_f_set='Not Set'
|
||||
|
||||
|
||||
model_params = modeltype, noise_pro, stemset_n, compensate, source_val, n_fft_scale_set, dim_f_set
|
||||
|
||||
return model_params
|
@ -1 +0,0 @@
|
||||
temp
|
@ -1 +0,0 @@
|
||||
|
@ -1 +0,0 @@
|
||||
|
@ -1,19 +0,0 @@
|
||||
No Model Selected
|
||||
No Model Selected
|
||||
Demucs v3: UVR Models
|
||||
Demucs v3: mdx
|
||||
Demucs v3: mdx_q
|
||||
Demucs v3: mdx_extra
|
||||
Demucs v3: mdx_extra_q
|
||||
Demucs v2: demucs
|
||||
Demucs v2: demucs_extra
|
||||
Demucs v2: demucs48_hq
|
||||
Demucs v2: tasnet
|
||||
Demucs v2: tasnet_extra
|
||||
Demucs v2: demucs_unittest
|
||||
Demucs v1: demucs
|
||||
Demucs v1: demucs_extra
|
||||
Demucs v1: light
|
||||
Demucs v1: light_extra
|
||||
Demucs v1: tasnet
|
||||
Demucs v1: tasnet_extra
|
@ -1,42 +0,0 @@
|
||||
{
|
||||
"Demucs_v3_mdx_url_1": "https://dl.fbaipublicfiles.com/demucs/mdx_final/0d19c1c6-0f06f20e.th",
|
||||
"Demucs_v3_mdx_url_2": "https://dl.fbaipublicfiles.com/demucs/mdx_final/7ecf8ec1-70f50cc9.th",
|
||||
"Demucs_v3_mdx_url_3": "https://dl.fbaipublicfiles.com/demucs/mdx_final/c511e2ab-fe698775.th",
|
||||
"Demucs_v3_mdx_url_4": "https://dl.fbaipublicfiles.com/demucs/mdx_final/7d865c68-3d5dd56b.th",
|
||||
"Demucs_v3_mdx_url_5": "https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/mdx.yaml",
|
||||
"Demucs_v3_mdx_q_url_1": "https://dl.fbaipublicfiles.com/demucs/mdx_final/6b9c2ca1-3fd82607.th",
|
||||
"Demucs_v3_mdx_q_url_2": "https://dl.fbaipublicfiles.com/demucs/mdx_final/b72baf4e-8778635e.th",
|
||||
"Demucs_v3_mdx_q_url_3": "https://dl.fbaipublicfiles.com/demucs/mdx_final/42e558d4-196e0e1b.th",
|
||||
"Demucs_v3_mdx_q_url_4": "https://dl.fbaipublicfiles.com/demucs/mdx_final/305bc58f-18378783.th",
|
||||
"Demucs_v3_mdx_q_url_5": "https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/mdx_q.yaml",
|
||||
"Demucs_v3_mdx_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/mdx_final/e51eebcc-c1b80bdd.th",
|
||||
"Demucs_v3_mdx_extra_url_2": "https://dl.fbaipublicfiles.com/demucs/mdx_final/a1d90b5c-ae9d2452.th",
|
||||
"Demucs_v3_mdx_extra_url_3": "https://dl.fbaipublicfiles.com/demucs/mdx_final/5d2d6c55-db83574e.th",
|
||||
"Demucs_v3_mdx_extra_url_4": "https://dl.fbaipublicfiles.com/demucs/mdx_final/cfa93e08-61801ae1.th",
|
||||
"Demucs_v3_mdx_extra_url_5": "https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/mdx_extra.yaml",
|
||||
"Demucs_v3_mdx_extra_q_url_1": "https://dl.fbaipublicfiles.com/demucs/mdx_final/83fc094f-4a16d450.th",
|
||||
"Demucs_v3_mdx_extra_q_url_2": "https://dl.fbaipublicfiles.com/demucs/mdx_final/464b36d7-e5a9386e.th",
|
||||
"Demucs_v3_mdx_extra_q_url_3": "https://dl.fbaipublicfiles.com/demucs/mdx_final/14fc6a69-a89dd0ee.th",
|
||||
"Demucs_v3_mdx_extra_q_url_4": "https://dl.fbaipublicfiles.com/demucs/mdx_final/7fd6ef75-a905dd85.th",
|
||||
"Demucs_v3_mdx_extra_q_url_5": "https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/mdx_extra_q.yaml",
|
||||
"Demucs_v3_UVR_url_1": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/ebf34a2d.th",
|
||||
"Demucs_v3_UVR_url_2": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/ebf34a2db.th",
|
||||
"Demucs_v3_UVR_url_3": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/UVR_Demucs_Model_1.yaml",
|
||||
"Demucs_v3_UVR_url_4": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/UVR_Demucs_Model_2.yaml",
|
||||
"Demucs_v3_UVR_url_5": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/UVR_Demucs_Model_Bag.yaml",
|
||||
"Demucs_v2_demucs_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/demucs-e07c671f.th",
|
||||
"Demucs_v2_demucs_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/demucs_extra-3646af93.th",
|
||||
"Demucs_v2_demucs48_hq_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/demucs48_hq-28a1282c.th",
|
||||
"Demucs_v2_tasnet_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/tasnet-beb46fac.th",
|
||||
"Demucs_v2_tasnet_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/tasnet_extra-df3777b2.th",
|
||||
"Demucs_v2_demucs_unittest_url_1": "https://dl.fbaipublicfiles.com/demucs/v3.0/demucs_unittest-09ebc15f.th",
|
||||
"Demucs_v1_demucs_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/demucs.th",
|
||||
"Demucs_v1_demucs_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/demucs_extra.th",
|
||||
"Demucs_v1_light_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/light.th",
|
||||
"Demucs_v1_light_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/light_extra.th",
|
||||
"Demucs_v1_tasnet_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/tasnet.th",
|
||||
"Demucs_v1_tasnet_extra_url_1": "https://dl.fbaipublicfiles.com/demucs/v2.0/tasnet_extra.th",
|
||||
"model_repo_url_1": "https://github.com/TRvlvr/model_repo/releases/download/model_pack_repo/",
|
||||
"single_model_repo_url_1": "https://github.com/TRvlvr/model_repo/releases/download/all_public_uvr_models/",
|
||||
"app_patch": "https://github.com/TRvlvr/model_repo/releases/download/uvr_update_patches/"
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
No Model Selected
|
||||
No Model Selected
|
||||
MDX-Net Model: UVR_MDXNET_Main
|
||||
MDX-Net Model: UVR_MDXNET_1_9703
|
||||
MDX-Net Model: UVR_MDXNET_2_9682
|
||||
MDX-Net Model: UVR_MDXNET_3_9662
|
||||
MDX-Net Model: UVR_MDXNET_9482
|
||||
MDX-Net Model: UVR_MDXNET_KARA
|
||||
Developer Pack: voc_model_epochs_434-439
|
||||
Developer Pack: inst_model_epochs_10-17
|
||||
Developer Pack: inst_model_epochs_26-40
|
||||
Developer Pack: inst_model_epochs_51-57
|
||||
Developer Pack: inst_model_epochs_58-64
|
@ -1 +0,0 @@
|
||||
temp
|
@ -1,25 +0,0 @@
|
||||
No Model Selected
|
||||
No Model Selected
|
||||
VR Arch Model Pack v5: SP Models
|
||||
VR Arch Model Pack v5: HP2 Models
|
||||
VR Arch Model Pack v4: Main Models
|
||||
VR Arch Single Model v5: 1_HP-UVR
|
||||
VR Arch Single Model v5: 2_HP-UVR
|
||||
VR Arch Single Model v5: 3_HP-Vocal-UVR
|
||||
VR Arch Single Model v5: 4_HP-Vocal-UVR
|
||||
VR Arch Single Model v5: 5_HP-Karaoke-UVR
|
||||
VR Arch Single Model v5: 6_HP-Karaoke-UVR
|
||||
VR Arch Single Model v5: 7_HP2-UVR
|
||||
VR Arch Single Model v5: 8_HP2-UVR
|
||||
VR Arch Single Model v5: 9_HP2-UVR
|
||||
VR Arch Single Model v5: 10_SP-UVR-2B-32000-1
|
||||
VR Arch Single Model v5: 11_SP-UVR-2B-32000-2
|
||||
VR Arch Single Model v5: 12_SP-UVR-3B-44100
|
||||
VR Arch Single Model v5: 13_SP-UVR-4B-44100-1
|
||||
VR Arch Single Model v5: 14_SP-UVR-4B-44100-2
|
||||
VR Arch Single Model v5: 15_SP-UVR-MID-44100-1
|
||||
VR Arch Single Model v5: 16_SP-UVR-MID-44100-2
|
||||
VR Arch Single Model v4: MGM_HIGHEND_v4
|
||||
VR Arch Single Model v4: MGM_LOWEND_A_v4
|
||||
VR Arch Single Model v4: MGM_LOWEND_B_v4
|
||||
VR Arch Single Model v4: MGM_MAIN_v4
|
@ -1,16 +0,0 @@
|
||||
No Model
|
||||
No Model
|
||||
MDX-Net: UVR-MDX-NET 1
|
||||
MDX-Net: UVR-MDX-NET 2
|
||||
MDX-Net: UVR-MDX-NET 3
|
||||
MDX-Net: UVR_MDXNET_9482
|
||||
MDX-Net: UVR-MDX-NET Karaoke
|
||||
MDX-Net: bass
|
||||
Demucs: UVR_Demucs_Model_1
|
||||
Demucs: UVR_Demucs_Model_2
|
||||
Demucs: UVR_Demucs_Model_Bag
|
||||
Demucs: Demucs_unittest v2
|
||||
Demucs: mdx_extra
|
||||
Demucs: mdx_q
|
||||
Demucs: Tasnet v1
|
||||
Demucs: Tasnet_extra v1
|
@ -1,13 +0,0 @@
|
||||
No Model
|
||||
No Model
|
||||
1_HP-UVR
|
||||
2_HP-UVR
|
||||
6_HP-Karaoke-UVR
|
||||
11_SP-UVR-2B-32000-2
|
||||
13_SP-UVR-4B-44100-1
|
||||
MGM_HIGHEND_v4 (1)
|
||||
MGM_HIGHEND_v4
|
||||
MGM_LOWEND_A_v4
|
||||
MGM_LOWEND_B_v4
|
||||
MGM_MAIN_v4
|
||||
WIP-Piano-4band-129605kb
|
@ -1,266 +0,0 @@
|
||||
0374836ab954ccd5946b29668c36bfdd
|
||||
e494001f6e38f3ff9f8db07073dbcc38
|
||||
1284cfb6ca5cbe68778a392bf92fe448
|
||||
927f5993571090980f7042a5087ad7d5
|
||||
8a7b42b609383c9bd11c093e357c8d01
|
||||
d7b9b49bf75c78afad0e88786bd729ae
|
||||
8737fb18a216d62ba2fec7948da59721
|
||||
432308a1f31d144ba117dc5f87e97809
|
||||
39eedabe4309ecbcda1df37a5cdd6adf
|
||||
fbee5264485e2c4b4003db897dea3528
|
||||
443ca4b02bf26bc42d9ef114aa25adc8
|
||||
8d700d4589ba30b876114823af40bcea
|
||||
52be0e4c18ddfba376081a7edaca5f56
|
||||
f0fd48dc0422a992e08e18f9cf318678
|
||||
af21b8645202d0b6d93cb383284ad0e6
|
||||
c5f39697c5dd372c4fb9656f01c814cc
|
||||
3f2bd7da922c4b45ac8923cccce41455
|
||||
8c467b5fbce83858b67436e28efa31c3
|
||||
16418df565fbaddd8e91ead6693a7418
|
||||
06f4c4b9e7cc2c3503bdcb9cfad4298b
|
||||
3a28db13d74c27f4ef255e5acb2f66b1
|
||||
2c7e0a31f0aa7947865b66a8ccfdf08f
|
||||
ef878de3d28e6ef376ad35527d86e4dc
|
||||
52b4c815669b7a6c1898453f5c42a617
|
||||
63c28c788f40af6d49ad8013600149bf
|
||||
787c1fa7256250695b14d2c62d57070c
|
||||
3eac6076f597da01788946563cc2756d
|
||||
d3efcccba9417bd0567845958d55bed5
|
||||
5d4b6d50847807833b82009be6519364
|
||||
cd988a4722f06c7fc9798750da9a6216
|
||||
5c0953d6f2d6a6ac3c738c0ba04fb518
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
e46ef7b671b13a9a6bada197d8ccc0cf
|
||||
a57f5884b67bc0be16759045d9734b7f
|
||||
9b60b21391809845bb4435bc7096aabf
|
||||
5a4897d7a3afcae86f6948ba9275a49e
|
||||
d521fcb9b6cb6818710bf1609d1a8182
|
||||
3c6420e4e3646d7906d6d1b86d0410bc
|
||||
a85c8174b2c91e780a67b391650ae264
|
||||
b5a906653199f49f0e0215e0b22901b4
|
||||
16de23223764249902734d64f2a0223f
|
||||
2957853f7346c5039fc2f4d1b0f3c65c
|
||||
a8fb404acc3631cfbb8aacf20f39d65d
|
||||
f1e62e9e52477dff0c1b92c218bcd7f0
|
||||
2067c316fe7a097040f6da35451bde94
|
||||
b6653ac3158e60561f05933ebe4d6477
|
||||
274f631b444ce3ec6fbb71778ca58ae5
|
||||
5dc5f89788c7385a99787a15e78cc852
|
||||
740e38a99d835f113ffc396e144fbfa8
|
||||
b21de390242db154b1e6d45b9c44a912
|
||||
8c6751c184707c356534a8d4481e2987
|
||||
057a0878236e70dfdf8e09fc8e3d9126
|
||||
0a15368a0d7b00eb1f49276c316c280f
|
||||
ae35d179e0395e53867f2b7f32de337e
|
||||
87a9c56e36d2cb159ff76929b0edfd3f
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
18508ba57b14327516f4f958d7cb5bdd
|
||||
d2b8a00978bcf61eeb3642ffb2653431
|
||||
c1cbaeea910a925be045c4dad52e0f95
|
||||
72d739c4fa1f0c606f357cc6b4b313b0
|
||||
44d6519e1efc6c68d53f82361e382987
|
||||
7b63504b3dd9ed7ef5c6ef9fbbb6d857
|
||||
f0fb53226a97e2d1ed8af46308d0b238
|
||||
27065f326f173ee54c38e349a84caed8
|
||||
71f2b8871d21ce1ae9b3c16042d3b511
|
||||
870a12746e7b7648cc8449c0ea5f8be8
|
||||
93bcd06e20b2ae5388da783bf68c7224
|
||||
09973b74f4dabb01ecdfed706743f45e
|
||||
34c8c8870ed8cac0fbc1dc9d1ae90dec
|
||||
e3078ba5c104e5f4ec7ff17b23f4bc48
|
||||
7a84d9cc7d2a064be2328d5f183e21f8
|
||||
49efdbcfcf32bde3b0cdec517fc14f7d
|
||||
389c7c5b890a73fec8753a675dd12ac0
|
||||
34ec0124d7d734babf76c79ab94c1f5c
|
||||
2ebfd30a6f0dcae400bdadf27c138d72
|
||||
a6520bca33f5d9d47249c9dc72769869
|
||||
fb95e55c41d7b4609da78f7e189d57c7
|
||||
82ea77ce031ff7f388ca61d8022d0783
|
||||
ca4225e905d87de17c4495af7763f853
|
||||
066f3b8bc8e25d949c73ec1995072903
|
||||
1e4cccb2b9279c0f3d120e3df42eade5
|
||||
7148b2d2a566a500df4046b57d64c921
|
||||
4d5b28ed4facc34105c548b4ebe445d3
|
||||
545fcdc3f4214d1f19b5fdd21cde38bf
|
||||
c84cea02dae21a7c94d5cbc0de4cebfc
|
||||
19cb138773f3db150366f8ed3e1b3b44
|
||||
72f8c3d5486fe653c8bb99519097eb93
|
||||
1205327ef4f1b2b12710c4d648b71de2
|
||||
6b2a00d20b89c27e9b4185c2cf9e4aa7
|
||||
eae02d1f9b056ed813f864d30f33834d
|
||||
1c3fecce7632cc859b75c7b88ad2afa2
|
||||
ff62c0bcbcc4f685dd3b7831a0f7c3b7
|
||||
6fbc36b6b8c22477ff32dac19e4fca28
|
||||
7a205daabf8960bf487b9c0b794251bc
|
||||
cc1c53adf5c99f2264f5e01dc1082a5b
|
||||
37822839f05c3befd0c99b9f4882ab86
|
||||
ee0712096e63be0afd56a74f4a9e0ea1
|
||||
c58340ff0f0507240e3a146bdd990cf1
|
||||
1a13fd81b213d7163b49db5da00f53c3
|
||||
b77cf1f489cdde9eb8a9b67b6b59ec68
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
ae3bb6e6e27b272999c31ef153a3c87a
|
||||
299a55c8ede63c7897f018b45cb2d5d2
|
||||
679042229a62536cc8edbfc04efd4db6
|
||||
a8bd219e9c47f19d7a6114e423ad408f
|
||||
a55dd195a4545ee38d4cf35b1cc2ec63
|
||||
583d824859c4312bf9f29e33c9e5bfb9
|
||||
4c43c3b27dc8f806a629bf1fed00713f
|
||||
3e50a377fe876b78b0372275e4280deb
|
||||
0aa28867b9527b9d3039d51b64c539bd
|
||||
254ece16803e5c86ab5e848b7ed050f7
|
||||
231532acc25316bec842fb9daf8a2433
|
||||
ff07a7503a0f5242c20d3120e31edaef
|
||||
f3d967caf9a18cca0464c94af5e29b96
|
||||
f482c7a3e906bbd5f7f84344de95884e
|
||||
47541c9bfc1f64fb27ed7fe0e51d5820
|
||||
d11dd98a13e6931844d099162e944175
|
||||
db59cbd3343a3e1c4077e97273947c07
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
684895a24ed48e27092604e5ca55147b
|
||||
f56742ceec2bb09e4a8f6bfebd19e3b2
|
||||
0938f3adcf49644ee5952fce8470e1ee
|
||||
18c56f68d4a1ca021ef0daffd586e5a1
|
||||
2fd39f65bbdfb44ae24952fc55ec828f
|
||||
56c8dd32289acfc89ddb1cf1eb2080a1
|
||||
49df79ad1f22a1cc51d3fe6581c04368
|
||||
b39b1edd3defacc1035fedcb9717c13f
|
||||
493598ca0cfd5a4e3a308cf2d7b337cf
|
||||
027e12756f7ac9d72a0243e57208d640
|
||||
2c3920c38cdb3dac251d35f7cad32d76
|
||||
7399b3d9512206b26f885cbbbd5db8a6
|
||||
857af50fb527a7b187e2038d1f5339fe
|
||||
706bd84cee98aa24862c0d84b3ad7d83
|
||||
1310c0587c85752e2b2a958cbb8a865b
|
||||
08e4bf0e8b3d35897f3165db19e2fe45
|
||||
cbbdd039f02090f130a774609f546073
|
||||
1f98187a1cb50b04fcf9b6483aede1fe
|
||||
77c77d58fb898a936f534098c7cedde3
|
||||
68e0861a93e8f69d18e06446dabb4bfd
|
||||
d66fcc3a6869fc9e16e412f7102e7a4b
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
cbf08ceba8462bc3b63a4b8219b2127f
|
||||
1c8c65dccc65a874baf6b946323b9fcc
|
||||
29d53240deda5d41501fcf0a766adfce
|
||||
9c555f81fba02566811902d04c623d6c
|
||||
282ba1496fd4242ce2cf2d90e57fe2df
|
||||
5a071be7bdc03e9f10cfabc35256562f
|
||||
24154e229b32e53bc9418ec787e17494
|
||||
e4bb05aef0f088bc085bd70fdf0e23e5
|
||||
75a2e9b4a66c0906aa05841a08796f16
|
||||
76fcb7ec78d402d0fcbab783e6a5bb08
|
||||
afcd755eb6fe6fbd63064d62b97d7415
|
||||
2f749b5bba3fbdf47b6f1786682b6e17
|
||||
d7c92cee09b62970b9dec9290507f1ab
|
||||
4edc1683c236af337baa583a01120d4c
|
||||
ab9bc82a525b84ffddb8e3e0d3cfb9d6
|
||||
12b4b7b4569816cb499a051203f84163
|
||||
7dc1829acd3fc5ed7aee352383464a8f
|
||||
77654e582fa565e1878880c2dc7ccc6a
|
||||
1af9ca98f02117c715a7d08a93a90d11
|
||||
26ee73d5f2cbff2f833e83e3d9d9a970
|
||||
aa04ea15b9607d920ae5ae0e826e2b96
|
||||
602bd5c724ea9d4c2f446c9491ee35f2
|
||||
5a5770df2a95203d87f383ea4bac1c13
|
||||
5c3aac1983493dca30d0512e32d73aec
|
||||
317c5596068ee1d89f1e134f34c41a6f
|
||||
cb7622696ed1a09922c8bf9e08dab19a
|
||||
a10993b3fc9e713175e8c15369208e37
|
||||
54f94ef6ae99039746b29e8c7b095f42
|
||||
fcdf005de9869614d418fda6921736b1
|
||||
738526a1206737e49ed2e3ed525cef75
|
||||
561075aa5e8c15da84a793cc351ff7f1
|
||||
6c31403d96f13e0f99cf70caba5dbcf4
|
||||
d2f6e3956e13abcaa5854061ec66b328
|
||||
eeb018b28ae4d0aeec0a5644f2784319
|
||||
33b6e5e6677d03a5210f04eb9f2b7d25
|
||||
a93ff7868bbe0707e01f23b1bd420dc9
|
||||
3fcc378ca8ff8d2e57e2768393a78f01
|
||||
759ca61e56317dc0c1dfbaec891e0b6d
|
||||
fd5e636fbb4c6eea0383f7803f32649f
|
||||
743f50f5512c8b8d8a045c8987e2f490
|
||||
cc40b9e052b524fa882b812be835e2b1
|
||||
2299e5fd3ff04cdac5473479dab4ca12
|
||||
80ed2351ed5645b10ee59c49de2fa85e
|
||||
72e70ae8fcea406a4175cb8aff365f26
|
||||
ce7eab5316ddbe8492a911fd6e9360ec
|
||||
0a3db22db2ec36d2274be2e6c1a3f281
|
||||
7accc6b329e87fd488a8611be2822c31
|
||||
9d75768514ae1e9d815d44770c2c7528
|
||||
2c099e9ad0ef0ed8fbbe5207d86bf1c3
|
||||
1735d7847e15f75103dab33ae7812593
|
||||
4ccf7af16a1e132915a53b5c1d0489b4
|
||||
9d6dc0eeb89233b2fc2e4cb6b0c03c8d
|
||||
9c174a9728ba905330d53404350e5030
|
||||
b1e90f473873c0de27feadd42f784cde
|
||||
d96712e0a516217a4b15f21da3e09dee
|
||||
9c64543bc5757fd9bd385ad1977d98f6
|
||||
6f3c09ff2b603f88f9cb59643bf60d27
|
||||
195710ebfdac31abc9a8c1cf70af64c5
|
||||
dc69356b009931763e60494ed65b091b
|
||||
8700c86a88cc28873a3fa38dddeb657d
|
||||
d2deadd2e486200fad9d7504a6be272b
|
||||
94c1f1fcc101819c1b0ea619b1d14a4d
|
||||
bd1f3fcfb0080ad24fbaf522f46d93d0
|
||||
7ab6e91e95dc46c43f6fd453a7fa08d2
|
||||
b62bf9ecb1504fafcbb2f1dfd3577adb
|
||||
d79e834a074be79732214c241acbafae
|
||||
248fbfb44e4c7b6252c43f6efd57beeb
|
||||
9d0a3bf0fbfd3ac5a326da42730c59d8
|
||||
0381868fc1424a5a2cbddc0dcd3e03ff
|
||||
99fe35974f3b3e44222d3ea922361441
|
||||
ee649ecf9af62537230d53a1669aded9
|
||||
7c603f02ecae615a6e6db193c833049d
|
||||
70643a56ccda1e41c853b626fc61b2b7
|
||||
7aede03b88b41aed480873dcc1155ff1
|
||||
f82eb261734ae9506f3a2b0982f5a436
|
||||
b7e0ea765ce79b16b3360b6f7c20bf3e
|
||||
e42f1bb671e9007a58a56a0dbcfba96a
|
||||
4944c8ab32140b11ea96055b536195bd
|
||||
2398160da9da6e05ed4cf41c313ab359
|
||||
83640e4eebfa904a335fcce7308f76ee
|
||||
b79bcd180ab4105bc7d477594366ac32
|
||||
9ea57e40b2a085a34432903153b6f553
|
||||
a55bd0247b2b97299a21ca33ea4153d6
|
||||
b917bdac8ecdd58d62c662604fe41156
|
||||
de0e9b8d929f8ea4c6e9fbdbc5702539
|
||||
a1f86a115d6771f2f49c192187433937
|
||||
3c0441d69f6f21890f07b791a2a0f975
|
||||
df50c0c577db9620d65c461514753cc6
|
||||
e2c2fdddc294a14e81ab638877746897
|
||||
6289fc9313430c398a5a154a4184e643
|
||||
45858d3c16515a018a55bdd63a8dcaa0
|
||||
094235d47192c91bd2bfeaa2005c4a95
|
||||
e50ae9b60d3a2527545c2a9c3c840947
|
||||
38e807c4d51ea851182e89b2a26823c9
|
||||
7b0e3b866a0ad9aedac142b017a46d23
|
||||
82f53c138d9ae0442f42357538c2623a
|
||||
e6dd1e0d8fd1dc6ace7026f8749c1fed
|
||||
221c01f90c00e98ceccef860b33ecb76
|
||||
1d39503ae9334f6eee559bdd70f8c24f
|
||||
f4b9da2652eb0dce90a9ea3335cd36c0
|
||||
d403bb7dcbe901eb8f248e87c03fb7cd
|
||||
41e7fab08927a26a7afd6a8830bc2d8c
|
||||
539e6c09143a295cea430c7459bbff33
|
||||
fd83d05f82a4edf4a01c56ce3a8d6e63
|
||||
8fead59e6616e753f9f1c27156353947
|
||||
61be36cf0a2880d4b38c575b65699b4a
|
||||
83232153c59247187570377af0a1d223
|
||||
dc9777a4cef96dc2f46a5381ba058256
|
||||
322d9cd44c707f6b54e55775700ca514
|
||||
7587ebafebed7d9bdaa6165db2c43608
|
||||
83ddc19beea20010318bce4722d890d5
|
||||
bb64c8f176f3c4d87ff260be720d66c3
|
||||
202c811375f61cd6d5840a40cf2cb4ba
|
||||
7b3460f9e8dd28202111ec582e965d55
|
||||
dd087f5adcd94116225963397ac25889
|
||||
5e5865e8d2f48d93066c866aa31c5983
|
||||
ff2d856e56b5768688a1d1de00c143dc
|
||||
90245b98df873843287f68caf9da596b
|
||||
fb793952993781dbee22336bc6296987
|
||||
5107088c9476c07bdd32af1b9d67108e
|
||||
969bfa927f27ca1c98c00d3ae589f623
|
||||
37969f2b2add6199fb00780899ce8c0d
|
||||
122742f2e218d003cc22d108df9c668a
|
||||
c72c77ff2373bc0e0d9beebf35c0dc07
|
||||
43eefd064d333877c59ee7362d044e0c
|
@ -1,56 +0,0 @@
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
2223f985aa47e99a0348f987ea2a3db6
|
||||
3fc1fa83cebb144dca7d379a3767ac77
|
||||
dfe5e1f42c42dcc262f2a2e2bc4ca7aa
|
||||
69108243963e4ed3fe22fdb37b812fe8
|
||||
ec3d6dc24c75e06a72fe1a2bd970b7b0
|
||||
aee23fcb90ef135bbd036f6e1c1ad9f9
|
||||
4561b9240c9acaf13eee2bd0186b4df4
|
||||
da0f43e81eb60b0bdacedd2de4758ee9
|
||||
5ee77a84e40bbd66a9d2b08b6a4c8496
|
||||
8b0526d02937c08adc95dfd57652c915
|
||||
08ff1d3a743eb2377c96b3de793990a0
|
||||
af292ce84aa6125ab75020f31e183f5b
|
||||
7f56ee6b9ee402802c403f348fea58cb
|
||||
038bb0d0a9f3c89b5671189384cfdf91
|
||||
db79054b3ae6c30f655e8ff12d64caa7
|
||||
b2e16d43ef559782a32874ffdace8b82
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
b71bb782cad9b8c6ea0a72c6ae69e8b4
|
||||
9d478026519f140e14e9c1bb32fcc522
|
||||
e81c4b46ec685b3ce227f426f884cfe0
|
||||
e9edcfacbbbbc513734082e1c1f7f6ad
|
||||
8d0bb54171a0996f2610be0fdc5743a8
|
||||
fbe5c4eecc1f3ad4b38364d77a774013
|
||||
66209e099302542c627c29bbb6976c59
|
||||
ee7b7dcda4e4353730cf89afc881c8cb
|
||||
0d09ab08de2cf0efe123144589345a33
|
||||
be2cff51fc6fcae172d30d3f1c142ee6
|
||||
b53e4cc77f9c47cbc6184cc7158f65ca
|
||||
c38f6a06977b9bc287c83f1e80ee0d9f
|
||||
0e05e776801b7016714015043e97373b
|
||||
fd39ea4282a92d3cb5f8d502e4c44ffa
|
||||
c937b7662b6f5cd92ff82fe595f160e7
|
||||
c0e0e9c44f815c1d0c0737343d702923
|
||||
c488149f2cd37c710da574f3b784e6e3
|
||||
823ef02eadf24f652609959e3a35206e
|
||||
674e8851d69bef3e4e1724d21247a8dc
|
||||
d3543c7b5d214515a7bd55d57b2413a0
|
||||
eb1179fb56fbcab660d9b69f9ac9cbe7
|
||||
0f7f0b21feb6b1b6e843f6047a3af13a
|
||||
b6f8de9a8316d5bd330a84eb22078ef4
|
||||
6dd6104d3ba4b3e9f47fba7d6c84dd9c
|
||||
1579df63864bf6ec11f2484cb2cfca7e
|
||||
3d2af588b96dc0e84be66804684e7c56
|
||||
6e566b37b3cec881ec93cfe415a710ec
|
||||
455c272b691c1001aa9b9cad5dfedd20
|
||||
ec892e0ea6f973d8c15645e621ee8fe1
|
||||
4a0b13b03e4db47191f387c2ced82f73
|
||||
e5d6e895bcbe4ca62ca9cc8808d8da6e
|
||||
4a0b13b03e4db47191f387c2ced82f73
|
||||
e5d6e895bcbe4ca62ca9cc8808d8da6e
|
||||
9df9f3bf4c7151fc36fb822d7728f433
|
||||
4475c1d3f79482cb2082f1bd13899e1b
|
||||
3d3523c8e0ab0a355748f38449331918
|
||||
24bb2808feae6efb2aaae9db3778886c
|
||||
947e6dd9e4aea2811eb3fb26d4bde615
|
@ -1,5 +0,0 @@
|
||||
1bbcb39d8a4be721d9322e62f13de1c1
|
||||
94422d1d6eb7019eff97dbef2daba979
|
||||
d3b87173f484864674ee2a21cd7b35f2
|
||||
053f663b23c70c6c1f52938fb480f5b8
|
||||
76929c1b5b9b804f89f4ebb78712c668
|
@ -1 +0,0 @@
|
||||
cache_goes_here
|
@ -1 +0,0 @@
|
||||
cache_goes_here
|
116
lib_v5/layers.py
@ -1,116 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 5, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,116 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 5, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,116 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 5, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,119 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16, 32), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv6 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 6, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
feat6 = self.conv6(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5, feat6), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,122 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16, 32, 64), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv6 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv7 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 7, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
feat6 = self.conv6(x)
|
||||
feat7 = self.conv7(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5, feat6, feat7), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,122 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16, 32, 64), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv6 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv7 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 7, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
feat6 = self.conv6(x)
|
||||
feat7 = self.conv7(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5, feat6, feat7), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,122 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class Conv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(Conv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class SeperableConv2DBNActiv(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, dilation=1, activ=nn.ReLU):
|
||||
super(SeperableConv2DBNActiv, self).__init__()
|
||||
self.conv = nn.Sequential(
|
||||
nn.Conv2d(
|
||||
nin, nin,
|
||||
kernel_size=ksize,
|
||||
stride=stride,
|
||||
padding=pad,
|
||||
dilation=dilation,
|
||||
groups=nin,
|
||||
bias=False),
|
||||
nn.Conv2d(
|
||||
nin, nout,
|
||||
kernel_size=1,
|
||||
bias=False),
|
||||
nn.BatchNorm2d(nout),
|
||||
activ()
|
||||
)
|
||||
|
||||
def __call__(self, x):
|
||||
return self.conv(x)
|
||||
|
||||
|
||||
class Encoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.LeakyReLU):
|
||||
super(Encoder, self).__init__()
|
||||
self.conv1 = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.conv2 = Conv2DBNActiv(nout, nout, ksize, stride, pad, activ=activ)
|
||||
|
||||
def __call__(self, x):
|
||||
skip = self.conv1(x)
|
||||
h = self.conv2(skip)
|
||||
|
||||
return h, skip
|
||||
|
||||
|
||||
class Decoder(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, ksize=3, stride=1, pad=1, activ=nn.ReLU, dropout=False):
|
||||
super(Decoder, self).__init__()
|
||||
self.conv = Conv2DBNActiv(nin, nout, ksize, 1, pad, activ=activ)
|
||||
self.dropout = nn.Dropout2d(0.1) if dropout else None
|
||||
|
||||
def __call__(self, x, skip=None):
|
||||
x = F.interpolate(x, scale_factor=2, mode='bilinear', align_corners=True)
|
||||
if skip is not None:
|
||||
skip = spec_utils.crop_center(skip, x)
|
||||
x = torch.cat([x, skip], dim=1)
|
||||
h = self.conv(x)
|
||||
|
||||
if self.dropout is not None:
|
||||
h = self.dropout(h)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class ASPPModule(nn.Module):
|
||||
|
||||
def __init__(self, nin, nout, dilations=(4, 8, 16, 32, 64), activ=nn.ReLU):
|
||||
super(ASPPModule, self).__init__()
|
||||
self.conv1 = nn.Sequential(
|
||||
nn.AdaptiveAvgPool2d((1, None)),
|
||||
Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
)
|
||||
self.conv2 = Conv2DBNActiv(nin, nin, 1, 1, 0, activ=activ)
|
||||
self.conv3 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[0], dilations[0], activ=activ)
|
||||
self.conv4 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[1], dilations[1], activ=activ)
|
||||
self.conv5 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv6 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.conv7 = SeperableConv2DBNActiv(
|
||||
nin, nin, 3, 1, dilations[2], dilations[2], activ=activ)
|
||||
self.bottleneck = nn.Sequential(
|
||||
Conv2DBNActiv(nin * 7, nout, 1, 1, 0, activ=activ),
|
||||
nn.Dropout2d(0.1)
|
||||
)
|
||||
|
||||
def forward(self, x):
|
||||
_, _, h, w = x.size()
|
||||
feat1 = F.interpolate(self.conv1(x), size=(h, w), mode='bilinear', align_corners=True)
|
||||
feat2 = self.conv2(x)
|
||||
feat3 = self.conv3(x)
|
||||
feat4 = self.conv4(x)
|
||||
feat5 = self.conv5(x)
|
||||
feat6 = self.conv6(x)
|
||||
feat7 = self.conv7(x)
|
||||
out = torch.cat((feat1, feat2, feat3, feat4, feat5, feat6, feat7), dim=1)
|
||||
bottle = self.bottleneck(out)
|
||||
return bottle
|
@ -1,60 +0,0 @@
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
default_param = {}
|
||||
default_param['bins'] = 768
|
||||
default_param['unstable_bins'] = 9 # training only
|
||||
default_param['reduction_bins'] = 762 # training only
|
||||
default_param['sr'] = 44100
|
||||
default_param['pre_filter_start'] = 757
|
||||
default_param['pre_filter_stop'] = 768
|
||||
default_param['band'] = {}
|
||||
|
||||
|
||||
default_param['band'][1] = {
|
||||
'sr': 11025,
|
||||
'hl': 128,
|
||||
'n_fft': 960,
|
||||
'crop_start': 0,
|
||||
'crop_stop': 245,
|
||||
'lpf_start': 61, # inference only
|
||||
'res_type': 'polyphase'
|
||||
}
|
||||
|
||||
default_param['band'][2] = {
|
||||
'sr': 44100,
|
||||
'hl': 512,
|
||||
'n_fft': 1536,
|
||||
'crop_start': 24,
|
||||
'crop_stop': 547,
|
||||
'hpf_start': 81, # inference only
|
||||
'res_type': 'sinc_best'
|
||||
}
|
||||
|
||||
|
||||
def int_keys(d):
|
||||
r = {}
|
||||
for k, v in d:
|
||||
if k.isdigit():
|
||||
k = int(k)
|
||||
r[k] = v
|
||||
return r
|
||||
|
||||
|
||||
class ModelParameters(object):
|
||||
def __init__(self, config_path=''):
|
||||
if '.pth' == pathlib.Path(config_path).suffix:
|
||||
import zipfile
|
||||
|
||||
with zipfile.ZipFile(config_path, 'r') as zip:
|
||||
self.param = json.loads(zip.read('param.json'), object_pairs_hook=int_keys)
|
||||
elif '.json' == pathlib.Path(config_path).suffix:
|
||||
with open(config_path, 'r') as f:
|
||||
self.param = json.loads(f.read(), object_pairs_hook=int_keys)
|
||||
else:
|
||||
self.param = default_param
|
||||
|
||||
for k in ['mid_side', 'mid_side_b', 'mid_side_b2', 'stereo_w', 'stereo_n', 'reverse']:
|
||||
if not k in self.param:
|
||||
self.param[k] = False
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 16000,
|
||||
"hl": 512,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 1024,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 16000,
|
||||
"pre_filter_start": 1023,
|
||||
"pre_filter_stop": 1024
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 32000,
|
||||
"hl": 512,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 1024,
|
||||
"hpf_start": -1,
|
||||
"res_type": "kaiser_fast"
|
||||
}
|
||||
},
|
||||
"sr": 32000,
|
||||
"pre_filter_start": 1000,
|
||||
"pre_filter_stop": 1021
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 33075,
|
||||
"hl": 384,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 1024,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 33075,
|
||||
"pre_filter_start": 1000,
|
||||
"pre_filter_stop": 1021
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 44100,
|
||||
"hl": 1024,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 1024,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 1023,
|
||||
"pre_filter_stop": 1024
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 256,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 44100,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 256,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 256,
|
||||
"pre_filter_stop": 256
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 1024,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 1023,
|
||||
"pre_filter_stop": 1024
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"bins": 1024,
|
||||
"unstable_bins": 0,
|
||||
"reduction_bins": 0,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 700,
|
||||
"hpf_start": -1,
|
||||
"res_type": "sinc_best"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 1023,
|
||||
"pre_filter_stop": 700
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 705,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 6000,
|
||||
"hl": 66,
|
||||
"n_fft": 512,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 240,
|
||||
"lpf_start": 60,
|
||||
"lpf_stop": 118,
|
||||
"res_type": "sinc_fastest"
|
||||
},
|
||||
"2": {
|
||||
"sr": 32000,
|
||||
"hl": 352,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 22,
|
||||
"crop_stop": 505,
|
||||
"hpf_start": 44,
|
||||
"hpf_stop": 23,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 32000,
|
||||
"pre_filter_start": 710,
|
||||
"pre_filter_stop": 731
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"bins": 512,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 510,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 160,
|
||||
"n_fft": 768,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 192,
|
||||
"lpf_start": 41,
|
||||
"lpf_stop": 139,
|
||||
"res_type": "sinc_fastest"
|
||||
},
|
||||
"2": {
|
||||
"sr": 44100,
|
||||
"hl": 640,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 10,
|
||||
"crop_stop": 320,
|
||||
"hpf_start": 47,
|
||||
"hpf_stop": 15,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 510,
|
||||
"pre_filter_stop": 512
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 705,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 6000,
|
||||
"hl": 66,
|
||||
"n_fft": 512,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 240,
|
||||
"lpf_start": 60,
|
||||
"lpf_stop": 240,
|
||||
"res_type": "sinc_fastest"
|
||||
},
|
||||
"2": {
|
||||
"sr": 48000,
|
||||
"hl": 528,
|
||||
"n_fft": 1536,
|
||||
"crop_start": 22,
|
||||
"crop_stop": 505,
|
||||
"hpf_start": 82,
|
||||
"hpf_stop": 22,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 48000,
|
||||
"pre_filter_start": 710,
|
||||
"pre_filter_stop": 731
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
{
|
||||
"bins": 768,
|
||||
"unstable_bins": 5,
|
||||
"reduction_bins": 733,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 768,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 278,
|
||||
"lpf_start": 28,
|
||||
"lpf_stop": 140,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 768,
|
||||
"crop_start": 14,
|
||||
"crop_stop": 322,
|
||||
"hpf_start": 70,
|
||||
"hpf_stop": 14,
|
||||
"lpf_start": 283,
|
||||
"lpf_stop": 314,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 131,
|
||||
"crop_stop": 313,
|
||||
"hpf_start": 154,
|
||||
"hpf_stop": 141,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 757,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
{
|
||||
"mid_side": true,
|
||||
"bins": 768,
|
||||
"unstable_bins": 5,
|
||||
"reduction_bins": 733,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 768,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 278,
|
||||
"lpf_start": 28,
|
||||
"lpf_stop": 140,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 768,
|
||||
"crop_start": 14,
|
||||
"crop_stop": 322,
|
||||
"hpf_start": 70,
|
||||
"hpf_stop": 14,
|
||||
"lpf_start": 283,
|
||||
"lpf_stop": 314,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 131,
|
||||
"crop_stop": 313,
|
||||
"hpf_start": 154,
|
||||
"hpf_stop": 141,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 757,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
{
|
||||
"mid_side_b2": true,
|
||||
"bins": 640,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 565,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 108,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 187,
|
||||
"lpf_start": 92,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 22050,
|
||||
"hl": 216,
|
||||
"n_fft": 768,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 212,
|
||||
"hpf_start": 68,
|
||||
"hpf_stop": 34,
|
||||
"lpf_start": 174,
|
||||
"lpf_stop": 209,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 44100,
|
||||
"hl": 432,
|
||||
"n_fft": 640,
|
||||
"crop_start": 66,
|
||||
"crop_stop": 307,
|
||||
"hpf_start": 86,
|
||||
"hpf_stop": 72,
|
||||
"res_type": "kaiser_fast"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 639,
|
||||
"pre_filter_stop": 640
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
{
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"mid_side": true,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"mid_side_b": true,
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"mid_side_b": true,
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"reverse": true,
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"stereo_w": true,
|
||||
"bins": 768,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 668,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 1024,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 186,
|
||||
"lpf_start": 37,
|
||||
"lpf_stop": 73,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 11025,
|
||||
"hl": 128,
|
||||
"n_fft": 512,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 185,
|
||||
"hpf_start": 36,
|
||||
"hpf_stop": 18,
|
||||
"lpf_start": 93,
|
||||
"lpf_stop": 185,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 22050,
|
||||
"hl": 256,
|
||||
"n_fft": 512,
|
||||
"crop_start": 46,
|
||||
"crop_stop": 186,
|
||||
"hpf_start": 93,
|
||||
"hpf_stop": 46,
|
||||
"lpf_start": 164,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 512,
|
||||
"n_fft": 768,
|
||||
"crop_start": 121,
|
||||
"crop_stop": 382,
|
||||
"hpf_start": 138,
|
||||
"hpf_stop": 123,
|
||||
"res_type": "sinc_medium"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 740,
|
||||
"pre_filter_stop": 768
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
{
|
||||
"bins": 672,
|
||||
"unstable_bins": 8,
|
||||
"reduction_bins": 637,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 7350,
|
||||
"hl": 80,
|
||||
"n_fft": 640,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 85,
|
||||
"lpf_start": 25,
|
||||
"lpf_stop": 53,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 7350,
|
||||
"hl": 80,
|
||||
"n_fft": 320,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 87,
|
||||
"hpf_start": 25,
|
||||
"hpf_stop": 12,
|
||||
"lpf_start": 31,
|
||||
"lpf_stop": 62,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 14700,
|
||||
"hl": 160,
|
||||
"n_fft": 512,
|
||||
"crop_start": 17,
|
||||
"crop_stop": 216,
|
||||
"hpf_start": 48,
|
||||
"hpf_stop": 24,
|
||||
"lpf_start": 139,
|
||||
"lpf_stop": 210,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 480,
|
||||
"n_fft": 960,
|
||||
"crop_start": 78,
|
||||
"crop_stop": 383,
|
||||
"hpf_start": 130,
|
||||
"hpf_stop": 86,
|
||||
"res_type": "kaiser_fast"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 668,
|
||||
"pre_filter_stop": 672
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"bins": 672,
|
||||
"unstable_bins": 8,
|
||||
"reduction_bins": 637,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 7350,
|
||||
"hl": 80,
|
||||
"n_fft": 640,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 85,
|
||||
"lpf_start": 25,
|
||||
"lpf_stop": 53,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 7350,
|
||||
"hl": 80,
|
||||
"n_fft": 320,
|
||||
"crop_start": 4,
|
||||
"crop_stop": 87,
|
||||
"hpf_start": 25,
|
||||
"hpf_stop": 12,
|
||||
"lpf_start": 31,
|
||||
"lpf_stop": 62,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 14700,
|
||||
"hl": 160,
|
||||
"n_fft": 512,
|
||||
"crop_start": 17,
|
||||
"crop_stop": 216,
|
||||
"hpf_start": 48,
|
||||
"hpf_stop": 24,
|
||||
"lpf_start": 139,
|
||||
"lpf_stop": 210,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"4": {
|
||||
"sr": 44100,
|
||||
"hl": 480,
|
||||
"n_fft": 960,
|
||||
"crop_start": 78,
|
||||
"crop_stop": 383,
|
||||
"hpf_start": 130,
|
||||
"hpf_stop": 86,
|
||||
"convert_channels": "stereo_n",
|
||||
"res_type": "kaiser_fast"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 668,
|
||||
"pre_filter_stop": 672
|
||||
}
|
@ -1 +0,0 @@
|
||||
Auto
|
@ -1,43 +0,0 @@
|
||||
{
|
||||
"mid_side_b2": true,
|
||||
"bins": 1280,
|
||||
"unstable_bins": 7,
|
||||
"reduction_bins": 565,
|
||||
"band": {
|
||||
"1": {
|
||||
"sr": 11025,
|
||||
"hl": 108,
|
||||
"n_fft": 2048,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 374,
|
||||
"lpf_start": 92,
|
||||
"lpf_stop": 186,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"2": {
|
||||
"sr": 22050,
|
||||
"hl": 216,
|
||||
"n_fft": 1536,
|
||||
"crop_start": 0,
|
||||
"crop_stop": 424,
|
||||
"hpf_start": 68,
|
||||
"hpf_stop": 34,
|
||||
"lpf_start": 348,
|
||||
"lpf_stop": 418,
|
||||
"res_type": "polyphase"
|
||||
},
|
||||
"3": {
|
||||
"sr": 44100,
|
||||
"hl": 432,
|
||||
"n_fft": 1280,
|
||||
"crop_start": 132,
|
||||
"crop_stop": 614,
|
||||
"hpf_start": 172,
|
||||
"hpf_stop": 144,
|
||||
"res_type": "polyphase"
|
||||
}
|
||||
},
|
||||
"sr": 44100,
|
||||
"pre_filter_start": 1280,
|
||||
"pre_filter_stop": 1280
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
def provide_model_param_hash(model_hash):
|
||||
#v5 Models
|
||||
if model_hash == '47939caf0cfe52a0e81442b85b971dfd':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '4e4ecb9764c50a8c414fee6e10395bbe':
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2.json')
|
||||
param_name=str('4band_v2')
|
||||
elif model_hash == 'e60a1e84803ce4efc0a6551206cc4b71':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == 'a82f14e75892e55e994376edbf0c8435':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '6dd9eaa6f0420af9f1d403aaafa4cc06':
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2_sn.json')
|
||||
param_name=str('4band_v2_sn')
|
||||
elif model_hash == '5c7bbca45a187e81abbbd351606164e5':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
elif model_hash == 'd6b2cb685a058a091e5e7098192d3233':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
elif model_hash == 'c1b9f38170a7c90e96f027992eb7c62b':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == 'c3448ec923fa0edf3d03a19e633faa53':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif model_hash == '68aa2c8093d0080704b200d140f59e54':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100.json')
|
||||
param_name=str('3band_44100.json')
|
||||
elif model_hash == 'fdc83be5b798e4bd29fe00fe6600e147':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid.json')
|
||||
elif model_hash == '2ce34bc92fd57f55db16b7a4def3d745':
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid.json')
|
||||
elif model_hash == '52fdca89576f06cf4340b74a4730ee5f':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100.json')
|
||||
elif model_hash == '41191165b05d38fc77f072fa9e8e8a30':
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100.json')
|
||||
elif model_hash == '89e83b511ad474592689e562d5b1f80e':
|
||||
model_params_set=str('lib_v5/modelparams/2band_32000.json')
|
||||
param_name=str('2band_32000.json')
|
||||
elif model_hash == '0b954da81d453b716b114d6d7c95177f':
|
||||
model_params_set=str('lib_v5/modelparams/2band_32000.json')
|
||||
param_name=str('2band_32000.json')
|
||||
|
||||
#v4 Models
|
||||
|
||||
elif model_hash == '6a00461c51c2920fd68937d4609ed6c8':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr16000_hl512.json')
|
||||
param_name=str('1band_sr16000_hl512')
|
||||
elif model_hash == '0ab504864d20f1bd378fe9c81ef37140':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == '7dd21065bf91c10f7fccb57d7d83b07f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == '80ab74d65e515caa3622728d2de07d23':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif model_hash == 'edc115e7fc523245062200c00caa847f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif model_hash == '28063e9f6ab5b341c5f6d3c67f2045b7':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif model_hash == 'b58090534c52cbc3e9b5104bad666ef2':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif model_hash == '0cdab9947f1b0928705f518f3c78ea8f':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif model_hash == 'ae702fed0238afb5346db8356fe25f13':
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl1024.json')
|
||||
param_name=str('1band_sr44100_hl1024')
|
||||
else:
|
||||
model_params_set=str('Not Found Using Hash')
|
||||
param_name=str('Not Found Using Hash')
|
||||
|
||||
model_params = model_params_set, param_name
|
||||
|
||||
return model_params
|
||||
|
||||
def provide_model_param_name(ModelName):
|
||||
#1 Band
|
||||
if '1band_sr16000_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr16000_hl512.json')
|
||||
param_name=str('1band_sr16000_hl512')
|
||||
elif '1band_sr32000_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr32000_hl512.json')
|
||||
param_name=str('1band_sr32000_hl512')
|
||||
elif '1band_sr33075_hl384' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr33075_hl384.json')
|
||||
param_name=str('1band_sr33075_hl384')
|
||||
elif '1band_sr44100_hl256' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl256.json')
|
||||
param_name=str('1band_sr44100_hl256')
|
||||
elif '1band_sr44100_hl512' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl512.json')
|
||||
param_name=str('1band_sr44100_hl512')
|
||||
elif '1band_sr44100_hl1024' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/1band_sr44100_hl1024.json')
|
||||
param_name=str('1band_sr44100_hl1024')
|
||||
|
||||
#2 Band
|
||||
elif '2band_44100_lofi' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/2band_44100_lofi.json')
|
||||
param_name=str('2band_44100_lofi')
|
||||
elif '2band_32000' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/2band_32000.json')
|
||||
param_name=str('2band_32000')
|
||||
elif '2band_48000' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/2band_48000.json')
|
||||
param_name=str('2band_48000')
|
||||
|
||||
#3 Band
|
||||
elif '3band_44100' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100.json')
|
||||
param_name=str('3band_44100')
|
||||
elif '3band_44100_mid' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_mid.json')
|
||||
param_name=str('3band_44100_mid')
|
||||
elif '3band_44100_msb2' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/3band_44100_msb2.json')
|
||||
param_name=str('3band_44100_msb2')
|
||||
|
||||
#4 Band
|
||||
elif '4band_44100' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100.json')
|
||||
param_name=str('4band_44100')
|
||||
elif '4band_44100_mid' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_mid.json')
|
||||
param_name=str('4band_44100_mid')
|
||||
elif '4band_44100_msb' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_msb.json')
|
||||
param_name=str('4band_44100_msb')
|
||||
elif '4band_44100_msb2' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_msb2.json')
|
||||
param_name=str('4band_44100_msb2')
|
||||
elif '4band_44100_reverse' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_reverse.json')
|
||||
param_name=str('4band_44100_reverse')
|
||||
elif '4band_44100_sw' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_44100_sw.json')
|
||||
param_name=str('4band_44100_sw')
|
||||
elif '4band_v2' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2.json')
|
||||
param_name=str('4band_v2')
|
||||
elif '4band_v2_sn' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/4band_v2_sn.json')
|
||||
param_name=str('4band_v2_sn')
|
||||
elif 'tmodelparam' in ModelName:
|
||||
model_params_set=str('lib_v5/modelparams/tmodelparam.json')
|
||||
param_name=str('User Model Param Set')
|
||||
else:
|
||||
model_params_set=str('Not Found Using Name')
|
||||
param_name=str('Not Found Using Name')
|
||||
|
||||
model_params = model_params_set, param_name
|
||||
|
||||
return model_params
|
113
lib_v5/nets.py
@ -1,113 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers
|
||||
from lib_v5 import spec_utils
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 16)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 16)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(18, 8, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(8, 16)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(16, 32)
|
||||
|
||||
self.out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,112 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_123821KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 32)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 32)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(16, 32)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(66, 32, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(32, 64)
|
||||
|
||||
self.out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,112 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_123821KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 32)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 32)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(16, 32)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(66, 32, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(32, 64)
|
||||
|
||||
self.out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,116 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_129605KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16, 32)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
self.enc5 = layers.Encoder(ch * 8, ch * 16, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 16, ch * 32, dilations)
|
||||
|
||||
self.dec5 = layers.Decoder(ch * (16 + 32), ch * 16, 3, 1, 1)
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
h, e5 = self.enc5(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec5(h, e5)
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 16)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 16)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(18, 8, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(8, 16)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(16, 32)
|
||||
|
||||
self.out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,112 +0,0 @@
|
||||
import torch
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_33966KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16, 32)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 16)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 16)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(18, 8, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(8, 16)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(34, 16, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(16, 32)
|
||||
|
||||
self.out = nn.Conv2d(32, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(16, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,113 +0,0 @@
|
||||
import torch
|
||||
import numpy as np
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_537238KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 64)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 64)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(66, 32, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(32, 64)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(130, 64, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(64, 128)
|
||||
|
||||
self.out = nn.Conv2d(128, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1,113 +0,0 @@
|
||||
import torch
|
||||
import numpy as np
|
||||
from torch import nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from lib_v5 import layers_537238KB as layers
|
||||
|
||||
|
||||
class BaseASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, nin, ch, dilations=(4, 8, 16)):
|
||||
super(BaseASPPNet, self).__init__()
|
||||
self.enc1 = layers.Encoder(nin, ch, 3, 2, 1)
|
||||
self.enc2 = layers.Encoder(ch, ch * 2, 3, 2, 1)
|
||||
self.enc3 = layers.Encoder(ch * 2, ch * 4, 3, 2, 1)
|
||||
self.enc4 = layers.Encoder(ch * 4, ch * 8, 3, 2, 1)
|
||||
|
||||
self.aspp = layers.ASPPModule(ch * 8, ch * 16, dilations)
|
||||
|
||||
self.dec4 = layers.Decoder(ch * (8 + 16), ch * 8, 3, 1, 1)
|
||||
self.dec3 = layers.Decoder(ch * (4 + 8), ch * 4, 3, 1, 1)
|
||||
self.dec2 = layers.Decoder(ch * (2 + 4), ch * 2, 3, 1, 1)
|
||||
self.dec1 = layers.Decoder(ch * (1 + 2), ch, 3, 1, 1)
|
||||
|
||||
def __call__(self, x):
|
||||
h, e1 = self.enc1(x)
|
||||
h, e2 = self.enc2(h)
|
||||
h, e3 = self.enc3(h)
|
||||
h, e4 = self.enc4(h)
|
||||
|
||||
h = self.aspp(h)
|
||||
|
||||
h = self.dec4(h, e4)
|
||||
h = self.dec3(h, e3)
|
||||
h = self.dec2(h, e2)
|
||||
h = self.dec1(h, e1)
|
||||
|
||||
return h
|
||||
|
||||
|
||||
class CascadedASPPNet(nn.Module):
|
||||
|
||||
def __init__(self, n_fft):
|
||||
super(CascadedASPPNet, self).__init__()
|
||||
self.stg1_low_band_net = BaseASPPNet(2, 64)
|
||||
self.stg1_high_band_net = BaseASPPNet(2, 64)
|
||||
|
||||
self.stg2_bridge = layers.Conv2DBNActiv(66, 32, 1, 1, 0)
|
||||
self.stg2_full_band_net = BaseASPPNet(32, 64)
|
||||
|
||||
self.stg3_bridge = layers.Conv2DBNActiv(130, 64, 1, 1, 0)
|
||||
self.stg3_full_band_net = BaseASPPNet(64, 128)
|
||||
|
||||
self.out = nn.Conv2d(128, 2, 1, bias=False)
|
||||
self.aux1_out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
self.aux2_out = nn.Conv2d(64, 2, 1, bias=False)
|
||||
|
||||
self.max_bin = n_fft // 2
|
||||
self.output_bin = n_fft // 2 + 1
|
||||
|
||||
self.offset = 128
|
||||
|
||||
def forward(self, x, aggressiveness=None):
|
||||
mix = x.detach()
|
||||
x = x.clone()
|
||||
|
||||
x = x[:, :, :self.max_bin]
|
||||
|
||||
bandw = x.size()[2] // 2
|
||||
aux1 = torch.cat([
|
||||
self.stg1_low_band_net(x[:, :, :bandw]),
|
||||
self.stg1_high_band_net(x[:, :, bandw:])
|
||||
], dim=2)
|
||||
|
||||
h = torch.cat([x, aux1], dim=1)
|
||||
aux2 = self.stg2_full_band_net(self.stg2_bridge(h))
|
||||
|
||||
h = torch.cat([x, aux1, aux2], dim=1)
|
||||
h = self.stg3_full_band_net(self.stg3_bridge(h))
|
||||
|
||||
mask = torch.sigmoid(self.out(h))
|
||||
mask = F.pad(
|
||||
input=mask,
|
||||
pad=(0, 0, 0, self.output_bin - mask.size()[2]),
|
||||
mode='replicate')
|
||||
|
||||
if self.training:
|
||||
aux1 = torch.sigmoid(self.aux1_out(aux1))
|
||||
aux1 = F.pad(
|
||||
input=aux1,
|
||||
pad=(0, 0, 0, self.output_bin - aux1.size()[2]),
|
||||
mode='replicate')
|
||||
aux2 = torch.sigmoid(self.aux2_out(aux2))
|
||||
aux2 = F.pad(
|
||||
input=aux2,
|
||||
pad=(0, 0, 0, self.output_bin - aux2.size()[2]),
|
||||
mode='replicate')
|
||||
return mask * mix, aux1 * mix, aux2 * mix
|
||||
else:
|
||||
if aggressiveness:
|
||||
mask[:, :, :aggressiveness['split_bin']] = torch.pow(mask[:, :, :aggressiveness['split_bin']], 1 + aggressiveness['value'] / 3)
|
||||
mask[:, :, aggressiveness['split_bin']:] = torch.pow(mask[:, :, aggressiveness['split_bin']:], 1 + aggressiveness['value'])
|
||||
|
||||
return mask * mix
|
||||
|
||||
def predict(self, x_mag, aggressiveness=None):
|
||||
h = self.forward(x_mag, aggressiveness)
|
||||
|
||||
if self.offset > 0:
|
||||
h = h[:, :, :, self.offset:-self.offset]
|
||||
assert h.size()[3] > 0
|
||||
|
||||
return h
|
@ -1 +0,0 @@
|
||||
Sox goes here
|
@ -1,549 +0,0 @@
|
||||
import os
|
||||
|
||||
import librosa
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
import math
|
||||
import json
|
||||
import hashlib
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
def crop_center(h1, h2):
|
||||
h1_shape = h1.size()
|
||||
h2_shape = h2.size()
|
||||
|
||||
if h1_shape[3] == h2_shape[3]:
|
||||
return h1
|
||||
elif h1_shape[3] < h2_shape[3]:
|
||||
raise ValueError('h1_shape[3] must be greater than h2_shape[3]')
|
||||
|
||||
# s_freq = (h2_shape[2] - h1_shape[2]) // 2
|
||||
# e_freq = s_freq + h1_shape[2]
|
||||
s_time = (h1_shape[3] - h2_shape[3]) // 2
|
||||
e_time = s_time + h2_shape[3]
|
||||
h1 = h1[:, :, :, s_time:e_time]
|
||||
|
||||
return h1
|
||||
|
||||
|
||||
def wave_to_spectrogram(wave, hop_length, n_fft, mid_side=False, mid_side_b2=False, reverse=False):
|
||||
if reverse:
|
||||
wave_left = np.flip(np.asfortranarray(wave[0]))
|
||||
wave_right = np.flip(np.asfortranarray(wave[1]))
|
||||
elif mid_side:
|
||||
wave_left = np.asfortranarray(np.add(wave[0], wave[1]) / 2)
|
||||
wave_right = np.asfortranarray(np.subtract(wave[0], wave[1]))
|
||||
elif mid_side_b2:
|
||||
wave_left = np.asfortranarray(np.add(wave[1], wave[0] * .5))
|
||||
wave_right = np.asfortranarray(np.subtract(wave[0], wave[1] * .5))
|
||||
else:
|
||||
wave_left = np.asfortranarray(wave[0])
|
||||
wave_right = np.asfortranarray(wave[1])
|
||||
|
||||
spec_left = librosa.stft(wave_left, n_fft, hop_length=hop_length)
|
||||
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
|
||||
|
||||
spec = np.asfortranarray([spec_left, spec_right])
|
||||
|
||||
return spec
|
||||
|
||||
|
||||
def wave_to_spectrogram_mt(wave, hop_length, n_fft, mid_side=False, mid_side_b2=False, reverse=False):
|
||||
import threading
|
||||
|
||||
if reverse:
|
||||
wave_left = np.flip(np.asfortranarray(wave[0]))
|
||||
wave_right = np.flip(np.asfortranarray(wave[1]))
|
||||
elif mid_side:
|
||||
wave_left = np.asfortranarray(np.add(wave[0], wave[1]) / 2)
|
||||
wave_right = np.asfortranarray(np.subtract(wave[0], wave[1]))
|
||||
elif mid_side_b2:
|
||||
wave_left = np.asfortranarray(np.add(wave[1], wave[0] * .5))
|
||||
wave_right = np.asfortranarray(np.subtract(wave[0], wave[1] * .5))
|
||||
else:
|
||||
wave_left = np.asfortranarray(wave[0])
|
||||
wave_right = np.asfortranarray(wave[1])
|
||||
|
||||
def run_thread(**kwargs):
|
||||
global spec_left
|
||||
spec_left = librosa.stft(**kwargs)
|
||||
|
||||
thread = threading.Thread(target=run_thread, kwargs={'y': wave_left, 'n_fft': n_fft, 'hop_length': hop_length})
|
||||
thread.start()
|
||||
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
|
||||
thread.join()
|
||||
|
||||
spec = np.asfortranarray([spec_left, spec_right])
|
||||
|
||||
return spec
|
||||
|
||||
def normalize(wave_res):
|
||||
"""Save output music files"""
|
||||
maxv = np.abs(wave_res).max()
|
||||
if maxv > 1.0:
|
||||
print(f"\nNormalization Set On: Input above threshold for clipping. The result was normalized. Max:{maxv}\n")
|
||||
wave_res /= maxv
|
||||
else:
|
||||
print(f"\nNormalization Set On: Input not above threshold for clipping. Max:{maxv}\n")
|
||||
|
||||
return wave_res
|
||||
|
||||
def nonormalize(wave_res):
|
||||
"""Save output music files"""
|
||||
maxv = np.abs(wave_res).max()
|
||||
if maxv > 1.0:
|
||||
print(f"\nNormalization Set Off: Input above threshold for clipping. The result was not normalized. Max:{maxv}\n")
|
||||
else:
|
||||
print(f"\nNormalization Set Off: Input not above threshold for clipping. Max:{maxv}\n")
|
||||
|
||||
return wave_res
|
||||
|
||||
def combine_spectrograms(specs, mp):
|
||||
l = min([specs[i].shape[2] for i in specs])
|
||||
spec_c = np.zeros(shape=(2, mp.param['bins'] + 1, l), dtype=np.complex64)
|
||||
offset = 0
|
||||
bands_n = len(mp.param['band'])
|
||||
|
||||
for d in range(1, bands_n + 1):
|
||||
h = mp.param['band'][d]['crop_stop'] - mp.param['band'][d]['crop_start']
|
||||
spec_c[:, offset:offset+h, :l] = specs[d][:, mp.param['band'][d]['crop_start']:mp.param['band'][d]['crop_stop'], :l]
|
||||
offset += h
|
||||
|
||||
if offset > mp.param['bins']:
|
||||
raise ValueError('Too much bins')
|
||||
|
||||
# lowpass fiter
|
||||
if mp.param['pre_filter_start'] > 0: # and mp.param['band'][bands_n]['res_type'] in ['scipy', 'polyphase']:
|
||||
if bands_n == 1:
|
||||
spec_c = fft_lp_filter(spec_c, mp.param['pre_filter_start'], mp.param['pre_filter_stop'])
|
||||
else:
|
||||
gp = 1
|
||||
for b in range(mp.param['pre_filter_start'] + 1, mp.param['pre_filter_stop']):
|
||||
g = math.pow(10, -(b - mp.param['pre_filter_start']) * (3.5 - gp) / 20.0)
|
||||
gp = g
|
||||
spec_c[:, b, :] *= g
|
||||
|
||||
return np.asfortranarray(spec_c)
|
||||
|
||||
|
||||
def spectrogram_to_image(spec, mode='magnitude'):
|
||||
if mode == 'magnitude':
|
||||
if np.iscomplexobj(spec):
|
||||
y = np.abs(spec)
|
||||
else:
|
||||
y = spec
|
||||
y = np.log10(y ** 2 + 1e-8)
|
||||
elif mode == 'phase':
|
||||
if np.iscomplexobj(spec):
|
||||
y = np.angle(spec)
|
||||
else:
|
||||
y = spec
|
||||
|
||||
y -= y.min()
|
||||
y *= 255 / y.max()
|
||||
img = np.uint8(y)
|
||||
|
||||
if y.ndim == 3:
|
||||
img = img.transpose(1, 2, 0)
|
||||
img = np.concatenate([
|
||||
np.max(img, axis=2, keepdims=True), img
|
||||
], axis=2)
|
||||
|
||||
return img
|
||||
|
||||
|
||||
def reduce_vocal_aggressively(X, y, softmask):
|
||||
v = X - y
|
||||
y_mag_tmp = np.abs(y)
|
||||
v_mag_tmp = np.abs(v)
|
||||
|
||||
v_mask = v_mag_tmp > y_mag_tmp
|
||||
y_mag = np.clip(y_mag_tmp - v_mag_tmp * v_mask * softmask, 0, np.inf)
|
||||
|
||||
return y_mag * np.exp(1.j * np.angle(y))
|
||||
|
||||
|
||||
def mask_silence(mag, ref, thres=0.2, min_range=64, fade_size=32):
|
||||
if min_range < fade_size * 2:
|
||||
raise ValueError('min_range must be >= fade_area * 2')
|
||||
|
||||
mag = mag.copy()
|
||||
|
||||
idx = np.where(ref.mean(axis=(0, 1)) < thres)[0]
|
||||
starts = np.insert(idx[np.where(np.diff(idx) != 1)[0] + 1], 0, idx[0])
|
||||
ends = np.append(idx[np.where(np.diff(idx) != 1)[0]], idx[-1])
|
||||
uninformative = np.where(ends - starts > min_range)[0]
|
||||
if len(uninformative) > 0:
|
||||
starts = starts[uninformative]
|
||||
ends = ends[uninformative]
|
||||
old_e = None
|
||||
for s, e in zip(starts, ends):
|
||||
if old_e is not None and s - old_e < fade_size:
|
||||
s = old_e - fade_size * 2
|
||||
|
||||
if s != 0:
|
||||
weight = np.linspace(0, 1, fade_size)
|
||||
mag[:, :, s:s + fade_size] += weight * ref[:, :, s:s + fade_size]
|
||||
else:
|
||||
s -= fade_size
|
||||
|
||||
if e != mag.shape[2]:
|
||||
weight = np.linspace(1, 0, fade_size)
|
||||
mag[:, :, e - fade_size:e] += weight * ref[:, :, e - fade_size:e]
|
||||
else:
|
||||
e += fade_size
|
||||
|
||||
mag[:, :, s + fade_size:e - fade_size] += ref[:, :, s + fade_size:e - fade_size]
|
||||
old_e = e
|
||||
|
||||
return mag
|
||||
|
||||
|
||||
def align_wave_head_and_tail(a, b):
|
||||
l = min([a[0].size, b[0].size])
|
||||
|
||||
return a[:l,:l], b[:l,:l]
|
||||
|
||||
|
||||
def cache_or_load(mix_path, inst_path, mp):
|
||||
mix_basename = os.path.splitext(os.path.basename(mix_path))[0]
|
||||
inst_basename = os.path.splitext(os.path.basename(inst_path))[0]
|
||||
|
||||
cache_dir = 'mph{}'.format(hashlib.sha1(json.dumps(mp.param, sort_keys=True).encode('utf-8')).hexdigest())
|
||||
mix_cache_dir = os.path.join('cache', cache_dir)
|
||||
inst_cache_dir = os.path.join('cache', cache_dir)
|
||||
|
||||
os.makedirs(mix_cache_dir, exist_ok=True)
|
||||
os.makedirs(inst_cache_dir, exist_ok=True)
|
||||
|
||||
mix_cache_path = os.path.join(mix_cache_dir, mix_basename + '.npy')
|
||||
inst_cache_path = os.path.join(inst_cache_dir, inst_basename + '.npy')
|
||||
|
||||
if os.path.exists(mix_cache_path) and os.path.exists(inst_cache_path):
|
||||
X_spec_m = np.load(mix_cache_path)
|
||||
y_spec_m = np.load(inst_cache_path)
|
||||
else:
|
||||
X_wave, y_wave, X_spec_s, y_spec_s = {}, {}, {}, {}
|
||||
|
||||
for d in range(len(mp.param['band']), 0, -1):
|
||||
bp = mp.param['band'][d]
|
||||
|
||||
if d == len(mp.param['band']): # high-end band
|
||||
X_wave[d], _ = librosa.load(
|
||||
mix_path, bp['sr'], False, dtype=np.float32, res_type=bp['res_type'])
|
||||
y_wave[d], _ = librosa.load(
|
||||
inst_path, bp['sr'], False, dtype=np.float32, res_type=bp['res_type'])
|
||||
else: # lower bands
|
||||
X_wave[d] = librosa.resample(X_wave[d+1], mp.param['band'][d+1]['sr'], bp['sr'], res_type=bp['res_type'])
|
||||
y_wave[d] = librosa.resample(y_wave[d+1], mp.param['band'][d+1]['sr'], bp['sr'], res_type=bp['res_type'])
|
||||
|
||||
X_wave[d], y_wave[d] = align_wave_head_and_tail(X_wave[d], y_wave[d])
|
||||
|
||||
X_spec_s[d] = wave_to_spectrogram(X_wave[d], bp['hl'], bp['n_fft'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse'])
|
||||
y_spec_s[d] = wave_to_spectrogram(y_wave[d], bp['hl'], bp['n_fft'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse'])
|
||||
|
||||
del X_wave, y_wave
|
||||
|
||||
X_spec_m = combine_spectrograms(X_spec_s, mp)
|
||||
y_spec_m = combine_spectrograms(y_spec_s, mp)
|
||||
|
||||
if X_spec_m.shape != y_spec_m.shape:
|
||||
raise ValueError('The combined spectrograms are different: ' + mix_path)
|
||||
|
||||
_, ext = os.path.splitext(mix_path)
|
||||
|
||||
np.save(mix_cache_path, X_spec_m)
|
||||
np.save(inst_cache_path, y_spec_m)
|
||||
|
||||
return X_spec_m, y_spec_m
|
||||
|
||||
|
||||
def spectrogram_to_wave(spec, hop_length, mid_side, mid_side_b2, reverse, clamp=False):
|
||||
spec_left = np.asfortranarray(spec[0])
|
||||
spec_right = np.asfortranarray(spec[1])
|
||||
|
||||
wave_left = librosa.istft(spec_left, hop_length=hop_length)
|
||||
wave_right = librosa.istft(spec_right, hop_length=hop_length)
|
||||
|
||||
if reverse:
|
||||
return np.asfortranarray([np.flip(wave_left), np.flip(wave_right)])
|
||||
elif mid_side:
|
||||
return np.asfortranarray([np.add(wave_left, wave_right / 2), np.subtract(wave_left, wave_right / 2)])
|
||||
elif mid_side_b2:
|
||||
return np.asfortranarray([np.add(wave_right / 1.25, .4 * wave_left), np.subtract(wave_left / 1.25, .4 * wave_right)])
|
||||
else:
|
||||
return np.asfortranarray([wave_left, wave_right])
|
||||
|
||||
|
||||
def spectrogram_to_wave_mt(spec, hop_length, mid_side, reverse, mid_side_b2):
|
||||
import threading
|
||||
|
||||
spec_left = np.asfortranarray(spec[0])
|
||||
spec_right = np.asfortranarray(spec[1])
|
||||
|
||||
def run_thread(**kwargs):
|
||||
global wave_left
|
||||
wave_left = librosa.istft(**kwargs)
|
||||
|
||||
thread = threading.Thread(target=run_thread, kwargs={'stft_matrix': spec_left, 'hop_length': hop_length})
|
||||
thread.start()
|
||||
wave_right = librosa.istft(spec_right, hop_length=hop_length)
|
||||
thread.join()
|
||||
|
||||
if reverse:
|
||||
return np.asfortranarray([np.flip(wave_left), np.flip(wave_right)])
|
||||
elif mid_side:
|
||||
return np.asfortranarray([np.add(wave_left, wave_right / 2), np.subtract(wave_left, wave_right / 2)])
|
||||
elif mid_side_b2:
|
||||
return np.asfortranarray([np.add(wave_right / 1.25, .4 * wave_left), np.subtract(wave_left / 1.25, .4 * wave_right)])
|
||||
else:
|
||||
return np.asfortranarray([wave_left, wave_right])
|
||||
|
||||
|
||||
def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
|
||||
wave_band = {}
|
||||
bands_n = len(mp.param['band'])
|
||||
offset = 0
|
||||
|
||||
for d in range(1, bands_n + 1):
|
||||
bp = mp.param['band'][d]
|
||||
spec_s = np.ndarray(shape=(2, bp['n_fft'] // 2 + 1, spec_m.shape[2]), dtype=complex)
|
||||
h = bp['crop_stop'] - bp['crop_start']
|
||||
spec_s[:, bp['crop_start']:bp['crop_stop'], :] = spec_m[:, offset:offset+h, :]
|
||||
|
||||
offset += h
|
||||
if d == bands_n: # higher
|
||||
if extra_bins_h: # if --high_end_process bypass
|
||||
max_bin = bp['n_fft'] // 2
|
||||
spec_s[:, max_bin-extra_bins_h:max_bin, :] = extra_bins[:, :extra_bins_h, :]
|
||||
if bp['hpf_start'] > 0:
|
||||
spec_s = fft_hp_filter(spec_s, bp['hpf_start'], bp['hpf_stop'] - 1)
|
||||
if bands_n == 1:
|
||||
wave = spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse'])
|
||||
else:
|
||||
wave = np.add(wave, spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']))
|
||||
else:
|
||||
sr = mp.param['band'][d+1]['sr']
|
||||
if d == 1: # lower
|
||||
spec_s = fft_lp_filter(spec_s, bp['lpf_start'], bp['lpf_stop'])
|
||||
wave = librosa.resample(spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']), bp['sr'], sr, res_type="sinc_fastest")
|
||||
else: # mid
|
||||
spec_s = fft_hp_filter(spec_s, bp['hpf_start'], bp['hpf_stop'] - 1)
|
||||
spec_s = fft_lp_filter(spec_s, bp['lpf_start'], bp['lpf_stop'])
|
||||
wave2 = np.add(wave, spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']))
|
||||
wave = librosa.resample(wave2, bp['sr'], sr, res_type="sinc_fastest")
|
||||
|
||||
return wave.T
|
||||
|
||||
def cmb_spectrogram_to_wave_d(spec_m, mp, extra_bins_h=None, extra_bins=None, demucs=True):
|
||||
wave_band = {}
|
||||
bands_n = len(mp.param['band'])
|
||||
offset = 0
|
||||
|
||||
for d in range(1, bands_n + 1):
|
||||
bp = mp.param['band'][d]
|
||||
spec_s = np.ndarray(shape=(2, bp['n_fft'] // 2 + 1, spec_m.shape[2]), dtype=complex)
|
||||
h = bp['crop_stop'] - bp['crop_start']
|
||||
spec_s[:, bp['crop_start']:bp['crop_stop'], :] = spec_m[:, offset:offset+h, :]
|
||||
|
||||
offset += h
|
||||
if d == bands_n: # higher
|
||||
if extra_bins_h: # if --high_end_process bypass
|
||||
max_bin = bp['n_fft'] // 2
|
||||
spec_s[:, max_bin-extra_bins_h:max_bin, :] = extra_bins[:, :extra_bins_h, :]
|
||||
if bp['hpf_start'] > 0:
|
||||
spec_s = fft_hp_filter(spec_s, bp['hpf_start'], bp['hpf_stop'] - 1)
|
||||
if bands_n == 1:
|
||||
wave = spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse'])
|
||||
else:
|
||||
wave = np.add(wave, spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']))
|
||||
else:
|
||||
sr = mp.param['band'][d+1]['sr']
|
||||
if d == 1: # lower
|
||||
spec_s = fft_lp_filter(spec_s, bp['lpf_start'], bp['lpf_stop'])
|
||||
wave = librosa.resample(spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']), bp['sr'], sr, res_type="sinc_fastest")
|
||||
else: # mid
|
||||
spec_s = fft_hp_filter(spec_s, bp['hpf_start'], bp['hpf_stop'] - 1)
|
||||
spec_s = fft_lp_filter(spec_s, bp['lpf_start'], bp['lpf_stop'])
|
||||
wave2 = np.add(wave, spectrogram_to_wave(spec_s, bp['hl'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse']))
|
||||
wave = librosa.resample(wave2, bp['sr'], sr, res_type="sinc_fastest")
|
||||
|
||||
#print(demucs)
|
||||
|
||||
if demucs == True:
|
||||
wave = librosa.resample(wave, bp['sr'], 44100, res_type="sinc_fastest")
|
||||
return wave
|
||||
else:
|
||||
return wave
|
||||
|
||||
def fft_lp_filter(spec, bin_start, bin_stop):
|
||||
g = 1.0
|
||||
for b in range(bin_start, bin_stop):
|
||||
g -= 1 / (bin_stop - bin_start)
|
||||
spec[:, b, :] = g * spec[:, b, :]
|
||||
|
||||
spec[:, bin_stop:, :] *= 0
|
||||
|
||||
return spec
|
||||
|
||||
|
||||
def fft_hp_filter(spec, bin_start, bin_stop):
|
||||
g = 1.0
|
||||
for b in range(bin_start, bin_stop, -1):
|
||||
g -= 1 / (bin_start - bin_stop)
|
||||
spec[:, b, :] = g * spec[:, b, :]
|
||||
|
||||
spec[:, 0:bin_stop+1, :] *= 0
|
||||
|
||||
return spec
|
||||
|
||||
|
||||
def mirroring(a, spec_m, input_high_end, mp):
|
||||
if 'mirroring' == a:
|
||||
mirror = np.flip(np.abs(spec_m[:, mp.param['pre_filter_start']-10-input_high_end.shape[1]:mp.param['pre_filter_start']-10, :]), 1)
|
||||
mirror = mirror * np.exp(1.j * np.angle(input_high_end))
|
||||
|
||||
return np.where(np.abs(input_high_end) <= np.abs(mirror), input_high_end, mirror)
|
||||
|
||||
if 'mirroring2' == a:
|
||||
mirror = np.flip(np.abs(spec_m[:, mp.param['pre_filter_start']-10-input_high_end.shape[1]:mp.param['pre_filter_start']-10, :]), 1)
|
||||
mi = np.multiply(mirror, input_high_end * 1.7)
|
||||
|
||||
return np.where(np.abs(input_high_end) <= np.abs(mi), input_high_end, mi)
|
||||
|
||||
|
||||
def ensembling(a, specs):
|
||||
for i in range(1, len(specs)):
|
||||
if i == 1:
|
||||
spec = specs[0]
|
||||
|
||||
ln = min([spec.shape[2], specs[i].shape[2]])
|
||||
spec = spec[:,:,:ln]
|
||||
specs[i] = specs[i][:,:,:ln]
|
||||
|
||||
if 'min_mag' == a:
|
||||
spec = np.where(np.abs(specs[i]) <= np.abs(spec), specs[i], spec)
|
||||
if 'max_mag' == a:
|
||||
spec = np.where(np.abs(specs[i]) >= np.abs(spec), specs[i], spec)
|
||||
|
||||
return spec
|
||||
|
||||
def stft(wave, nfft, hl):
|
||||
wave_left = np.asfortranarray(wave[0])
|
||||
wave_right = np.asfortranarray(wave[1])
|
||||
spec_left = librosa.stft(wave_left, nfft, hop_length=hl)
|
||||
spec_right = librosa.stft(wave_right, nfft, hop_length=hl)
|
||||
spec = np.asfortranarray([spec_left, spec_right])
|
||||
|
||||
return spec
|
||||
|
||||
def istft(spec, hl):
|
||||
spec_left = np.asfortranarray(spec[0])
|
||||
spec_right = np.asfortranarray(spec[1])
|
||||
|
||||
wave_left = librosa.istft(spec_left, hop_length=hl)
|
||||
wave_right = librosa.istft(spec_right, hop_length=hl)
|
||||
wave = np.asfortranarray([wave_left, wave_right])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import cv2
|
||||
import sys
|
||||
import time
|
||||
import argparse
|
||||
from model_param_init import ModelParameters
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--algorithm', '-a', type=str, choices=['invert', 'invert_p', 'min_mag', 'max_mag', 'deep', 'align'], default='min_mag')
|
||||
p.add_argument('--model_params', '-m', type=str, default=os.path.join('modelparams', '1band_sr44100_hl512.json'))
|
||||
p.add_argument('--output_name', '-o', type=str, default='output')
|
||||
p.add_argument('--vocals_only', '-v', action='store_true')
|
||||
p.add_argument('input', nargs='+')
|
||||
args = p.parse_args()
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
if args.algorithm.startswith('invert') and len(args.input) != 2:
|
||||
raise ValueError('There should be two input files.')
|
||||
|
||||
if not args.algorithm.startswith('invert') and len(args.input) < 2:
|
||||
raise ValueError('There must be at least two input files.')
|
||||
|
||||
wave, specs = {}, {}
|
||||
mp = ModelParameters(args.model_params)
|
||||
|
||||
for i in range(len(args.input)):
|
||||
spec = {}
|
||||
|
||||
for d in range(len(mp.param['band']), 0, -1):
|
||||
bp = mp.param['band'][d]
|
||||
|
||||
if d == len(mp.param['band']): # high-end band
|
||||
wave[d], _ = librosa.load(
|
||||
args.input[i], bp['sr'], False, dtype=np.float32, res_type=bp['res_type'])
|
||||
|
||||
if len(wave[d].shape) == 1: # mono to stereo
|
||||
wave[d] = np.array([wave[d], wave[d]])
|
||||
else: # lower bands
|
||||
wave[d] = librosa.resample(wave[d+1], mp.param['band'][d+1]['sr'], bp['sr'], res_type=bp['res_type'])
|
||||
|
||||
spec[d] = wave_to_spectrogram(wave[d], bp['hl'], bp['n_fft'], mp.param['mid_side'], mp.param['mid_side_b2'], mp.param['reverse'])
|
||||
|
||||
specs[i] = combine_spectrograms(spec, mp)
|
||||
|
||||
del wave
|
||||
|
||||
if args.algorithm == 'deep':
|
||||
d_spec = np.where(np.abs(specs[0]) <= np.abs(spec[1]), specs[0], spec[1])
|
||||
v_spec = d_spec - specs[1]
|
||||
sf.write(os.path.join('{}.wav'.format(args.output_name)), cmb_spectrogram_to_wave(v_spec, mp), mp.param['sr'])
|
||||
|
||||
if args.algorithm.startswith('invert'):
|
||||
ln = min([specs[0].shape[2], specs[1].shape[2]])
|
||||
specs[0] = specs[0][:,:,:ln]
|
||||
specs[1] = specs[1][:,:,:ln]
|
||||
|
||||
if 'invert_p' == args.algorithm:
|
||||
X_mag = np.abs(specs[0])
|
||||
y_mag = np.abs(specs[1])
|
||||
max_mag = np.where(X_mag >= y_mag, X_mag, y_mag)
|
||||
v_spec = specs[1] - max_mag * np.exp(1.j * np.angle(specs[0]))
|
||||
else:
|
||||
specs[1] = reduce_vocal_aggressively(specs[0], specs[1], 0.2)
|
||||
v_spec = specs[0] - specs[1]
|
||||
|
||||
if not args.vocals_only:
|
||||
X_mag = np.abs(specs[0])
|
||||
y_mag = np.abs(specs[1])
|
||||
v_mag = np.abs(v_spec)
|
||||
|
||||
X_image = spectrogram_to_image(X_mag)
|
||||
y_image = spectrogram_to_image(y_mag)
|
||||
v_image = spectrogram_to_image(v_mag)
|
||||
|
||||
cv2.imwrite('{}_X.png'.format(args.output_name), X_image)
|
||||
cv2.imwrite('{}_y.png'.format(args.output_name), y_image)
|
||||
cv2.imwrite('{}_v.png'.format(args.output_name), v_image)
|
||||
|
||||
sf.write('{}_X.wav'.format(args.output_name), cmb_spectrogram_to_wave(specs[0], mp), mp.param['sr'])
|
||||
sf.write('{}_y.wav'.format(args.output_name), cmb_spectrogram_to_wave(specs[1], mp), mp.param['sr'])
|
||||
|
||||
sf.write('{}_v.wav'.format(args.output_name), cmb_spectrogram_to_wave(v_spec, mp), mp.param['sr'])
|
||||
else:
|
||||
if not args.algorithm == 'deep':
|
||||
sf.write(os.path.join('ensembled','{}.wav'.format(args.output_name)), cmb_spectrogram_to_wave(ensembling(args.algorithm, specs), mp), mp.param['sr'])
|
||||
|
||||
if args.algorithm == 'align':
|
||||
|
||||
trackalignment = [
|
||||
{
|
||||
'file1':'"{}"'.format(args.input[0]),
|
||||
'file2':'"{}"'.format(args.input[1])
|
||||
}
|
||||
]
|
||||
|
||||
for i,e in tqdm(enumerate(trackalignment), desc="Performing Alignment..."):
|
||||
os.system(f"python lib/align_tracks.py {e['file1']} {e['file2']}")
|
||||
|
||||
#print('Total time: {0:.{1}f}s'.format(time.time() - start_time, 1))
|
@ -1,61 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
inited = False
|
||||
root = None
|
||||
|
||||
|
||||
def init(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
global inited
|
||||
global root
|
||||
|
||||
if not inited:
|
||||
from tkinter import _default_root
|
||||
|
||||
path = (Path(__file__).parent / "sun-valley.tcl").resolve()
|
||||
|
||||
try:
|
||||
_default_root.tk.call("source", str(path))
|
||||
except AttributeError:
|
||||
raise RuntimeError(
|
||||
"can't set theme. "
|
||||
"Tk is not initialized. "
|
||||
"Please first create a tkinter.Tk instance, then set the theme."
|
||||
) from None
|
||||
else:
|
||||
inited = True
|
||||
root = _default_root
|
||||
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@init
|
||||
def set_theme(theme):
|
||||
if theme not in {"dark", "light"}:
|
||||
raise RuntimeError(f"not a valid theme name: {theme}")
|
||||
|
||||
root.tk.call("set_theme", theme)
|
||||
|
||||
|
||||
@init
|
||||
def get_theme():
|
||||
theme = root.tk.call("ttk::style", "theme", "use")
|
||||
|
||||
try:
|
||||
return {"sun-valley-dark": "dark", "sun-valley-light": "light"}[theme]
|
||||
except KeyError:
|
||||
return theme
|
||||
|
||||
|
||||
@init
|
||||
def toggle_theme():
|
||||
if get_theme() == "dark":
|
||||
use_light_theme()
|
||||
else:
|
||||
use_dark_theme()
|
||||
|
||||
|
||||
use_dark_theme = lambda: set_theme("dark")
|
||||
use_light_theme = lambda: set_theme("light")
|
@ -1,46 +0,0 @@
|
||||
source [file join [file dirname [info script]] theme dark.tcl]
|
||||
|
||||
option add *tearOff 0
|
||||
|
||||
proc set_theme {mode} {
|
||||
if {$mode == "dark"} {
|
||||
ttk::style theme use "sun-valley-dark"
|
||||
|
||||
array set colors {
|
||||
-fg "#F6F6F7"
|
||||
-bg "#0e0e0f"
|
||||
-disabledfg "#F6F6F7"
|
||||
-selectfg "#F6F6F7"
|
||||
-selectbg "#003b50"
|
||||
}
|
||||
|
||||
ttk::style configure . \
|
||||
-background $colors(-bg) \
|
||||
-foreground $colors(-fg) \
|
||||
-troughcolor $colors(-bg) \
|
||||
-focuscolor $colors(-selectbg) \
|
||||
-selectbackground $colors(-selectbg) \
|
||||
-selectforeground $colors(-selectfg) \
|
||||
-insertwidth 0 \
|
||||
-insertcolor $colors(-fg) \
|
||||
-fieldbackground $colors(-selectbg) \
|
||||
-font {"Century Gothic" 10} \
|
||||
-borderwidth 0 \
|
||||
-relief flat
|
||||
|
||||
tk_setPalette \
|
||||
background [ttk::style lookup . -background] \
|
||||
foreground [ttk::style lookup . -foreground] \
|
||||
highlightColor [ttk::style lookup . -focuscolor] \
|
||||
selectBackground [ttk::style lookup . -selectbackground] \
|
||||
selectForeground [ttk::style lookup . -selectforeground] \
|
||||
activeBackground [ttk::style lookup . -selectbackground] \
|
||||
activeForeground [ttk::style lookup . -selectforeground]
|
||||
|
||||
ttk::style map . -foreground [list disabled $colors(-disabledfg)]
|
||||
|
||||
option add *font [ttk::style lookup . -font]
|
||||
option add *Menu.selectcolor $colors(-fg)
|
||||
option add *Menu.background #0e0e0f
|
||||
}
|
||||
}
|
@ -1,534 +0,0 @@
|
||||
# Copyright © 2021 rdbende <rdbende@gmail.com>
|
||||
|
||||
# A stunning dark theme for ttk based on Microsoft's Sun Valley visual style
|
||||
|
||||
package require Tk 8.6
|
||||
|
||||
namespace eval ttk::theme::sun-valley-dark {
|
||||
variable version 1.0
|
||||
package provide ttk::theme::sun-valley-dark $version
|
||||
|
||||
ttk::style theme create sun-valley-dark -parent clam -settings {
|
||||
proc load_images {imgdir} {
|
||||
variable images
|
||||
foreach file [glob -directory $imgdir *.png] {
|
||||
set images([file tail [file rootname $file]]) \
|
||||
[image create photo -file $file -format png]
|
||||
}
|
||||
}
|
||||
|
||||
load_images [file join [file dirname [info script]] dark]
|
||||
|
||||
array set colors {
|
||||
-fg "#F6F6F7"
|
||||
-bg "#0e0e0f"
|
||||
-disabledfg "#F6F6F7"
|
||||
-selectfg "#ffffff"
|
||||
-selectbg "#2f60d8"
|
||||
}
|
||||
|
||||
ttk::style layout TButton {
|
||||
Button.button -children {
|
||||
Button.padding -children {
|
||||
Button.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Toolbutton {
|
||||
Toolbutton.button -children {
|
||||
Toolbutton.padding -children {
|
||||
Toolbutton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TMenubutton {
|
||||
Menubutton.button -children {
|
||||
Menubutton.padding -children {
|
||||
Menubutton.label -side left -expand 1
|
||||
Menubutton.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TOptionMenu {
|
||||
OptionMenu.button -children {
|
||||
OptionMenu.padding -children {
|
||||
OptionMenu.label -side left -expand 0
|
||||
OptionMenu.indicator -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Accent.TButton {
|
||||
AccentButton.button -children {
|
||||
AccentButton.padding -children {
|
||||
AccentButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Titlebar.TButton {
|
||||
TitlebarButton.button -children {
|
||||
TitlebarButton.padding -children {
|
||||
TitlebarButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Close.Titlebar.TButton {
|
||||
CloseButton.button -children {
|
||||
CloseButton.padding -children {
|
||||
CloseButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TCheckbutton {
|
||||
Checkbutton.button -children {
|
||||
Checkbutton.padding -children {
|
||||
Checkbutton.indicator -side left
|
||||
Checkbutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Switch.TCheckbutton {
|
||||
Switch.button -children {
|
||||
Switch.padding -children {
|
||||
Switch.indicator -side left
|
||||
Switch.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Toggle.TButton {
|
||||
ToggleButton.button -children {
|
||||
ToggleButton.padding -children {
|
||||
ToggleButton.label -side left -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TRadiobutton {
|
||||
Radiobutton.button -children {
|
||||
Radiobutton.padding -children {
|
||||
Radiobutton.indicator -side left
|
||||
Radiobutton.label -side right -expand 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Vertical.TScrollbar {
|
||||
Vertical.Scrollbar.trough -sticky ns -children {
|
||||
Vertical.Scrollbar.uparrow -side top
|
||||
Vertical.Scrollbar.downarrow -side bottom
|
||||
Vertical.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Horizontal.TScrollbar {
|
||||
Horizontal.Scrollbar.trough -sticky ew -children {
|
||||
Horizontal.Scrollbar.leftarrow -side left
|
||||
Horizontal.Scrollbar.rightarrow -side right
|
||||
Horizontal.Scrollbar.thumb -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TSeparator {
|
||||
TSeparator.separator -sticky nsew
|
||||
}
|
||||
|
||||
ttk::style layout TCombobox {
|
||||
Combobox.field -sticky nsew -children {
|
||||
Combobox.padding -expand 1 -sticky nsew -children {
|
||||
Combobox.textarea -sticky nsew
|
||||
}
|
||||
}
|
||||
null -side right -sticky ns -children {
|
||||
Combobox.arrow -sticky nsew
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TSpinbox {
|
||||
Spinbox.field -sticky nsew -children {
|
||||
Spinbox.padding -expand 1 -sticky nsew -children {
|
||||
Spinbox.textarea -sticky nsew
|
||||
}
|
||||
|
||||
}
|
||||
null -side right -sticky nsew -children {
|
||||
Spinbox.uparrow -side left -sticky nsew
|
||||
Spinbox.downarrow -side right -sticky nsew
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Card.TFrame {
|
||||
Card.field {
|
||||
Card.padding -expand 1
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TLabelframe {
|
||||
Labelframe.border {
|
||||
Labelframe.padding -expand 1 -children {
|
||||
Labelframe.label -side left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout TNotebook {
|
||||
Notebook.border -children {
|
||||
TNotebook.Tab -expand 1
|
||||
Notebook.client -sticky nsew
|
||||
}
|
||||
}
|
||||
|
||||
ttk::style layout Treeview.Item {
|
||||
Treeitem.padding -sticky nsew -children {
|
||||
Treeitem.image -side left -sticky {}
|
||||
Treeitem.indicator -side left -sticky {}
|
||||
Treeitem.text -side left -sticky {}
|
||||
}
|
||||
}
|
||||
|
||||
# Button
|
||||
ttk::style configure TButton -padding {8 4} -anchor center -foreground $colors(-fg)
|
||||
|
||||
ttk::style map TButton -foreground \
|
||||
[list disabled #7a7a7a \
|
||||
pressed #d0d0d0]
|
||||
|
||||
ttk::style element create Button.button image \
|
||||
[list $images(button-rest) \
|
||||
{selected disabled} $images(button-disabled) \
|
||||
disabled $images(button-disabled) \
|
||||
selected $images(button-rest) \
|
||||
pressed $images(button-pressed) \
|
||||
active $images(button-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Toolbutton
|
||||
ttk::style configure Toolbutton -padding {8 4} -anchor center
|
||||
|
||||
ttk::style element create Toolbutton.button image \
|
||||
[list $images(empty) \
|
||||
{selected disabled} $images(button-disabled) \
|
||||
selected $images(button-rest) \
|
||||
pressed $images(button-pressed) \
|
||||
active $images(button-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Menubutton
|
||||
ttk::style configure TMenubutton -padding {8 4 0 4}
|
||||
|
||||
ttk::style element create Menubutton.button \
|
||||
image [list $images(button-rest) \
|
||||
disabled $images(button-disabled) \
|
||||
pressed $images(button-pressed) \
|
||||
active $images(button-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
ttk::style element create Menubutton.indicator image $images(arrow-down) -width 28 -sticky {}
|
||||
|
||||
# OptionMenu
|
||||
ttk::style configure TOptionMenu -padding {8 4 0 4}
|
||||
|
||||
ttk::style element create OptionMenu.button \
|
||||
image [list $images(button-rest) \
|
||||
disabled $images(button-disabled) \
|
||||
pressed $images(button-pressed) \
|
||||
active $images(button-hover) \
|
||||
] -border 0 -sticky nsew
|
||||
|
||||
ttk::style element create OptionMenu.indicator image $images(arrow-down) -width 28 -sticky {}
|
||||
|
||||
# Accent.TButton
|
||||
ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground #ffffff
|
||||
|
||||
ttk::style map Accent.TButton -foreground \
|
||||
[list pressed #25536a \
|
||||
disabled #a5a5a5]
|
||||
|
||||
ttk::style element create AccentButton.button image \
|
||||
[list $images(button-accent-rest) \
|
||||
{selected disabled} $images(button-accent-disabled) \
|
||||
disabled $images(button-accent-disabled) \
|
||||
selected $images(button-accent-rest) \
|
||||
pressed $images(button-accent-pressed) \
|
||||
active $images(button-accent-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Titlebar.TButton
|
||||
ttk::style configure Titlebar.TButton -padding {8 4} -anchor center -foreground #ffffff
|
||||
|
||||
ttk::style map Titlebar.TButton -foreground \
|
||||
[list disabled #6f6f6f \
|
||||
pressed #d1d1d1 \
|
||||
active #ffffff]
|
||||
|
||||
ttk::style element create TitlebarButton.button image \
|
||||
[list $images(empty) \
|
||||
disabled $images(empty) \
|
||||
pressed $images(button-titlebar-pressed) \
|
||||
active $images(button-titlebar-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Close.Titlebar.TButton
|
||||
ttk::style configure Close.Titlebar.TButton -padding {8 4} -anchor center -foreground #ffffff
|
||||
|
||||
ttk::style map Close.Titlebar.TButton -foreground \
|
||||
[list disabled #6f6f6f \
|
||||
pressed #e8bfbb \
|
||||
active #ffffff]
|
||||
|
||||
ttk::style element create CloseButton.button image \
|
||||
[list $images(empty) \
|
||||
disabled $images(empty) \
|
||||
pressed $images(button-close-pressed) \
|
||||
active $images(button-close-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Checkbutton
|
||||
ttk::style configure TCheckbutton -padding 4
|
||||
|
||||
ttk::style element create Checkbutton.indicator image \
|
||||
[list $images(check-unsel-rest) \
|
||||
{alternate disabled} $images(check-tri-disabled) \
|
||||
{selected disabled} $images(check-disabled) \
|
||||
disabled $images(check-unsel-disabled) \
|
||||
{pressed alternate} $images(check-tri-hover) \
|
||||
{active alternate} $images(check-tri-hover) \
|
||||
alternate $images(check-tri-rest) \
|
||||
{pressed selected} $images(check-hover) \
|
||||
{active selected} $images(check-hover) \
|
||||
selected $images(check-rest) \
|
||||
{pressed !selected} $images(check-unsel-pressed) \
|
||||
active $images(check-unsel-hover) \
|
||||
] -width 26 -sticky w
|
||||
|
||||
# Switch.TCheckbutton
|
||||
ttk::style element create Switch.indicator image \
|
||||
[list $images(switch-off-rest) \
|
||||
{selected disabled} $images(switch-on-disabled) \
|
||||
disabled $images(switch-off-disabled) \
|
||||
{pressed selected} $images(switch-on-pressed) \
|
||||
{active selected} $images(switch-on-hover) \
|
||||
selected $images(switch-on-rest) \
|
||||
{pressed !selected} $images(switch-off-pressed) \
|
||||
active $images(switch-off-hover) \
|
||||
] -width 46 -sticky w
|
||||
|
||||
# Toggle.TButton
|
||||
ttk::style configure Toggle.TButton -padding {8 4 8 4} -anchor center -foreground $colors(-fg)
|
||||
|
||||
ttk::style map Toggle.TButton -foreground \
|
||||
[list {selected disabled} #a5a5a5 \
|
||||
{selected pressed} #d0d0d0 \
|
||||
selected #ffffff \
|
||||
pressed #25536a \
|
||||
disabled #7a7a7a
|
||||
]
|
||||
|
||||
ttk::style element create ToggleButton.button image \
|
||||
[list $images(button-rest) \
|
||||
{selected disabled} $images(button-accent-disabled) \
|
||||
disabled $images(button-disabled) \
|
||||
{pressed selected} $images(button-rest) \
|
||||
{active selected} $images(button-accent-hover) \
|
||||
selected $images(button-accent-rest) \
|
||||
{pressed !selected} $images(button-accent-rest) \
|
||||
active $images(button-hover) \
|
||||
] -border 4 -sticky nsew
|
||||
|
||||
# Radiobutton
|
||||
ttk::style configure TRadiobutton -padding 0
|
||||
|
||||
ttk::style element create Radiobutton.indicator image \
|
||||
[list $images(radio-unsel-rest) \
|
||||
{selected disabled} $images(radio-disabled) \
|
||||
disabled $images(radio-unsel-disabled) \
|
||||
{pressed selected} $images(radio-pressed) \
|
||||
{active selected} $images(radio-hover) \
|
||||
selected $images(radio-rest) \
|
||||
{pressed !selected} $images(radio-unsel-pressed) \
|
||||
active $images(radio-unsel-hover) \
|
||||
] -width 20 -sticky w
|
||||
|
||||
ttk::style configure Menu.TRadiobutton -padding 0
|
||||
|
||||
ttk::style element create Menu.Radiobutton.indicator image \
|
||||
[list $images(radio-unsel-rest) \
|
||||
{selected disabled} $images(radio-disabled) \
|
||||
disabled $images(radio-unsel-disabled) \
|
||||
{pressed selected} $images(radio-pressed) \
|
||||
{active selected} $images(radio-hover) \
|
||||
selected $images(radio-rest) \
|
||||
{pressed !selected} $images(radio-unsel-pressed) \
|
||||
active $images(radio-unsel-hover) \
|
||||
] -width 20 -sticky w
|
||||
|
||||
# Scrollbar
|
||||
ttk::style element create Horizontal.Scrollbar.trough image $images(scroll-hor-trough) -sticky ew -border 6
|
||||
ttk::style element create Horizontal.Scrollbar.thumb image $images(scroll-hor-thumb) -sticky ew -border 3
|
||||
|
||||
ttk::style element create Horizontal.Scrollbar.rightarrow image $images(scroll-right) -sticky {} -width 12
|
||||
ttk::style element create Horizontal.Scrollbar.leftarrow image $images(scroll-left) -sticky {} -width 12
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.trough image $images(scroll-vert-trough) -sticky ns -border 6
|
||||
ttk::style element create Vertical.Scrollbar.thumb image $images(scroll-vert-thumb) -sticky ns -border 3
|
||||
|
||||
ttk::style element create Vertical.Scrollbar.uparrow image $images(scroll-up) -sticky {} -height 12
|
||||
ttk::style element create Vertical.Scrollbar.downarrow image $images(scroll-down) -sticky {} -height 12
|
||||
|
||||
# Scale
|
||||
ttk::style element create Horizontal.Scale.trough image $images(scale-trough-hor) \
|
||||
-border 5 -padding 0
|
||||
|
||||
ttk::style element create Vertical.Scale.trough image $images(scale-trough-vert) \
|
||||
-border 5 -padding 0
|
||||
|
||||
ttk::style element create Scale.slider \
|
||||
image [list $images(scale-thumb-rest) \
|
||||
disabled $images(scale-thumb-disabled) \
|
||||
pressed $images(scale-thumb-pressed) \
|
||||
active $images(scale-thumb-hover) \
|
||||
] -sticky {}
|
||||
|
||||
# Progressbar
|
||||
ttk::style element create Horizontal.Progressbar.trough image $images(progress-trough-hor) \
|
||||
-border 1 -sticky ew
|
||||
|
||||
ttk::style element create Horizontal.Progressbar.pbar image $images(progress-pbar-hor) \
|
||||
-border 2 -sticky ew
|
||||
|
||||
ttk::style element create Vertical.Progressbar.trough image $images(progress-trough-vert) \
|
||||
-border 1 -sticky ns
|
||||
|
||||
ttk::style element create Vertical.Progressbar.pbar image $images(progress-pbar-vert) \
|
||||
-border 2 -sticky ns
|
||||
|
||||
# Entry
|
||||
ttk::style configure TEntry -foreground $colors(-fg)
|
||||
|
||||
ttk::style map TEntry -foreground \
|
||||
[list disabled #757575 \
|
||||
pressed #cfcfcf
|
||||
]
|
||||
|
||||
ttk::style element create Entry.field \
|
||||
image [list $images(entry-rest) \
|
||||
{focus hover !invalid} $images(entry-focus) \
|
||||
invalid $images(entry-invalid) \
|
||||
disabled $images(entry-disabled) \
|
||||
{focus !invalid} $images(entry-focus) \
|
||||
hover $images(entry-hover) \
|
||||
] -border 5 -padding 8 -sticky nsew
|
||||
|
||||
# Combobox
|
||||
ttk::style configure TCombobox -foreground $colors(-fg)
|
||||
|
||||
ttk::style map TCombobox -foreground \
|
||||
[list disabled #757575 \
|
||||
pressed #cfcfcf
|
||||
]
|
||||
|
||||
ttk::style configure ComboboxPopdownFrame -borderwidth 0 -flat solid
|
||||
|
||||
ttk::style map TCombobox -selectbackground [list \
|
||||
{readonly hover} $colors(-selectbg) \
|
||||
{readonly focus} $colors(-selectbg) \
|
||||
] -selectforeground [list \
|
||||
{readonly hover} $colors(-selectfg) \
|
||||
{readonly focus} $colors(-selectfg) \
|
||||
]
|
||||
|
||||
ttk::style element create Combobox.field \
|
||||
image [list $images(entry-rest) \
|
||||
{readonly disabled} $images(button-disabled) \
|
||||
{readonly pressed} $images(button-pressed) \
|
||||
{readonly hover} $images(button-hover) \
|
||||
readonly $images(button-rest) \
|
||||
invalid $images(entry-invalid) \
|
||||
disabled $images(entry-disabled) \
|
||||
focus $images(entry-focus) \
|
||||
hover $images(entry-hover) \
|
||||
] -border 0 -padding {8 8 28 8}
|
||||
|
||||
ttk::style element create Combobox.arrow image $images(arrow-down) -width 35 -sticky {}
|
||||
|
||||
# Spinbox
|
||||
ttk::style configure TSpinbox -foreground $colors(-fg)
|
||||
|
||||
ttk::style map TSpinbox -foreground \
|
||||
[list disabled #757575 \
|
||||
pressed #cfcfcf
|
||||
]
|
||||
|
||||
ttk::style element create Spinbox.field \
|
||||
image [list $images(entry-rest) \
|
||||
invalid $images(entry-invalid) \
|
||||
disabled $images(entry-disabled) \
|
||||
focus $images(entry-focus) \
|
||||
hover $images(entry-hover) \
|
||||
] -border 5 -padding {8 8 54 8} -sticky nsew
|
||||
|
||||
ttk::style element create Spinbox.uparrow image $images(arrow-up) -width 35 -sticky {}
|
||||
ttk::style element create Spinbox.downarrow image $images(arrow-down) -width 35 -sticky {}
|
||||
|
||||
# Sizegrip
|
||||
ttk::style element create Sizegrip.sizegrip image $images(sizegrip) \
|
||||
-sticky nsew
|
||||
|
||||
# Separator
|
||||
ttk::style element create TSeparator.separator image $images(separator)
|
||||
|
||||
# Card
|
||||
ttk::style element create Card.field image $images(card) \
|
||||
-border 10 -padding 4 -sticky nsew
|
||||
|
||||
# Labelframe
|
||||
ttk::style element create Labelframe.border image $images(card) \
|
||||
-border 5 -padding 4 -sticky nsew
|
||||
|
||||
# Notebook
|
||||
ttk::style configure TNotebook -padding 1
|
||||
|
||||
ttk::style element create Notebook.border \
|
||||
image $images(notebook-border) -border 5 -padding 5
|
||||
|
||||
ttk::style element create Notebook.client image $images(notebook)
|
||||
|
||||
ttk::style element create Notebook.tab \
|
||||
image [list $images(tab-rest) \
|
||||
selected $images(tab-selected) \
|
||||
active $images(tab-hover) \
|
||||
] -border 13 -padding {16 14 16 6} -height 32
|
||||
|
||||
# Treeview
|
||||
ttk::style element create Treeview.field image $images(card) \
|
||||
-border 5
|
||||
|
||||
ttk::style element create Treeheading.cell \
|
||||
image [list $images(treeheading-rest) \
|
||||
pressed $images(treeheading-pressed) \
|
||||
active $images(treeheading-hover)
|
||||
] -border 5 -padding 15 -sticky nsew
|
||||
|
||||
ttk::style element create Treeitem.indicator \
|
||||
image [list $images(arrow-right) \
|
||||
user2 $images(empty) \
|
||||
user1 $images(arrow-down) \
|
||||
] -width 26 -sticky {}
|
||||
|
||||
ttk::style configure Treeview -background $colors(-bg) -rowheight [expr {[font metrics font -linespace] + 2}]
|
||||
ttk::style map Treeview \
|
||||
-background [list selected #292929] \
|
||||
-foreground [list selected $colors(-selectfg)]
|
||||
|
||||
# Panedwindow
|
||||
# Insane hack to remove clam's ugly sash
|
||||
ttk::style configure Sash -gripcount 0
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 373 B |
Before Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 377 B |
Before Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 274 B |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 363 B |