mirror of
https://github.com/Anjok07/ultimatevocalremovergui.git
synced 2024-11-28 09:21:03 +01:00
Add files via upload
This commit is contained in:
parent
159e14463d
commit
a6fef6c6e9
@ -41,6 +41,7 @@ if getattr(sys, 'frozen', False):
|
|||||||
base_path = sys._MEIPASS
|
base_path = sys._MEIPASS
|
||||||
else:
|
else:
|
||||||
base_path = os.path.dirname(os.path.abspath(__file__))
|
base_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
os.chdir(base_path) # Change the current working directory to the base path
|
os.chdir(base_path) # Change the current working directory to the base path
|
||||||
|
|
||||||
instrumentalModels_dir = os.path.join(base_path, 'models')
|
instrumentalModels_dir = os.path.join(base_path, 'models')
|
||||||
@ -64,7 +65,6 @@ DEFAULT_DATA = {
|
|||||||
'lastDir': None,
|
'lastDir': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def open_image(path: str, size: tuple = None, keep_aspect: bool = True, rotate: int = 0) -> ImageTk.PhotoImage:
|
def open_image(path: str, size: tuple = None, keep_aspect: bool = True, rotate: int = 0) -> ImageTk.PhotoImage:
|
||||||
"""
|
"""
|
||||||
Open the image on the path and apply given settings\n
|
Open the image on the path and apply given settings\n
|
||||||
@ -94,7 +94,6 @@ def open_image(path: str, size: tuple = None, keep_aspect: bool = True, rotate:
|
|||||||
img = img.resize(size, Image.ANTIALIAS)
|
img = img.resize(size, Image.ANTIALIAS)
|
||||||
return ImageTk.PhotoImage(img)
|
return ImageTk.PhotoImage(img)
|
||||||
|
|
||||||
|
|
||||||
def save_data(data):
|
def save_data(data):
|
||||||
"""
|
"""
|
||||||
Saves given data as a .pkl (pickle) file
|
Saves given data as a .pkl (pickle) file
|
||||||
@ -107,7 +106,6 @@ def save_data(data):
|
|||||||
with open('data.pkl', 'wb') as data_file:
|
with open('data.pkl', 'wb') as data_file:
|
||||||
pickle.dump(data, data_file)
|
pickle.dump(data, data_file)
|
||||||
|
|
||||||
|
|
||||||
def load_data() -> dict:
|
def load_data() -> dict:
|
||||||
"""
|
"""
|
||||||
Loads saved pkl file and returns the stored data
|
Loads saved pkl file and returns the stored data
|
||||||
@ -126,7 +124,6 @@ def load_data() -> dict:
|
|||||||
|
|
||||||
return load_data()
|
return load_data()
|
||||||
|
|
||||||
|
|
||||||
def drop(event, accept_mode: str = 'files'):
|
def drop(event, accept_mode: str = 'files'):
|
||||||
"""
|
"""
|
||||||
Drag & Drop verification process
|
Drag & Drop verification process
|
||||||
@ -153,12 +150,10 @@ def drop(event, accept_mode: str = 'files'):
|
|||||||
# Invalid accept mode
|
# Invalid accept mode
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ThreadSafeConsole(tk.Text):
|
class ThreadSafeConsole(tk.Text):
|
||||||
"""
|
"""
|
||||||
Text Widget which is thread safe for tkinter
|
Text Widget which is thread safe for tkinter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, master, **options):
|
def __init__(self, master, **options):
|
||||||
tk.Text.__init__(self, master, **options)
|
tk.Text.__init__(self, master, **options)
|
||||||
self.queue = queue.Queue()
|
self.queue = queue.Queue()
|
||||||
@ -186,7 +181,6 @@ class ThreadSafeConsole(tk.Text):
|
|||||||
self.configure(state=tk.DISABLED)
|
self.configure(state=tk.DISABLED)
|
||||||
self.after(100, self.update_me)
|
self.after(100, self.update_me)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(TkinterDnD.Tk):
|
class MainWindow(TkinterDnD.Tk):
|
||||||
# --Constants--
|
# --Constants--
|
||||||
# Layout
|
# Layout
|
||||||
@ -248,9 +242,10 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
# Constants
|
# Constants
|
||||||
self.winSize_var = tk.StringVar(value=data['window_size'])
|
self.winSize_var = tk.StringVar(value=data['window_size'])
|
||||||
self.agg_var = tk.StringVar(value=data['agg'])
|
self.agg_var = tk.StringVar(value=data['agg'])
|
||||||
# AI model
|
# Choose Conversion Method
|
||||||
self.aiModel_var = tk.StringVar(value=data['aiModel'])
|
self.aiModel_var = tk.StringVar(value=data['aiModel'])
|
||||||
self.last_aiModel = self.aiModel_var.get()
|
self.last_aiModel = self.aiModel_var.get()
|
||||||
|
# Choose Ensemble
|
||||||
self.ensChoose_var = tk.StringVar(value=data['ensChoose'])
|
self.ensChoose_var = tk.StringVar(value=data['ensChoose'])
|
||||||
self.last_ensChoose = self.ensChoose_var.get()
|
self.last_ensChoose = self.ensChoose_var.get()
|
||||||
# Other
|
# Other
|
||||||
@ -264,7 +259,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
self.configure_widgets()
|
self.configure_widgets()
|
||||||
self.bind_widgets()
|
self.bind_widgets()
|
||||||
self.place_widgets()
|
self.place_widgets()
|
||||||
|
|
||||||
self.update_available_models()
|
self.update_available_models()
|
||||||
self.update_states()
|
self.update_states()
|
||||||
self.update_loop()
|
self.update_loop()
|
||||||
@ -403,6 +397,22 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
variable=self.modelFolder_var,
|
variable=self.modelFolder_var,
|
||||||
)
|
)
|
||||||
# -Column 2-
|
# -Column 2-
|
||||||
|
|
||||||
|
# Choose Conversion Method
|
||||||
|
self.options_aiModel_Label = tk.Label(master=self.options_Frame,
|
||||||
|
text='Choose Conversion Method', anchor=tk.CENTER,
|
||||||
|
background='#404040', font=self.font, foreground='white', relief="groove")
|
||||||
|
self.options_aiModel_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
||||||
|
self.aiModel_var,
|
||||||
|
None, 'Single Model', 'Ensemble Mode')
|
||||||
|
# Ensemble Mode
|
||||||
|
self.options_ensChoose_Label = tk.Label(master=self.options_Frame,
|
||||||
|
text='Choose Ensemble', anchor=tk.CENTER,
|
||||||
|
background='#404040', font=self.font, foreground='white', relief="groove")
|
||||||
|
self.options_ensChoose_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
||||||
|
self.ensChoose_var,
|
||||||
|
None, 'HP1 Models', 'HP2 Models', 'All HP Models', 'Vocal Models')
|
||||||
|
# -Column 3-
|
||||||
|
|
||||||
# WINDOW SIZE
|
# WINDOW SIZE
|
||||||
self.options_winSize_Label = tk.Label(master=self.options_Frame,
|
self.options_winSize_Label = tk.Label(master=self.options_Frame,
|
||||||
@ -418,23 +428,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
self.options_agg_Label = tk.Label(master=self.options_Frame,
|
self.options_agg_Label = tk.Label(master=self.options_Frame,
|
||||||
text='Aggression Setting',
|
text='Aggression Setting',
|
||||||
background='#404040', font=self.font, foreground='white', relief="groove")
|
background='#404040', font=self.font, foreground='white', relief="groove")
|
||||||
|
|
||||||
# AI model
|
|
||||||
self.options_aiModel_Label = tk.Label(master=self.options_Frame,
|
|
||||||
text='Choose Conversion Method', anchor=tk.CENTER,
|
|
||||||
background='#404040', font=self.font, foreground='white', relief="groove")
|
|
||||||
self.options_aiModel_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
|
||||||
self.aiModel_var,
|
|
||||||
None, 'Single Model', 'Ensemble Mode')
|
|
||||||
# Ensemble Mode
|
|
||||||
self.options_ensChoose_Label = tk.Label(master=self.options_Frame,
|
|
||||||
text='Choose Ensemble', anchor=tk.CENTER,
|
|
||||||
background='#404040', font=self.font, foreground='white', relief="groove")
|
|
||||||
self.options_ensChoose_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
|
||||||
self.ensChoose_var,
|
|
||||||
None, 'HP1 Models', 'HP2 Models', 'All HP Models', 'Vocal Models')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# "Save to", "Select Your Audio File(s)"", and "Start Conversion" Button Style
|
# "Save to", "Select Your Audio File(s)"", and "Start Conversion" Button Style
|
||||||
s = ttk.Style()
|
s = ttk.Style()
|
||||||
@ -448,12 +441,8 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
self.options_instrumentalModel_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
self.options_instrumentalModel_Optionmenu = ttk.OptionMenu(self.options_Frame,
|
||||||
self.instrumentalModel_var)
|
self.instrumentalModel_var)
|
||||||
|
|
||||||
# Add Open Export Directory Button
|
|
||||||
# self.options_export_Button = ttk.Button(master=self.options_Frame,
|
|
||||||
# text='Open Export Directory',
|
|
||||||
# style="Bold.TButton",
|
|
||||||
# command=self.open_newModel_filedialog)
|
|
||||||
# -Place Widgets-
|
# -Place Widgets-
|
||||||
|
|
||||||
# -Column 1-
|
# -Column 1-
|
||||||
self.options_gpu_Checkbutton.place(x=0, y=0, width=0, height=0,
|
self.options_gpu_Checkbutton.place(x=0, y=0, width=0, height=0,
|
||||||
relx=0, rely=0, relwidth=1/3, relheight=1/self.COL1_ROWS)
|
relx=0, rely=0, relwidth=1/3, relheight=1/self.COL1_ROWS)
|
||||||
@ -469,8 +458,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
relx=0, rely=4/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
|
relx=0, rely=4/self.COL1_ROWS, relwidth=1/3, relheight=1/self.COL1_ROWS)
|
||||||
|
|
||||||
# -Column 2-
|
# -Column 2-
|
||||||
|
|
||||||
|
|
||||||
self.options_instrumentalModel_Label.place(x=-15, y=6, width=0, height=-10,
|
self.options_instrumentalModel_Label.place(x=-15, y=6, width=0, height=-10,
|
||||||
relx=1/3, rely=2/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
relx=1/3, rely=2/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
||||||
self.options_instrumentalModel_Optionmenu.place(x=-15, y=6, width=0, height=-10,
|
self.options_instrumentalModel_Optionmenu.place(x=-15, y=6, width=0, height=-10,
|
||||||
@ -481,14 +468,15 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
relx=1/3, rely=0/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
relx=1/3, rely=0/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
||||||
self.options_ensChoose_Optionmenu.place(x=-15, y=6, width=0, height=-10,
|
self.options_ensChoose_Optionmenu.place(x=-15, y=6, width=0, height=-10,
|
||||||
relx=1/3, rely=1/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
relx=1/3, rely=1/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
||||||
|
|
||||||
|
# Conversion Method
|
||||||
|
self.options_aiModel_Label.place(x=-15, y=6, width=0, height=-10,
|
||||||
# self.options_export_Button.place(x=0, y=0, width=-30, height=-8,
|
relx=1/3, rely=0/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
||||||
# relx=2/3, rely=4/self.COL3_ROWS, relwidth=1/3, relheight=1/self.COL3_ROWS)
|
self.options_aiModel_Optionmenu.place(x=-15, y=4, width=0, height=-10,
|
||||||
|
relx=1/3, rely=1/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
||||||
|
|
||||||
# -Column 3-
|
# -Column 3-
|
||||||
|
|
||||||
# WINDOW
|
# WINDOW
|
||||||
self.options_winSize_Label.place(x=35, y=6, width=-40, height=-10,
|
self.options_winSize_Label.place(x=35, y=6, width=-40, height=-10,
|
||||||
relx=2/3, rely=0, relwidth=1/3, relheight=1/self.COL3_ROWS)
|
relx=2/3, rely=0, relwidth=1/3, relheight=1/self.COL3_ROWS)
|
||||||
@ -501,15 +489,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
self.options_agg_Entry.place(x=80, y=6, width=-133, height=-10,
|
self.options_agg_Entry.place(x=80, y=6, width=-133, height=-10,
|
||||||
relx=2/3, rely=3/self.COL3_ROWS, relwidth=1/3, relheight=1/self.COL3_ROWS)
|
relx=2/3, rely=3/self.COL3_ROWS, relwidth=1/3, relheight=1/self.COL3_ROWS)
|
||||||
|
|
||||||
|
|
||||||
# Conversion Method
|
|
||||||
self.options_aiModel_Label.place(x=-15, y=6, width=0, height=-10,
|
|
||||||
relx=1/3, rely=0/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
|
||||||
self.options_aiModel_Optionmenu.place(x=-15, y=4, width=0, height=-10,
|
|
||||||
relx=1/3, rely=1/self.COL2_ROWS, relwidth=1/3, relheight=1/self.COL2_ROWS)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Model deselect
|
# Model deselect
|
||||||
self.aiModel_var.trace_add('write',
|
self.aiModel_var.trace_add('write',
|
||||||
lambda *args: self.deselect_models())
|
lambda *args: self.deselect_models())
|
||||||
@ -640,7 +619,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
).start()
|
).start()
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
|
|
||||||
def update_inputPaths(self):
|
def update_inputPaths(self):
|
||||||
"""Update the music file entry"""
|
"""Update the music file entry"""
|
||||||
if self.inputPaths:
|
if self.inputPaths:
|
||||||
@ -665,7 +643,7 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
#temp_instrumentalModels_dir = os.path.join(instrumentalModels_dir, self.aiModel_var.get(), 'Main Models') # nopep8
|
#temp_instrumentalModels_dir = os.path.join(instrumentalModels_dir, self.aiModel_var.get(), 'Main Models') # nopep8
|
||||||
temp_instrumentalModels_dir = os.path.join(instrumentalModels_dir, 'Main Models') # nopep8
|
temp_instrumentalModels_dir = os.path.join(instrumentalModels_dir, 'Main Models') # nopep8
|
||||||
|
|
||||||
# Instrumental models
|
# Main models
|
||||||
new_InstrumentalModels = os.listdir(temp_instrumentalModels_dir)
|
new_InstrumentalModels = os.listdir(temp_instrumentalModels_dir)
|
||||||
if new_InstrumentalModels != self.lastInstrumentalModels:
|
if new_InstrumentalModels != self.lastInstrumentalModels:
|
||||||
self.instrumentalLabel_to_path.clear()
|
self.instrumentalLabel_to_path.clear()
|
||||||
@ -679,13 +657,11 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
self.instrumentalLabel_to_path[file_name] = os.path.join(temp_instrumentalModels_dir, file_name) # nopep8
|
self.instrumentalLabel_to_path[file_name] = os.path.join(temp_instrumentalModels_dir, file_name) # nopep8
|
||||||
self.lastInstrumentalModels = new_InstrumentalModels
|
self.lastInstrumentalModels = new_InstrumentalModels
|
||||||
|
|
||||||
|
|
||||||
def update_states(self):
|
def update_states(self):
|
||||||
"""
|
"""
|
||||||
Vary the states for all widgets based
|
Vary the states for all widgets based
|
||||||
on certain selections
|
on certain selections
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.aiModel_var.get() == 'Single Model':
|
if self.aiModel_var.get() == 'Single Model':
|
||||||
self.options_ensChoose_Label.place_forget()
|
self.options_ensChoose_Label.place_forget()
|
||||||
self.options_ensChoose_Optionmenu.place_forget()
|
self.options_ensChoose_Optionmenu.place_forget()
|
||||||
@ -804,7 +780,6 @@ class MainWindow(TkinterDnD.Tk):
|
|||||||
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
root = MainWindow()
|
root = MainWindow()
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ class VocalRemover(object):
|
|||||||
self.devices = defaultdict(lambda: None)
|
self.devices = defaultdict(lambda: None)
|
||||||
# self.offset = model.offset
|
# self.offset = model.offset
|
||||||
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
# Paths
|
# Paths
|
||||||
'input_paths': None,
|
'input_paths': None,
|
||||||
@ -61,14 +60,12 @@ def update_progress(progress_var, total_files, file_num, step: float = 1):
|
|||||||
|
|
||||||
progress_var.set(progress)
|
progress_var.set(progress)
|
||||||
|
|
||||||
|
|
||||||
def get_baseText(total_files, file_num):
|
def get_baseText(total_files, file_num):
|
||||||
"""Create the base text for the command widget"""
|
"""Create the base text for the command widget"""
|
||||||
text = 'File {file_num}/{total_files} '.format(file_num=file_num,
|
text = 'File {file_num}/{total_files} '.format(file_num=file_num,
|
||||||
total_files=total_files)
|
total_files=total_files)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def determineModelFolderName():
|
def determineModelFolderName():
|
||||||
"""
|
"""
|
||||||
Determine the name that is used for the folder and appended
|
Determine the name that is used for the folder and appended
|
||||||
@ -109,8 +106,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
p.add_argument('--nn_architecture', type=str, choices= ['auto'] + list('{}KB'.format(s) for s in nn_arch_sizes), default='auto')
|
p.add_argument('--nn_architecture', type=str, choices= ['auto'] + list('{}KB'.format(s) for s in nn_arch_sizes), default='auto')
|
||||||
p.add_argument('--high_end_process', type=str, default='mirroring')
|
p.add_argument('--high_end_process', type=str, default='mirroring')
|
||||||
args = p.parse_args()
|
args = p.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def save_files(wav_instrument, wav_vocals):
|
def save_files(wav_instrument, wav_vocals):
|
||||||
"""Save output music files"""
|
"""Save output music files"""
|
||||||
vocal_name = '(Vocals)'
|
vocal_name = '(Vocals)'
|
||||||
@ -133,6 +129,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
wav_instrument, mp.param['sr'])
|
wav_instrument, mp.param['sr'])
|
||||||
|
|
||||||
appendModelFolderName = modelFolderName.replace('/', '_')
|
appendModelFolderName = modelFolderName.replace('/', '_')
|
||||||
|
|
||||||
# -Save files-
|
# -Save files-
|
||||||
# Instrumental
|
# Instrumental
|
||||||
if instrumental_name is not None:
|
if instrumental_name is not None:
|
||||||
@ -173,7 +170,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
os.mkdir(folder_path)
|
os.mkdir(folder_path)
|
||||||
|
|
||||||
# Separation Preperation
|
# Separation Preperation
|
||||||
try: #Load File(s)
|
try: #Load File(s)
|
||||||
for file_num, music_file in enumerate(data['input_paths'], start=1):
|
for file_num, music_file in enumerate(data['input_paths'], start=1):
|
||||||
# Determine File Name
|
# Determine File Name
|
||||||
base_name = f'{data["export_path"]}{modelFolderName}/{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}'
|
base_name = f'{data["export_path"]}{modelFolderName}/{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}'
|
||||||
@ -190,8 +187,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=0)
|
step=0)
|
||||||
|
|
||||||
|
#Load Model
|
||||||
#Load Model(s)
|
|
||||||
text_widget.write(base_text + 'Loading models...')
|
text_widget.write(base_text + 'Loading models...')
|
||||||
|
|
||||||
|
|
||||||
@ -354,10 +350,8 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
else:
|
else:
|
||||||
return pred * coef, X_mag, np.exp(1.j * X_phase)
|
return pred * coef, X_mag, np.exp(1.j * X_phase)
|
||||||
|
|
||||||
|
|
||||||
aggressiveness = {'value': args.aggressiveness, 'split_bin': mp.param['band'][1]['crop_stop']}
|
aggressiveness = {'value': args.aggressiveness, 'split_bin': mp.param['band'][1]['crop_stop']}
|
||||||
|
|
||||||
|
|
||||||
if data['tta']:
|
if data['tta']:
|
||||||
text_widget.write(base_text + "Running Inferences (TTA)...\n")
|
text_widget.write(base_text + "Running Inferences (TTA)...\n")
|
||||||
else:
|
else:
|
||||||
@ -402,6 +396,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=1)
|
step=1)
|
||||||
|
|
||||||
# Save output music files
|
# Save output music files
|
||||||
text_widget.write(base_text + 'Saving Files...')
|
text_widget.write(base_text + 'Saving Files...')
|
||||||
save_files(wav_instrument, wav_vocals)
|
save_files(wav_instrument, wav_vocals)
|
||||||
|
@ -28,7 +28,6 @@ class VocalRemover(object):
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.text_widget = text_widget
|
self.text_widget = text_widget
|
||||||
# self.offset = model.offset
|
# self.offset = model.offset
|
||||||
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
# Paths
|
# Paths
|
||||||
@ -60,7 +59,6 @@ def update_progress(progress_var, total_files, file_num, step: float = 1):
|
|||||||
|
|
||||||
progress_var.set(progress)
|
progress_var.set(progress)
|
||||||
|
|
||||||
|
|
||||||
def get_baseText(total_files, file_num):
|
def get_baseText(total_files, file_num):
|
||||||
"""Create the base text for the command widget"""
|
"""Create the base text for the command widget"""
|
||||||
text = 'File {file_num}/{total_files} '.format(file_num=file_num,
|
text = 'File {file_num}/{total_files} '.format(file_num=file_num,
|
||||||
@ -77,7 +75,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
31191, # default
|
31191, # default
|
||||||
33966, 123821, 123812, 537238 # custom
|
33966, 123821, 123812, 537238 # custom
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
p = argparse.ArgumentParser()
|
p = argparse.ArgumentParser()
|
||||||
p.add_argument('--aggressiveness',type=float, default=data['agg']/100)
|
p.add_argument('--aggressiveness',type=float, default=data['agg']/100)
|
||||||
@ -139,9 +136,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
button_widget.configure(state=tk.DISABLED) # Disable Button
|
button_widget.configure(state=tk.DISABLED) # Disable Button
|
||||||
|
|
||||||
# Separation Preperation
|
# Separation Preperation
|
||||||
try: #Load File(s)
|
try: #Ensemble Dictionary
|
||||||
|
|
||||||
|
|
||||||
HP1_Models = [
|
HP1_Models = [
|
||||||
{
|
{
|
||||||
'model_name':'HP_4BAND_44100_A',
|
'model_name':'HP_4BAND_44100_A',
|
||||||
@ -166,7 +161,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
'model_location':'models/Main Models/HP2_4BAND_44100_1.pth',
|
'model_location':'models/Main Models/HP2_4BAND_44100_1.pth',
|
||||||
'using_archtecture': '537238KB',
|
'using_archtecture': '537238KB',
|
||||||
'loop_name': 'Ensemble Mode - Model 1/3'
|
'loop_name': 'Ensemble Mode - Model 1/3'
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'model_name':'HP2_4BAND_44100_2',
|
'model_name':'HP2_4BAND_44100_2',
|
||||||
@ -174,7 +168,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
'model_location':'models/Main Models/HP2_4BAND_44100_2.pth',
|
'model_location':'models/Main Models/HP2_4BAND_44100_2.pth',
|
||||||
'using_archtecture': '537238KB',
|
'using_archtecture': '537238KB',
|
||||||
'loop_name': 'Ensemble Mode - Model 2/3'
|
'loop_name': 'Ensemble Mode - Model 2/3'
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'model_name':'HP2_3BAND_44100_MSB2',
|
'model_name':'HP2_3BAND_44100_MSB2',
|
||||||
@ -225,7 +218,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
Vocal_Models = [
|
Vocal_Models = [
|
||||||
{
|
{
|
||||||
'model_name':'HP_Vocal_4BAND_44100',
|
'model_name':'HP_Vocal_4BAND_44100',
|
||||||
@ -260,11 +252,8 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
ensefolder = 'Vocal_Models_Saved_Outputs'
|
ensefolder = 'Vocal_Models_Saved_Outputs'
|
||||||
ensemode = 'Vocal_Models'
|
ensemode = 'Vocal_Models'
|
||||||
|
|
||||||
|
#Prepare Audiofile(s)
|
||||||
|
|
||||||
|
|
||||||
for file_num, music_file in enumerate(data['input_paths'], start=1):
|
for file_num, music_file in enumerate(data['input_paths'], start=1):
|
||||||
|
|
||||||
# -Get text and update progress-
|
# -Get text and update progress-
|
||||||
base_text = get_baseText(total_files=len(data['input_paths']),
|
base_text = get_baseText(total_files=len(data['input_paths']),
|
||||||
file_num=file_num)
|
file_num=file_num)
|
||||||
@ -274,10 +263,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=0)
|
step=0)
|
||||||
|
|
||||||
|
#Prepare to loop models
|
||||||
#Load Model(s)
|
|
||||||
#text_widget.write(base_text + 'Loading models...')
|
|
||||||
|
|
||||||
for i, c in tqdm(enumerate(loops), disable=True, desc='Iterations..'):
|
for i, c in tqdm(enumerate(loops), disable=True, desc='Iterations..'):
|
||||||
|
|
||||||
text_widget.write(c['loop_name'] + '\n\n')
|
text_widget.write(c['loop_name'] + '\n\n')
|
||||||
@ -300,7 +286,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
"""
|
"""
|
||||||
enseFolderName = ''
|
enseFolderName = ''
|
||||||
|
|
||||||
# -Instrumental-
|
|
||||||
if str(ensefolder):
|
if str(ensefolder):
|
||||||
enseFolderName += os.path.splitext(os.path.basename(ensefolder))[0]
|
enseFolderName += os.path.splitext(os.path.basename(ensefolder))[0]
|
||||||
|
|
||||||
@ -326,7 +311,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
mp = ModelParameters(c['model_params'])
|
mp = ModelParameters(c['model_params'])
|
||||||
|
|
||||||
# -Instrumental-
|
#Load model
|
||||||
if os.path.isfile(c['model_location']):
|
if os.path.isfile(c['model_location']):
|
||||||
device = torch.device('cpu')
|
device = torch.device('cpu')
|
||||||
model = nets.CascadedASPPNet(mp.param['bins'] * 2)
|
model = nets.CascadedASPPNet(mp.param['bins'] * 2)
|
||||||
@ -340,7 +325,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
model_name = os.path.basename(c["model_name"])
|
model_name = os.path.basename(c["model_name"])
|
||||||
|
|
||||||
|
|
||||||
# -Go through the different steps of seperation-
|
# -Go through the different steps of seperation-
|
||||||
# Wave source
|
# Wave source
|
||||||
text_widget.write(base_text + 'Loading wave source... ')
|
text_widget.write(base_text + 'Loading wave source... ')
|
||||||
@ -376,9 +360,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
step=0.1)
|
step=0.1)
|
||||||
|
|
||||||
text_widget.write(base_text + 'Stft of wave source... ')
|
text_widget.write(base_text + 'Stft of wave source... ')
|
||||||
|
|
||||||
text_widget.write('Done!\n')
|
text_widget.write('Done!\n')
|
||||||
|
|
||||||
text_widget.write(base_text + "Please Wait...\n")
|
text_widget.write(base_text + "Please Wait...\n")
|
||||||
|
|
||||||
X_spec_m = spec_utils.combine_spectrograms(X_spec_s, mp)
|
X_spec_m = spec_utils.combine_spectrograms(X_spec_s, mp)
|
||||||
@ -458,7 +440,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
aggressiveness = {'value': args.aggressiveness, 'split_bin': mp.param['band'][1]['crop_stop']}
|
aggressiveness = {'value': args.aggressiveness, 'split_bin': mp.param['band'][1]['crop_stop']}
|
||||||
|
|
||||||
|
|
||||||
if data['tta']:
|
if data['tta']:
|
||||||
text_widget.write(base_text + "Running Inferences (TTA)... \n")
|
text_widget.write(base_text + "Running Inferences (TTA)... \n")
|
||||||
else:
|
else:
|
||||||
@ -468,10 +449,9 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
device,
|
device,
|
||||||
model, aggressiveness)
|
model, aggressiveness)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=0.85)
|
step=0.85)
|
||||||
|
|
||||||
# Postprocess
|
# Postprocess
|
||||||
if data['postprocess']:
|
if data['postprocess']:
|
||||||
text_widget.write(base_text + 'Post processing... ')
|
text_widget.write(base_text + 'Post processing... ')
|
||||||
@ -489,7 +469,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
if args.high_end_process.startswith('mirroring'):
|
if args.high_end_process.startswith('mirroring'):
|
||||||
input_high_end_ = spec_utils.mirroring(args.high_end_process, y_spec_m, input_high_end, mp)
|
input_high_end_ = spec_utils.mirroring(args.high_end_process, y_spec_m, input_high_end, mp)
|
||||||
|
|
||||||
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, mp, input_high_end_h, input_high_end_)
|
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, mp, input_high_end_h, input_high_end_)
|
||||||
else:
|
else:
|
||||||
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, mp)
|
wav_instrument = spec_utils.cmb_spectrogram_to_wave(y_spec_m, mp)
|
||||||
@ -505,13 +484,12 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=0.9)
|
step=0.9)
|
||||||
|
|
||||||
# Save output music files
|
# Save output music files
|
||||||
text_widget.write(base_text + 'Saving Files... ')
|
text_widget.write(base_text + 'Saving Files... ')
|
||||||
save_files(wav_instrument, wav_vocals)
|
save_files(wav_instrument, wav_vocals)
|
||||||
text_widget.write('Done!\n')
|
text_widget.write('Done!\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Save output image
|
# Save output image
|
||||||
if data['output_image']:
|
if data['output_image']:
|
||||||
with open('{}_Instruments.jpg'.format(base_name), mode='wb') as f:
|
with open('{}_Instruments.jpg'.format(base_name), mode='wb') as f:
|
||||||
@ -526,7 +504,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
text_widget.write(base_text + 'Completed Seperation!\n\n')
|
text_widget.write(base_text + 'Completed Seperation!\n\n')
|
||||||
|
|
||||||
# Emsembling Outputs
|
# Emsembling Outputs
|
||||||
|
|
||||||
def get_files(folder="", prefix="", suffix=""):
|
def get_files(folder="", prefix="", suffix=""):
|
||||||
return [f"{folder}{i}" for i in os.listdir(folder) if i.startswith(prefix) if i.endswith(suffix)]
|
return [f"{folder}{i}" for i in os.listdir(folder) if i.startswith(prefix) if i.endswith(suffix)]
|
||||||
|
|
||||||
@ -535,14 +512,14 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
'algorithm':'min_mag',
|
'algorithm':'min_mag',
|
||||||
'model_params':'lib_v5/modelparams/1band_sr44100_hl512.json',
|
'model_params':'lib_v5/modelparams/1band_sr44100_hl512.json',
|
||||||
'files':get_files(folder=enseExport, prefix=trackname, suffix="_(Instrumental).wav"),
|
'files':get_files(folder=enseExport, prefix=trackname, suffix="_(Instrumental).wav"),
|
||||||
'output':'{}_Ensembled_{}_Instrumentals'.format(trackname, ensemode),
|
'output':'{}_Ensembled_{}_(Instrumental)'.format(trackname, ensemode),
|
||||||
'type': 'Instrumentals'
|
'type': 'Instrumentals'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'algorithm':'max_mag',
|
'algorithm':'max_mag',
|
||||||
'model_params':'lib_v5/modelparams/1band_sr44100_hl512.json',
|
'model_params':'lib_v5/modelparams/1band_sr44100_hl512.json',
|
||||||
'files':get_files(folder=enseExport, prefix=trackname, suffix="_(Vocals).wav"),
|
'files':get_files(folder=enseExport, prefix=trackname, suffix="_(Vocals).wav"),
|
||||||
'output': '{}_Ensembled_{}_Vocals'.format(trackname, ensemode),
|
'output': '{}_Ensembled_{}_(Vocals)'.format(trackname, ensemode),
|
||||||
'type': 'Vocals'
|
'type': 'Vocals'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -587,7 +564,6 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
|
|
||||||
text_widget.write("Done!\n")
|
text_widget.write("Done!\n")
|
||||||
|
|
||||||
|
|
||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=0.95)
|
step=0.95)
|
||||||
text_widget.write("\n")
|
text_widget.write("\n")
|
||||||
@ -602,12 +578,11 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
print(type(e).__name__, e)
|
print(type(e).__name__, e)
|
||||||
print(message)
|
print(message)
|
||||||
progress_var.set(0)
|
progress_var.set(0)
|
||||||
button_widget.configure(state=tk.NORMAL) # Enable Button
|
button_widget.configure(state=tk.NORMAL) #Enable Button
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
if len(os.listdir(enseExport)) == 0: # Check if the folder is empty
|
if len(os.listdir(enseExport)) == 0: #Check if the folder is empty
|
||||||
shutil.rmtree(folder_path)
|
shutil.rmtree(folder_path) #Delete folder if empty
|
||||||
|
|
||||||
update_progress(**progress_kwargs,
|
update_progress(**progress_kwargs,
|
||||||
step=1)
|
step=1)
|
||||||
@ -620,4 +595,4 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
|
|||||||
text_widget.write(f'Conversions Completed!\n')
|
text_widget.write(f'Conversions Completed!\n')
|
||||||
text_widget.write(f'Time Elapsed: {time.strftime("%H:%M:%S", time.gmtime(int(time.perf_counter() - stime)))}') # nopep8
|
text_widget.write(f'Time Elapsed: {time.strftime("%H:%M:%S", time.gmtime(int(time.perf_counter() - stime)))}') # nopep8
|
||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
button_widget.configure(state=tk.NORMAL) # Enable Button
|
button_widget.configure(state=tk.NORMAL) #Enable Button
|
||||||
|
Loading…
Reference in New Issue
Block a user