Attempt at fix for #42

This commit is contained in:
Dilan Boskan
2021-01-09 20:40:12 +01:00
parent 15614a14f5
commit fe4c0073d3
3 changed files with 25 additions and 42 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,6 @@
__pycache__ __pycache__
data.pkl data.pkl
# Testing modules # Testing models
model_iter26_sr33075_hl384_w512.pth model_iter26_sr33075_hl384_w512.pth
baseline.pth baseline.pth
temp.wav

View File

@@ -143,18 +143,13 @@ def determineModelFolderName():
# -Instrumental- # -Instrumental-
if os.path.isfile(data['instrumentalModel']): if os.path.isfile(data['instrumentalModel']):
modelFolderName += os.path.splitext(os.path.basename(data['instrumentalModel']))[0] + '-' modelFolderName += os.path.splitext(os.path.basename(data['instrumentalModel']))[0]
# -Vocal- # -Vocal-
elif os.path.isfile(data['vocalModel']): elif os.path.isfile(data['vocalModel']):
modelFolderName += os.path.splitext(os.path.basename(data['vocalModel']))[0] + '-' modelFolderName += os.path.splitext(os.path.basename(data['vocalModel']))[0]
# -Stack- # -Stack-
if os.path.isfile(data['stackModel']): if os.path.isfile(data['stackModel']):
modelFolderName += os.path.splitext(os.path.basename(data['stackModel']))[0] modelFolderName += '-' + os.path.splitext(os.path.basename(data['stackModel']))[0]
else:
modelFolderName = modelFolderName[:-1]
if modelFolderName:
modelFolderName = '/' + modelFolderName
return modelFolderName return modelFolderName
@@ -327,22 +322,17 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
sf.write(f'temp.wav', sf.write(f'temp.wav',
wav_instrument.T, sr) wav_instrument.T, sr)
appendModelFolderName = modelFolderName.replace('/', '_')
# -Save files- # -Save files-
# Instrumental # Instrumental
if instrumental_name is not None: if instrumental_name is not None:
instrumental_path = '{save_path}/{file_name}.wav'.format( instrumental_path = os.path.join(save_path,
save_path=save_path, f'{os.path.basename(base_name)}_{instrumental_name}_{modelFolderName}.wav')
file_name=f'{os.path.basename(base_name)}_{instrumental_name}{appendModelFolderName}',
)
sf.write(instrumental_path, sf.write(instrumental_path,
wav_instrument.T, sr) wav_instrument.T, sr)
# Vocal # Vocal
if vocal_name is not None: if vocal_name is not None:
vocal_path = '{save_path}/{file_name}.wav'.format( vocal_path = os.path.join(save_path,
save_path=save_path, f'{os.path.basename(base_name)}_{vocal_name}_{modelFolderName}.wav')
file_name=f'{os.path.basename(base_name)}_{vocal_name}{appendModelFolderName}',
)
sf.write(vocal_path, sf.write(vocal_path,
wav_vocals.T, sr) wav_vocals.T, sr)
@@ -376,7 +366,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
models, devices = load_models() models, devices = load_models()
modelFolderName = determineModelFolderName() modelFolderName = determineModelFolderName()
if modelFolderName: if modelFolderName:
folder_path = f'{data["export_path"]}{modelFolderName}' folder_path = os.path.join(data["export_path"], modelFolderName)
if not os.path.isdir(folder_path): if not os.path.isdir(folder_path):
os.mkdir(folder_path) os.mkdir(folder_path)
@@ -388,7 +378,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
for file_num, music_file in enumerate(data['input_paths'], start=1): for file_num, music_file in enumerate(data['input_paths'], start=1):
try: try:
# 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 = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
for loop_num in range(total_loops): for loop_num in range(total_loops):
# -Determine which model will be used- # -Determine which model will be used-
@@ -483,4 +473,4 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
text_widget.write(f'Conversion(s) Completed and Saving all Files!\n') # nopep8 Write Command Text text_widget.write(f'Conversion(s) Completed and Saving all Files!\n') # nopep8 Write Command Text
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

View File

@@ -168,6 +168,8 @@ data = {
'stackPasses': 0, 'stackPasses': 0,
'stackOnly': False, 'stackOnly': False,
'saveAllStacked': False, 'saveAllStacked': False,
# Model Folder
'modelFolder': False,
# Constants # Constants
'sr': 44_100, 'sr': 44_100,
'hop_length': 1_024, 'hop_length': 1_024,
@@ -261,18 +263,13 @@ def determineModelFolderName():
# -Instrumental- # -Instrumental-
if os.path.isfile(data['instrumentalModel']): if os.path.isfile(data['instrumentalModel']):
modelFolderName += os.path.splitext(os.path.basename(data['instrumentalModel']))[0] + '-' modelFolderName += os.path.splitext(os.path.basename(data['instrumentalModel']))[0]
# -Vocal- # -Vocal-
elif os.path.isfile(data['vocalModel']): elif os.path.isfile(data['vocalModel']):
modelFolderName += os.path.splitext(os.path.basename(data['vocalModel']))[0] + '-' modelFolderName += os.path.splitext(os.path.basename(data['vocalModel']))[0]
# -Stack- # -Stack-
if os.path.isfile(data['stackModel']): if os.path.isfile(data['stackModel']):
modelFolderName += os.path.splitext(os.path.basename(data['stackModel']))[0] modelFolderName += '-' + os.path.splitext(os.path.basename(data['stackModel']))[0]
else:
modelFolderName = modelFolderName[:-1]
if modelFolderName:
modelFolderName = '/' + modelFolderName
return modelFolderName return modelFolderName
@@ -341,23 +338,18 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
sf.write(f'temp.wav', sf.write(f'temp.wav',
wav_instrument.T, sr) wav_instrument.T, sr)
appendModelFolderName = modelFolderName.replace('/', '_')
# -Save files- # -Save files-
# Instrumental # Instrumental
if instrumental_name is not None: if instrumental_name is not None:
instrumental_path = '{save_path}/{file_name}.wav'.format( instrumental_path = os.path.join(save_path,
save_path=save_path, f'{os.path.basename(base_name)}_{instrumental_name}_{modelFolderName}.wav')
file_name=f'{os.path.basename(base_name)}_{instrumental_name}{appendModelFolderName}',
)
sf.write(instrumental_path, sf.write(instrumental_path,
wav_instrument.T, sr) wav_instrument.T, sr)
# Vocal # Vocal
if vocal_name is not None: if vocal_name is not None:
vocal_path = '{save_path}/{file_name}.wav'.format( vocal_path = os.path.join(save_path,
save_path=save_path, f'{os.path.basename(base_name)}_{vocal_name}_{modelFolderName}.wav')
file_name=f'{os.path.basename(base_name)}_{vocal_name}{appendModelFolderName}',
)
sf.write(vocal_path, sf.write(vocal_path,
wav_vocals.T, sr) wav_vocals.T, sr)
@@ -381,7 +373,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
vocal_remover = VocalRemover(data, text_widget) vocal_remover = VocalRemover(data, text_widget)
modelFolderName = determineModelFolderName() modelFolderName = determineModelFolderName()
if modelFolderName: if modelFolderName:
folder_path = f'{data["export_path"]}{modelFolderName}' folder_path = os.path.join(data["export_path"], modelFolderName)
if not os.path.isdir(folder_path): if not os.path.isdir(folder_path):
os.mkdir(folder_path) os.mkdir(folder_path)
@@ -392,7 +384,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
for file_num, music_file in enumerate(data['input_paths'], start=1): for file_num, music_file in enumerate(data['input_paths'], start=1):
try: try:
# 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 = os.path.join(folder_path, f'{file_num}_{os.path.splitext(os.path.basename(music_file))[0]}')
# --Seperate Music Files-- # --Seperate Music Files--
for loop_num in range(total_loops): for loop_num in range(total_loops):
@@ -519,4 +511,4 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
text_widget.write(f'Conversion(s) Completed and Saving all Files!\n') text_widget.write(f'Conversion(s) Completed and Saving all Files!\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