Skip to content

Commit

Permalink
5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain-FLAM committed Nov 20, 2023
1 parent eb340e5 commit 19ca821
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 37 deletions.
2 changes: 1 addition & 1 deletion App/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Version 5.2.1
# Version 5.3
46 changes: 33 additions & 13 deletions App/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div style="font-size:18px;color:#00b32d;"><b>It\'s OK -> GPU is used for processing !!</b></div>')
# For MAC OSX
elif torch.backends.mps.is_available():
self.GPU_device = 'mps'
self.providers = None

if wxForm is None: # for Jupyter Notebook
print('<div style="font-size:18px;color:#00b32d;"><b>It\'s OK -> GPU is used for processing !!</b></div>')
else:
Expand Down Expand Up @@ -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",
Expand All @@ -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)


# ******************************************************************
Expand Down Expand Up @@ -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:
Expand All @@ -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) - <b>NO Denoise !</b>")
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:
Expand Down Expand Up @@ -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) - <b>NO Denoise !</b>")
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])
Expand Down Expand Up @@ -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) - <b>NO Denoise !</b>")
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])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:

Expand Down Expand Up @@ -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()

Expand Down
14 changes: 7 additions & 7 deletions App/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': "----",
},
]

Expand Down
2 changes: 1 addition & 1 deletion Gui/Notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
26 changes: 19 additions & 7 deletions Gui/wx_Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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']
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions Gui/wx_Window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 )
Expand Down
6 changes: 3 additions & 3 deletions Gui/wx_window.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font">Arial Narrow,90,400,14,74,0</property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">Form</property>
<property name="pos"></property>
<property name="size">697,777</property>
<property name="size">697,806</property>
<property name="style">wxDEFAULT_FRAME_STYLE</property>
<property name="subclass">; ; forward_declare</property>
<property name="title">KaraFan</property>
Expand Down Expand Up @@ -149,7 +149,7 @@
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">Arial,90,400,12,74,0</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 19ca821

Please sign in to comment.