Merge pull request #49 from Anjok07/revert-48-feature-resolutionType

Revert "Feature resolution type"
This commit is contained in:
Dilan Boskan 2021-01-15 10:23:26 +01:00 committed by GitHub
commit 14b5f7fd61
8 changed files with 37 additions and 91 deletions

3
.gitignore vendored
View File

@ -3,5 +3,4 @@ data.pkl
# Testing models
model_iter26_sr33075_hl384_w512.pth
baseline.pth
temp.wav
models/**/*.pth
temp.wav

View File

@ -61,8 +61,6 @@ DEFAULT_DATA = {
'modelInstrumentalLabel': '',
'modelStackedLabel': '',
'aiModel': 'v4',
'resType': 'Kaiser Fast',
'manType': False,
'useModel': 'instrumental',
'lastDir': None,
@ -242,15 +240,15 @@ class MainWindow(TkinterDnD.Tk):
# Layout
IMAGE_HEIGHT = 140
FILEPATHS_HEIGHT = 90
OPTIONS_HEIGHT = 285
OPTIONS_HEIGHT = 240
CONVERSIONBUTTON_HEIGHT = 35
COMMAND_HEIGHT = 200
PROGRESS_HEIGHT = 26
PADDING = 10
COL1_ROWS = 9.5
COL2_ROWS = 8.1
COL3_ROWS = 5.5
COL1_ROWS = 8
COL2_ROWS = 7
COL3_ROWS = 5
def __init__(self):
# Run the __init__ method on the tk.Tk class
@ -307,10 +305,8 @@ class MainWindow(TkinterDnD.Tk):
self.hopValue_var = tk.StringVar(value=data['hop_length'])
self.winSize_var = tk.StringVar(value=data['window_size'])
self.nfft_var = tk.StringVar(value=data['n_fft'])
self.manType_var = tk.BooleanVar(value=data['manType'])
# AI model
self.aiModel_var = tk.StringVar(value=data['aiModel'])
self.resType_var = tk.StringVar(value=data['resType'])
self.last_aiModel = self.aiModel_var.get()
# Other
self.inputPathsEntry_var = tk.StringVar(value='')
@ -402,6 +398,7 @@ class MainWindow(TkinterDnD.Tk):
text='Save to',
command=self.open_export_filedialog)
self.filePaths_saveTo_Entry = ttk.Entry(master=self.filePaths_Frame,
textvariable=self.exportPath_var,
state=tk.DISABLED
)
@ -470,11 +467,6 @@ class MainWindow(TkinterDnD.Tk):
text='Model Test Mode',
variable=self.modelFolder_var,
)
# Manual Constants
self.options_manType_Checkbutton = ttk.Checkbutton(master=self.options_Frame,
text='Custom parameters',
variable=self.manType_var,
)
# -Column 2-
# SR
self.options_sr_Entry = ttk.Entry(master=self.options_Frame,
@ -500,13 +492,6 @@ class MainWindow(TkinterDnD.Tk):
self.options_nfft_Label = tk.Label(master=self.options_Frame,
text='N_FFT', anchor=tk.W,
background='#63605f', font=self.font, foreground='white', relief="sunken")
# Resolution Type
self.options_resType_Label = tk.Label(master=self.options_Frame,
text='Resolution Type', anchor=tk.CENTER,
background='#63605f', font=self.font, foreground='white', relief="sunken")
self.options_resType_Optionmenu = ttk.OptionMenu(self.options_Frame,
self.resType_var,
None, 'Kaiser Fast', 'Kaiser Best', 'Scipy')
# AI model
self.options_aiModel_Label = tk.Label(master=self.options_Frame,
text='Choose AI Engine', anchor=tk.CENTER,
@ -557,9 +542,6 @@ class MainWindow(TkinterDnD.Tk):
# Model Folder
self.options_modelFolder_Checkbutton.place(x=0, y=0, width=0, height=0,
relx=0, rely=7/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
# Manual Constants
self.options_manType_Checkbutton.place(x=0, y=0, width=0, height=0,
relx=0, rely=8/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
# -Column 2-
# SR
self.options_sr_Label.place(x=5, y=4, width=5, height=-8,
@ -581,16 +563,11 @@ class MainWindow(TkinterDnD.Tk):
relx=1/3, rely=3/self.COL2_ROWS, relwidth=1/3/2, relheight=1/self.COL2_ROWS)
self.options_nfft_Entry.place(x=15, y=4, width=5, height=-8,
relx=1/3 + 1/3/2, rely=3/self.COL2_ROWS, relwidth=1/3/4, relheight=1/self.COL2_ROWS)
# Resolution Type
self.options_resType_Label.place(x=5, y=8, width=-30, height=-8,
relx=1/3, rely=4/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
self.options_resType_Optionmenu.place(x=5, y=8, width=-30, height=-8,
relx=1/3, rely=5/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
# AI model
self.options_aiModel_Label.place(x=5, y=8, width=-30, height=-8,
relx=1/3, rely=6/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
self.options_aiModel_Optionmenu.place(x=5, y=8, width=-30, height=-8,
relx=1/3, rely=7/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
self.options_aiModel_Label.place(x=5, y=-5, width=-30, height=-8,
relx=1/3, rely=5/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
self.options_aiModel_Optionmenu.place(x=5, y=-5, width=-30, height=-8,
relx=1/3, rely=6/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
# -Column 3-
# Choose Model
@ -615,8 +592,6 @@ class MainWindow(TkinterDnD.Tk):
lambda *args: self.decode_modelNames())
self.stackedModel_var.trace_add('write',
lambda *args: self.decode_modelNames())
self.manType_var.trace_add('write',
lambda *args: self.decode_modelNames())
# Model deselect
self.aiModel_var.trace_add('write',
lambda *args: self.deselect_models())
@ -666,13 +641,11 @@ class MainWindow(TkinterDnD.Tk):
input_paths = self.inputPaths
instrumentalModel_path = self.instrumentalLabel_to_path[self.instrumentalModel_var.get()] # nopep8
stackedModel_path = self.stackedLabel_to_path[self.stackedModel_var.get()] # nopep8
resType = self.resType_var.get().lower().replace(' ', '_')
# Get constants
instrumental = get_model_values(self.instrumentalModel_var.get())
stacked = get_model_values(self.stackedModel_var.get())
try:
if ([bool(instrumental), bool(stacked)].count(True) == 2 and
not self.manType_var.get()):
if [bool(instrumental), bool(stacked)].count(True) == 2:
sr = DEFAULT_DATA['sr']
hop_length = DEFAULT_DATA['hop_length']
window_size = DEFAULT_DATA['window_size']
@ -755,10 +728,6 @@ class MainWindow(TkinterDnD.Tk):
'hop_length': hop_length,
'window_size': window_size,
'n_fft': n_fft, # not needed for v2
# Resolution Type
'resType': resType,
# Parsed constants should be fixed
'manType': self.manType_var.get(),
# Other Variables (Tkinter)
'window': self,
'text_widget': self.command_Text,
@ -791,14 +760,7 @@ class MainWindow(TkinterDnD.Tk):
# Loop through each constant (key) and its widgets
for key, (widget, var) in widgetsVars.items():
if self.manType_var.get():
if str(widget.cget('state')) != 'normal':
# Manual typing and widget not enabled
widget.configure(state=tk.NORMAL)
if '/' in str(var.get()):
var.set(var.get().split('/')[0])
continue
elif stacked_selectable:
if stacked_selectable:
if instrumental_selectable:
if (key in instrumental.keys() and
key in stacked.keys()):
@ -806,17 +768,19 @@ class MainWindow(TkinterDnD.Tk):
widget.configure(state=tk.DISABLED)
var.set('%d/%d' % (instrumental[key], stacked[key]))
continue
elif key in stacked.keys():
# Only stacked selectable
widget.configure(state=tk.DISABLED)
var.set(stacked[key])
continue
elif (key in instrumental.keys() and
instrumental_selectable):
else:
if key in stacked.keys():
# Only stacked selectable
widget.configure(state=tk.DISABLED)
var.set(stacked[key])
continue
else:
# Stacked model can not be selected
widget.configure(state=tk.DISABLED)
var.set(instrumental[key])
continue
if (key in instrumental.keys() and
instrumental_selectable):
widget.configure(state=tk.DISABLED)
var.set(instrumental[key])
continue
# If widget is already enabled, no need to reset the value
if str(widget.cget('state')) != 'normal':
@ -979,8 +943,7 @@ class MainWindow(TkinterDnD.Tk):
# Get constants
instrumental = get_model_values(self.instrumentalModel_var.get())
stacked = get_model_values(self.stackedModel_var.get())
if ([bool(instrumental), bool(stacked)].count(True) == 2 and
not self.manType_var.get()):
if [bool(instrumental), bool(stacked)].count(True) == 2:
sr = DEFAULT_DATA['sr']
hop_length = DEFAULT_DATA['hop_length']
window_size = DEFAULT_DATA['window_size']
@ -1013,8 +976,6 @@ class MainWindow(TkinterDnD.Tk):
'modelInstrumentalLabel': self.instrumentalModel_var.get(),
'modelStackedLabel': self.stackedModel_var.get(),
'aiModel': self.aiModel_var.get(),
'resType': self.resType_var.get(),
'manType': self.manType_var.get(),
})
self.destroy()

View File

@ -53,10 +53,6 @@ data = {
'hop_length': 1_024,
'window_size': 320,
'n_fft': 2_048,
# Resolution Type
'resType': 'kaiser_fast',
# Parsed constants should be fixed
'manType': False,
}
default_sr = data['sr']
default_hop_length = data['hop_length']
@ -96,10 +92,6 @@ def update_constants(model_name):
data['window_size'] = default_window_size
data['n_fft'] = default_n_fft
if data['manType']:
# Default constants should be fixed
return
for text_part in text_parts:
if 'sr' in text_part:
text_part = text_part.replace('sr', '')
@ -214,7 +206,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
data['sr'],
False,
dtype=np.float32,
res_type=data['resType'])
res_type='kaiser_fast')
return X, sr
@ -377,8 +369,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
folder_path = os.path.join(data["export_path"], modelFolderName)
if not os.path.isdir(folder_path):
os.mkdir(folder_path)
else:
folder_path = ''
# Determine Loops
total_loops = data['stackPasses']
@ -386,9 +376,10 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
total_loops += 1
for file_num, music_file in enumerate(data['input_paths'], start=1):
# Determine File Name
base_name = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
try:
# Determine File Name
base_name = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
for loop_num in range(total_loops):
# -Determine which model will be used-
if not loop_num:

View File

@ -175,10 +175,6 @@ data = {
'hop_length': 1_024,
'window_size': 320,
'n_fft': 2_048,
# Resolution Type
'resType': 'kaiser_fast',
# Parsed constants should be fixed
'manType': False,
}
default_sr = data['sr']
default_hop_length = data['hop_length']
@ -216,10 +212,6 @@ def update_constants(model_name):
data['window_size'] = default_window_size
data['n_fft'] = default_n_fft
if data['manType']:
# Default constants should be fixed
return
for text_part in text_parts:
if 'sr' in text_part:
text_part = text_part.replace('sr', '')
@ -384,17 +376,16 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
folder_path = os.path.join(data["export_path"], modelFolderName)
if not os.path.isdir(folder_path):
os.mkdir(folder_path)
else:
folder_path = ''
# Determine Loops
total_loops = data['stackPasses']
if not data['stackOnly']:
total_loops += 1
for file_num, music_file in enumerate(data['input_paths'], start=1):
# Determine File Name
base_name = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
try:
# Determine File Name
base_name = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
# --Seperate Music Files--
for loop_num in range(total_loops):
# -Determine which model will be used-
@ -437,7 +428,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
# Wave source
text_widget.write(base_text + 'Loading wave source...\n')
X, sr = librosa.load(music_file, data['sr'], False,
dtype=np.float32, res_type=data['resType'])
dtype=np.float32, res_type='kaiser_fast')
if X.ndim == 1:
X = np.asarray([X, X])
text_widget.write(base_text + 'Done!\n')

View File

@ -0,0 +1 @@
Models Go Here

View File

@ -0,0 +1 @@
Models Go Here

View File

@ -0,0 +1 @@
Models Go Here

View File

@ -0,0 +1 @@
Models Go Here