From 19ca821c101a49d73115235d0c3867b04b534785 Mon Sep 17 00:00:00 2001
From: Captain FLAM <2856272+Captain-FLAM@users.noreply.github.com>
Date: Mon, 20 Nov 2023 16:02:45 +0100
Subject: [PATCH] 5.3
---
App/__init__.py | 2 +-
App/inference.py | 46 +++++++++++++++++++++++++++++++++-------------
App/settings.py | 14 +++++++-------
Gui/Notebook.py | 2 +-
Gui/wx_Main.py | 26 +++++++++++++++++++-------
Gui/wx_Window.py | 5 +----
Gui/wx_window.fbp | 6 +++---
README.md | 2 +-
8 files changed, 66 insertions(+), 37 deletions(-)
diff --git a/App/__init__.py b/App/__init__.py
index a4599cd..9f8c845 100644
--- a/App/__init__.py
+++ b/App/__init__.py
@@ -1 +1 @@
-# Version 5.2.1
\ No newline at end of file
+# Version 5.3
\ No newline at end of file
diff --git a/App/inference.py b/App/inference.py
index 31186a3..718d632 100644
--- a/App/inference.py
+++ b/App/inference.py
@@ -156,6 +156,13 @@ def __init__(self, params, config, wxForm):
self.GPU_device = 'cuda:0'
self.providers = ["CUDAExecutionProvider"]
+ if wxForm is None: # for Jupyter Notebook
+ print('
It\'s OK -> GPU is used for processing !!
')
+ # For MAC OSX
+ elif torch.backends.mps.is_available():
+ self.GPU_device = 'mps'
+ self.providers = None
+
if wxForm is None: # for Jupyter Notebook
print('It\'s OK -> GPU is used for processing !!
')
else:
@@ -263,9 +270,11 @@ def __init__(self, params, config, wxForm):
self.AudioFiles = [
"NORMALIZED",
+ # Vocals extraction
"Music extract",
"Vocal extract",
"Music Bleedings",
+ # Here --> Vocals results subtracted from Original Audio = Music
"Vocal Bleedings",
"Remove Music",
"Vocal FINAL",
@@ -277,8 +286,8 @@ def __init__(self, params, config, wxForm):
# DEBUG
# Reload "Bleedings" files with GOD MODE ... or not !
self.AudioFiles_Debug.append(3)
- self.AudioFiles_Debug.append(4)
- self.AudioFiles_Debug.append(5)
+ # self.AudioFiles_Debug.append(4)
+ # self.AudioFiles_Debug.append(5)
# ******************************************************************
@@ -580,6 +589,9 @@ def Extract_with_Model(self, type, audio, model):
if torch.cuda.is_available():
torch.cuda.empty_cache()
+ torch.cuda.ipc_collect()
+ elif torch.backends.mps.is_available():
+ torch.mps.empty_cache()
else:
if not self.large_gpu:
@@ -593,12 +605,12 @@ def Extract_with_Model(self, type, audio, model):
if self.Denoise:
print(f"{text} ({quality['BigShifts']} pass)")
- source = 0.5 * -self.demix_full(-audio, mdx_model, inference, bigshifts)[0]
- source += 0.5 * self.demix_full( audio, mdx_model, inference, bigshifts)[0]
+ source = 0.5 * -self.demix_full(-audio, mdx_model, inference, bigshifts, 1)[0]
+ source += 0.5 * self.demix_full( audio, mdx_model, inference, bigshifts, 2)[0]
else:
# ONLY 1 Pass, for testing purposes
print(f"{text} ({quality['BigShifts']} pass) - NO Denoise !")
- source = self.demix_full(audio, mdx_model, inference, bigshifts)[0]
+ source = self.demix_full(audio, mdx_model, inference, bigshifts, 0)[0]
# Automatic SRS (for not FULL-BAND models !)
if quality['BigShifts_SRS'] > 0:
@@ -629,15 +641,15 @@ def Extract_with_Model(self, type, audio, model):
print(f"{text} -> SRS High ({bigshifts} pass)")
source_SRS = 0.5 * App.audio_utils.Change_sample_rate(
- -self.demix_full(-audio_SRS, mdx_model, inference, bigshifts)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
+ -self.demix_full(-audio_SRS, mdx_model, inference, bigshifts, 1)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
source_SRS += 0.5 * App.audio_utils.Change_sample_rate(
- self.demix_full( audio_SRS, mdx_model, inference, bigshifts)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
+ self.demix_full( audio_SRS, mdx_model, inference, bigshifts, 2)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
else:
# ONLY 1 Pass, for testing purposes
print(f"{text} -> SRS High ({bigshifts} pass) - NO Denoise !")
source_SRS = App.audio_utils.Change_sample_rate(
- self.demix_full(audio_SRS, mdx_model, inference, bigshifts)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
+ self.demix_full( audio_SRS, mdx_model, inference, bigshifts, 0)[0], 'UP', self.original_cutoff, model['Cut_OFF'] + delta)
# Check if source_SRS is same size than source
source_SRS = librosa.util.fix_length(source_SRS, size = source.shape[-1])
@@ -685,14 +697,14 @@ def Extract_with_Model(self, type, audio, model):
print(f"{text} -> SRS Low (1 pass)")
source_SRS = 0.5 * App.audio_utils.Change_sample_rate(
- -self.demix_full(-audio_SRS, mdx_model, inference, 1)[0], 'DOWN', self.original_cutoff, cut_freq)
+ -self.demix_full(-audio_SRS, mdx_model, inference, 1, 1)[0], 'DOWN', self.original_cutoff, cut_freq)
source_SRS += 0.5 * App.audio_utils.Change_sample_rate(
- self.demix_full( audio_SRS, mdx_model, inference, 1)[0], 'DOWN', self.original_cutoff, cut_freq)
+ self.demix_full( audio_SRS, mdx_model, inference, 1, 2)[0], 'DOWN', self.original_cutoff, cut_freq)
else:
print(f"{text} -> SRS Low (1 pass) - NO Denoise !")
source_SRS = App.audio_utils.Change_sample_rate(
- self.demix_full(audio_SRS, mdx_model, inference, 1)[0], 'DOWN', self.original_cutoff, cut_freq)
+ self.demix_full( audio_SRS, mdx_model, inference, 1, 0)[0], 'DOWN', self.original_cutoff, cut_freq)
# Check if source_SRS is same size than source
source_SRS = librosa.util.fix_length(source_SRS, size = source.shape[-1])
@@ -730,6 +742,9 @@ def Kill_MDX(self, model_name):
gc.collect()
if torch.cuda.is_available():
torch.cuda.empty_cache()
+ torch.cuda.ipc_collect()
+ elif torch.backends.mps.is_available():
+ torch.mps.empty_cache()
def raise_aicrowd_error(self, msg):
# Will be used by the evaluator to provide logs, DO NOT CHANGE
@@ -795,7 +810,7 @@ def Save_Audio(self, key, audio, model_name = ""):
App.audio_utils.Save_Audio(file, audio, self.sample_rate, self.output_format, self.original_cutoff, self.ffmpeg)
- def demix_full(self, mix, use_model, infer_session, bigshifts):
+ def demix_full(self, mix, use_model, infer_session, bigshifts, pass_number = 0):
results = []
mix_length = int(mix.shape[1] / 44100)
@@ -812,7 +827,10 @@ def demix_full(self, mix, use_model, infer_session, bigshifts):
shifts = [x * demix_seconds for x in range(bigshifts)]
- self.Progress.reset(len(shifts), unit="Pass")
+ if pass_number == 0:
+ self.Progress.reset(len(shifts), unit="Pass") # NO Denoise -> only 1 PASS !
+ elif pass_number == 1:
+ self.Progress.reset(len(shifts) * 2, unit="Pass") # 1st PASS / 2
for shift in shifts:
@@ -976,6 +994,8 @@ def Exit():
if torch.cuda.is_available():
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
+ elif torch.backends.mps.is_available():
+ torch.mps.empty_cache()
gc.collect()
diff --git a/App/settings.py b/App/settings.py
index 3c77677..2d3bd2b 100644
--- a/App/settings.py
+++ b/App/settings.py
@@ -118,16 +118,16 @@
'bleed_6': "Instrum Main",
},
{
- 'music_1': "MDX23C 8K FFT",
- 'music_2': "Instrum HQ 3",
+ 'music_1': "----",
+ 'music_2': "----",
'vocal_1': "MDX23C 8K FFT",
- 'vocal_2': "Voc FT",
- 'bleed_1': "Instrum 3",
- 'bleed_2': "Instrum Main",
+ 'vocal_2': "Kim Vocal 2",
+ 'bleed_1': "Instrum Main",
+ 'bleed_2': "----",
'bleed_3': "MDX23C 8K FFT",
'bleed_4': "----",
- 'bleed_5': "Instrum 3",
- 'bleed_6': "Instrum Main",
+ 'bleed_5': "----",
+ 'bleed_6': "----",
},
]
diff --git a/Gui/Notebook.py b/Gui/Notebook.py
index 230b354..4e3dabf 100644
--- a/Gui/Notebook.py
+++ b/Gui/Notebook.py
@@ -12,7 +12,7 @@
def Run(params):
- import App.settings, Gui.Progress
+ import App.settings, Gui.Progress, Gui.Error
Gdrive = params['Gdrive']
Project = params['Project']
diff --git a/Gui/wx_Main.py b/Gui/wx_Main.py
index 96df5f5..4f80a63 100644
--- a/Gui/wx_Main.py
+++ b/Gui/wx_Main.py
@@ -8,12 +8,17 @@
import App.settings, Gui.wx_GPUtil, Gui.wx_Progress, Gui.wx_Window
# Change Font for ALL controls in a wxForm (Recursive)
-def Set_Fonts(parent, font):
+def Set_Fonts(parent, font = None, color = None):
for control in parent.GetChildren():
- if hasattr(control, "SetFont") and control.GetFont().GetFaceName() != "Tahoma" and not isinstance(control, wx.html.HtmlWindow):
- control.SetFont(font)
+ if font is not None:
+ if hasattr(control, "SetFont") and control.GetFont().GetFaceName() != "Tahoma" and not isinstance(control, wx.html.HtmlWindow):
+ control.SetFont(font)
+
+ if color is not None:
+ if hasattr(control, "SetForegroundColour") and not isinstance(control, wx.html.HtmlWindow):
+ control.SetForegroundColour(color)
# Recursive
if isinstance(control, wx.Notebook) or isinstance(control, wx.NotebookPage) \
@@ -28,7 +33,9 @@ def __init__(self, parent, params):
# Set fonts for ALL controls
if platform.system() == "Windows":
- Set_Fonts(self, wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Segoe UI"))
+ Set_Fonts(self, font = wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Segoe UI"))
+ elif platform.system() == "Darwin":
+ Set_Fonts(self, color = wx.Colour(0, 0, 0))
self.params = params
self.Gdrive = params['Gdrive']
@@ -56,9 +63,14 @@ def __init__(self, parent, params):
self.timer = wx.Timer(self) # Local Timer
self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer) # Link timer to function
else:
- self.GPU.SetForegroundColour(wx.Colour(255, 0, 64))
- self.GPU.SetLabel("Using CPU ►►►")
- self.GPU_info.SetLabel("With CPU, processing will be very slow !!")
+ if platform.system() == "Darwin":
+ self.GPU.SetForegroundColour(wx.Colour(0, 179, 45))
+ self.GPU.SetLabel(f"Using GPU ►")
+ self.GPU_info.SetLabel("... if you have installed the correct drivers !")
+ else:
+ self.GPU.SetForegroundColour(wx.Colour(255, 0, 64))
+ self.GPU.SetLabel("Using CPU ►►►")
+ self.GPU_info.SetLabel("With CPU, processing will be very slow !!")
# Set icons for each tab
icon_music = wx.Image(icon_path + "icon-music.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
diff --git a/Gui/wx_Window.py b/Gui/wx_Window.py
index d3093a0..e5af607 100644
--- a/Gui/wx_Window.py
+++ b/Gui/wx_Window.py
@@ -21,10 +21,9 @@
class Form ( wx.Frame ):
def __init__( self, parent ):
- wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"KaraFan"), pos = wx.DefaultPosition, size = wx.Size( 697,777 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
+ wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = _(u"KaraFan"), pos = wx.DefaultPosition, size = wx.Size( 697,806 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
- self.SetFont( wx.Font( 14, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Arial Narrow" ) )
self.SetBackgroundColour( wx.Colour( 255, 255, 255 ) )
MainSizer = wx.BoxSizer( wx.VERTICAL )
@@ -33,8 +32,6 @@ def __init__( self, parent ):
self.Tabs.SetFont( wx.Font( 12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Arial" ) )
self.Tab_Settings = wx.Panel( self.Tabs, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
- self.Tab_Settings.SetFont( wx.Font( 12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "Arial" ) )
-
box1 = wx.BoxSizer( wx.VERTICAL )
sbSizer1 = wx.StaticBoxSizer( wx.StaticBox( self.Tab_Settings, wx.ID_ANY, _(u"[ Songs ]") ), wx.VERTICAL )
diff --git a/Gui/wx_window.fbp b/Gui/wx_window.fbp
index fdc4cf1..c7f6d10 100644
--- a/Gui/wx_window.fbp
+++ b/Gui/wx_window.fbp
@@ -40,14 +40,14 @@
impl_virtual
- Arial Narrow,90,400,14,74,0
+
0
wxID_ANY
Form
- 697,777
+ 697,806
wxDEFAULT_FRAME_STYLE
; ; forward_declare
KaraFan
@@ -149,7 +149,7 @@
1
1
- Arial,90,400,12,74,0
+
0
0
wxID_ANY
diff --git a/README.md b/README.md
index 6c2e508..7679c15 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ click here to send me an email, I'll give you my wallet address :
[![Bitcoin](https://img.shields.io/badge/Donate-Bitcoin-green.svg?style=for-the-badge)](mailto:Captain_FLAM@gmx.fr) 😍
You can reach me by [**email**](https://github.com/Captain-FLAM) or Join all of us on the [**Dedicated channel on Discord**](https://discord.com/channels/708579735583588363/1162265179271200820) ![Discord](images/discord.svg)
-(prior to : [**Discord Invitation**](https://discord.gg/eXdEYwU2) on the "Audio Separation" server)
+(prior to : [**Discord Invitation**](https://discord.gg/ErkXU4JGKn) on the "Audio Separation" server)
# 🚀 INSTALL