This commit is contained in:
Dilan Boskan 2022-05-07 10:58:24 +02:00
parent 43af31d1b2
commit 6ed512e6d0
9 changed files with 342 additions and 214 deletions

View File

@ -30,10 +30,11 @@ JSON_TO_NAME = OrderedDict(**{
# Number # Number
'aggressiveness': 'doubleSpinBox_aggressiveness', 'aggressiveness': 'doubleSpinBox_aggressiveness',
'highEndProcess': 'comboBox_highEndProcess', 'highEndProcess': 'comboBox_highEndProcess',
'windowSize': 'comboBox_winSize',
# -Models- # -Models-
'ensemble': 'checkBox_ensemble',
'instrumentalModelName': 'comboBox_instrumental', 'instrumentalModelName': 'comboBox_instrumental',
'vocalModelName': 'comboBox_vocal', 'vocalModelName': 'comboBox_vocal',
'windowSize': 'comboBox_winSize',
}) })
DEFAULT_SETTINGS = { DEFAULT_SETTINGS = {
# --Independent Data (Data not directly connected with widgets)-- # --Independent Data (Data not directly connected with widgets)--
@ -54,11 +55,12 @@ DEFAULT_SETTINGS = {
'outputImage': True, 'outputImage': True,
'modelFolder': True, 'modelFolder': True,
'deepExtraction': True, 'deepExtraction': True,
'windowSize': 1024,
# Number # Number
'aggressiveness': 0.1, 'aggressiveness': 0.1,
'highEndProcess': 'Bypass', 'highEndProcess': 'Bypass',
# -Models- # -Models-
'windowSize': 1024, 'ensemble': True,
}], }],
['NONE', { ['NONE', {
# -Conversion- # -Conversion-
@ -68,11 +70,12 @@ DEFAULT_SETTINGS = {
'outputImage': False, 'outputImage': False,
'modelFolder': False, 'modelFolder': False,
'deepExtraction': False, 'deepExtraction': False,
'windowSize': 352,
# Number # Number
'aggressiveness': -0.1, 'aggressiveness': -0.1,
'highEndProcess': 'Mirroring', 'highEndProcess': 'Mirroring',
# -Models- # -Models-
'windowSize': 352, 'ensemble': False,
}] }]
], ],
# Presets save directory (Default: desktop) # Presets save directory (Default: desktop)

View File

@ -0,0 +1,107 @@
"""
Class for managing models
"""
# pylint: disable=no-name-in-module, import-error
# -GUI-
from typing import Dict
from PySide2 import QtWidgets
from PySide2 import QtCore
from PySide2 import QtGui
from PySide2.QtGui import Qt
# -Root imports-
# None
# -Other-
import hashlib
# System
import os
import sys
# Get the absolute path to this file
if getattr(sys, 'frozen', False):
# If the application is run as a bundle, the PyInstaller bootloader
# extends the sys module by a flag frozen=True and sets the app
# path into variable _MEIPASS'.
main_path = os.path.dirname(sys.executable)
abs_path = os.path.join(main_path, 'models')
else:
abs_path = os.path.dirname(os.path.abspath(__file__))
MODEL_TYPES = [
"Instrumental",
"Vocal",
"Karaoke",
"Custom"
]
class Model:
def __init__(self, model_type: str, path: str):
self.type = model_type
self.path = path
self.id = self.get_model_id(path)
@staticmethod
def get_model_id(path: str) -> str:
buffer_size = 65536
sha1 = hashlib.sha1()
with open(path, 'rb') as f:
while True:
data = f.read(buffer_size)
if not data:
break
sha1.update(data)
return sha1.hexdigest()
def __repr__(self) -> str:
return f"Model(type:{self.type},"
class ModelManager:
def __init__(self):
self.model_dirs = {}
self.available_models = {}
self._callback = None
self.create_model_folders()
def search_for_models(self, force_callback: bool = False):
"""Search for the models in each model type folder"""
new_available_models = {}
for model_type, model_dir in self.model_dirs.items():
for index, f in enumerate(os.listdir(model_dir)):
if not f.endswith('.pth'):
# File is not a model file, so skip
continue
# Get data
path = os.path.join(model_dir, f)
new_available_models[model_type] = Model(model_type, path)
if (new_available_models != self.available_models or
force_callback):
self.available_models = new_available_models
if self._callback is not None:
self._callback()
else:
self.available_models = new_available_models
def set_callback(self, callback):
"""Set a callback function that will be called
when the avaiable models have changed
Args:
callback (function): Callback funtion
"""
self._callback = callback
def create_model_folders(self):
"""Create the folders for each model type"""
self.model_dirs.clear()
for model in MODEL_TYPES:
model_dir = os.path.join(abs_path, model)
if not os.path.isdir(model_dir):
os.mkdir(model_dir)
self.model_dirs[model] = model_dir

View File

@ -1,24 +1,24 @@
[settingswindow] [settingswindow]
size=@Size(1028 551) size=@Size(941 550)
pos=@Point(585 245) pos=@Point(274 296)
checkBox_gpuConversion=false checkBox_gpuConversion=false
checkBox_tta=false checkBox_tta=true
checkBox_modelFolder=false checkBox_modelFolder=true
checkBox_outputImage=false checkBox_outputImage=true
checkBox_postProcess=false checkBox_postProcess=true
checkBox_deepExtraction=false checkBox_deepExtraction=true
comboBox_winSize=352 comboBox_winSize=1024
comboBox_highEndProcess=Mirroring comboBox_highEndProcess=Bypass
doubleSpinBox_aggressiveness=-0.1 doubleSpinBox_aggressiveness=0.1
checkBox_ensemble=false checkBox_ensemble=false
comboBox_instrumental=MGM-v5-2Band-32000-BETA1 - Kopie comboBox_instrumental=
comboBox_vocal= comboBox_vocal=
comboBox_presets=NONE comboBox_presets=Custom
checkBox_notifiyOnFinish=false checkBox_notifiyOnFinish=false
checkBox_notifyUpdates=true checkBox_notifyUpdates=true
checkBox_settingsStartup=false checkBox_settingsStartup=true
checkBox_enableAnimations=true checkBox_enableAnimations=true
checkBox_showInfoButtons=false checkBox_showInfoButtons=true
checkBox_multithreading=false checkBox_multithreading=false
comboBox_command=Off comboBox_command=Off
checkBox_autoSaveInstrumentals=true checkBox_autoSaveInstrumentals=true
@ -29,17 +29,12 @@ exportDirectory=C:/Users/boska/Desktop
language=en language=en
inputPaths=@Invalid() inputPaths=@Invalid()
inputsDirectory=C:/Users/boska/Desktop inputsDirectory=C:/Users/boska/Desktop
presets=@Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xc3\x80\x3X\x3\0\0\0\x41LLq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G?\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x88X\xe\0\0\0highEndProcessq\x4X\x6\0\0\0\x42ypassq\x5X\v\0\0\0modelFolderq\x6\x88X\v\0\0\0outputImageq\a\x88X\v\0\0\0postProcessq\b\x88X\x3\0\0\0ttaq\t\x88X\n\0\0\0windowSizeq\nM\0\x4u\x86q\v.), @Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xc7\x80\x3X\x4\0\0\0NONEq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G\xbf\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x89X\xe\0\0\0highEndProcessq\x4X\t\0\0\0Mirroringq\x5X\v\0\0\0modelFolderq\x6\x89X\v\0\0\0outputImageq\a\x89X\v\0\0\0postProcessq\b\x89X\x3\0\0\0ttaq\t\x89X\n\0\0\0windowSizeq\nM`\x1u\x86q\v.) presets=@Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xd3\x80\x3X\x3\0\0\0\x41LLq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G?\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x88X\b\0\0\0\x65nsembleq\x4\x88X\xe\0\0\0highEndProcessq\x5X\x6\0\0\0\x42ypassq\x6X\v\0\0\0modelFolderq\a\x88X\v\0\0\0outputImageq\b\x88X\v\0\0\0postProcessq\t\x88X\x3\0\0\0ttaq\n\x88X\n\0\0\0windowSizeq\vM\0\x4u\x86q\f.), @Variant(\0\0\0\x7f\0\0\0\x18PySide::PyObjectWrapper\0\0\0\0\xd7\x80\x3X\x4\0\0\0NONEq\0}q\x1(X\xe\0\0\0\x61ggressivenessq\x2G\xbf\xb9\x99\x99\x99\x99\x99\x9aX\xe\0\0\0\x64\x65\x65pExtractionq\x3\x89X\b\0\0\0\x65nsembleq\x4\x89X\xe\0\0\0highEndProcessq\x5X\t\0\0\0Mirroringq\x6X\v\0\0\0modelFolderq\a\x89X\v\0\0\0outputImageq\b\x89X\v\0\0\0postProcessq\t\x89X\x3\0\0\0ttaq\n\x89X\n\0\0\0windowSizeq\vM`\x1u\x86q\f.)
presets_loadDir=C:/Users/boska/Desktop presets_loadDir=C:/Users/boska/Desktop
presets_saveDir=C:/Users/boska/Desktop presets_saveDir=C:/Users/boska/Desktop
theme=dark theme=dark
[mainwindow] [mainwindow]
size=@Size(906 559) size=@Size(906 559)
pos=@Point(503 220) pos=@Point(507 260)
isMaximized=false
[infowindow]
size=@Size(596 440)
pos=@Point(662 204)
isMaximized=false isMaximized=false

View File

@ -3,15 +3,14 @@ Translator Class File
""" """
# pylint: disable=no-name-in-module, import-error # pylint: disable=no-name-in-module, import-error
# -GUI- # -GUI-
from typing import DefaultDict, Dict
from PySide2 import QtWidgets from PySide2 import QtWidgets
from PySide2 import QtCore from PySide2 import QtCore
from PySide2 import QtGui from PySide2 import QtGui
import PySide2
from PySide2.QtGui import Qt from PySide2.QtGui import Qt
# -Root imports- # -Root imports-
# None # None
# -Other- # -Other-
from typing import DefaultDict, Dict
# System # System
import os import os
import sys import sys

View File

@ -18,7 +18,7 @@ class Ui_SettingsWindow(object):
if not SettingsWindow.objectName(): if not SettingsWindow.objectName():
SettingsWindow.setObjectName(u"SettingsWindow") SettingsWindow.setObjectName(u"SettingsWindow")
SettingsWindow.setEnabled(True) SettingsWindow.setEnabled(True)
SettingsWindow.resize(941, 551) SettingsWindow.resize(941, 550)
SettingsWindow.setStyleSheet(u"") SettingsWindow.setStyleSheet(u"")
self.horizontalLayout = QHBoxLayout(SettingsWindow) self.horizontalLayout = QHBoxLayout(SettingsWindow)
self.horizontalLayout.setSpacing(0) self.horizontalLayout.setSpacing(0)
@ -134,7 +134,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_2 = QWidget() self.scrollAreaWidgetContents_2 = QWidget()
self.scrollAreaWidgetContents_2.setObjectName( self.scrollAreaWidgetContents_2.setObjectName(
u"scrollAreaWidgetContents_2") u"scrollAreaWidgetContents_2")
self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 741, 551)) self.scrollAreaWidgetContents_2.setGeometry(QRect(0, 0, 741, 550))
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
sizePolicy2.setHorizontalStretch(0) sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0) sizePolicy2.setVerticalStretch(0)
@ -164,7 +164,7 @@ class Ui_SettingsWindow(object):
self.horizontalFrame_1 = QFrame(self.frame_3) self.horizontalFrame_1 = QFrame(self.frame_3)
self.horizontalFrame_1.setObjectName(u"horizontalFrame_1") self.horizontalFrame_1.setObjectName(u"horizontalFrame_1")
self.horizontalLayout_4 = QHBoxLayout(self.horizontalFrame_1) self.horizontalLayout_4 = QHBoxLayout(self.horizontalFrame_1)
self.horizontalLayout_4.setSpacing(45) self.horizontalLayout_4.setSpacing(35)
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
self.frame_template_3 = QFrame(self.horizontalFrame_1) self.frame_template_3 = QFrame(self.horizontalFrame_1)
@ -572,25 +572,46 @@ class Ui_SettingsWindow(object):
self.frame_12.setObjectName(u"frame_12") self.frame_12.setObjectName(u"frame_12")
self.frame_12.setFrameShape(QFrame.NoFrame) self.frame_12.setFrameShape(QFrame.NoFrame)
self.frame_12.setFrameShadow(QFrame.Raised) self.frame_12.setFrameShadow(QFrame.Raised)
self.label_9 = QLabel(self.frame_12) self.tableWidget = QTableWidget(self.frame_12)
self.label_9.setObjectName(u"label_9") if (self.tableWidget.columnCount() < 3):
self.label_9.setGeometry(QRect(350, 30, 151, 31)) self.tableWidget.setColumnCount(3)
self.treeWidget = QTreeWidget(self.frame_12) __qtablewidgetitem = QTableWidgetItem()
__qtreewidgetitem = QTreeWidgetItem(self.treeWidget) self.tableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
__qtreewidgetitem1 = QTreeWidgetItem(__qtreewidgetitem) __qtablewidgetitem1 = QTableWidgetItem()
__qtreewidgetitem1.setCheckState(0, Qt.Checked) self.tableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
__qtreewidgetitem2 = QTreeWidgetItem(__qtreewidgetitem) __qtablewidgetitem2 = QTableWidgetItem()
__qtreewidgetitem2.setCheckState(0, Qt.Unchecked) self.tableWidget.setHorizontalHeaderItem(2, __qtablewidgetitem2)
__qtreewidgetitem3 = QTreeWidgetItem(self.treeWidget) if (self.tableWidget.rowCount() < 2):
__qtreewidgetitem4 = QTreeWidgetItem(__qtreewidgetitem3) self.tableWidget.setRowCount(2)
__qtreewidgetitem4.setCheckState(0, Qt.Unchecked) __qtablewidgetitem3 = QTableWidgetItem()
__qtreewidgetitem5 = QTreeWidgetItem(__qtreewidgetitem3) self.tableWidget.setVerticalHeaderItem(0, __qtablewidgetitem3)
__qtreewidgetitem5.setCheckState(0, Qt.Unchecked) __qtablewidgetitem4 = QTableWidgetItem()
QTreeWidgetItem(self.treeWidget) self.tableWidget.setVerticalHeaderItem(1, __qtablewidgetitem4)
self.treeWidget.setObjectName(u"treeWidget") __qtablewidgetitem5 = QTableWidgetItem()
self.treeWidget.setGeometry(QRect(40, 0, 256, 192)) self.tableWidget.setItem(0, 0, __qtablewidgetitem5)
self.treeWidget.setStyleSheet(u"") __qtablewidgetitem6 = QTableWidgetItem()
self.treeWidget.header().setVisible(False) self.tableWidget.setItem(0, 1, __qtablewidgetitem6)
__qtablewidgetitem7 = QTableWidgetItem()
self.tableWidget.setItem(0, 2, __qtablewidgetitem7)
__qtablewidgetitem8 = QTableWidgetItem()
self.tableWidget.setItem(1, 0, __qtablewidgetitem8)
__qtablewidgetitem9 = QTableWidgetItem()
self.tableWidget.setItem(1, 1, __qtablewidgetitem9)
__qtablewidgetitem10 = QTableWidgetItem()
self.tableWidget.setItem(1, 2, __qtablewidgetitem10)
self.tableWidget.setObjectName(u"tableWidget")
self.tableWidget.setGeometry(QRect(50, 20, 611, 91))
self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.tableWidget.setTabKeyNavigation(True)
self.tableWidget.setAlternatingRowColors(True)
self.tableWidget.setSelectionMode(QAbstractItemView.SingleSelection)
self.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
self.tableWidget.horizontalHeader().setCascadingSectionResizes(True)
self.tableWidget.horizontalHeader().setHighlightSections(False)
self.tableWidget.horizontalHeader().setProperty("showSortIndicator", True)
self.tableWidget.horizontalHeader().setStretchLastSection(True)
self.tableWidget.verticalHeader().setVisible(False)
self.tableWidget.verticalHeader().setHighlightSections(False)
self.gridLayout.addWidget(self.frame_12, 0, 0, 1, 1) self.gridLayout.addWidget(self.frame_12, 0, 0, 1, 1)
@ -622,7 +643,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents = QWidget()
self.scrollAreaWidgetContents.setObjectName( self.scrollAreaWidgetContents.setObjectName(
u"scrollAreaWidgetContents") u"scrollAreaWidgetContents")
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 656, 551)) self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 741, 550))
self.scrollAreaWidgetContents.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n" self.scrollAreaWidgetContents.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
"}") "}")
@ -657,7 +678,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_4 = QWidget() self.scrollAreaWidgetContents_4 = QWidget()
self.scrollAreaWidgetContents_4.setObjectName( self.scrollAreaWidgetContents_4.setObjectName(
u"scrollAreaWidgetContents_4") u"scrollAreaWidgetContents_4")
self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 656, 551)) self.scrollAreaWidgetContents_4.setGeometry(QRect(0, 0, 741, 550))
self.scrollAreaWidgetContents_4.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n" self.scrollAreaWidgetContents_4.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
"}") "}")
@ -713,7 +734,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_5 = QWidget() self.scrollAreaWidgetContents_5 = QWidget()
self.scrollAreaWidgetContents_5.setObjectName( self.scrollAreaWidgetContents_5.setObjectName(
u"scrollAreaWidgetContents_5") u"scrollAreaWidgetContents_5")
self.scrollAreaWidgetContents_5.setGeometry(QRect(0, 0, 656, 551)) self.scrollAreaWidgetContents_5.setGeometry(QRect(0, 0, 741, 550))
self.scrollAreaWidgetContents_5.setMinimumSize(QSize(600, 0)) self.scrollAreaWidgetContents_5.setMinimumSize(QSize(600, 0))
self.scrollAreaWidgetContents_5.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n" self.scrollAreaWidgetContents_5.setStyleSheet(u"QFrame#frame_engine, QFrame#frame_modelOptions {\n"
" background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n" " background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0.221409, y2:0.587, stop:0.119318 rgba(85, 78, 163, 255), stop:0.683616 rgba(0, 0, 0, 0));\n"
@ -741,7 +762,7 @@ class Ui_SettingsWindow(object):
self.frame_5.setFrameShape(QFrame.NoFrame) self.frame_5.setFrameShape(QFrame.NoFrame)
self.frame_5.setFrameShadow(QFrame.Raised) self.frame_5.setFrameShadow(QFrame.Raised)
self.horizontalLayout_6 = QHBoxLayout(self.frame_5) self.horizontalLayout_6 = QHBoxLayout(self.frame_5)
self.horizontalLayout_6.setSpacing(45) self.horizontalLayout_6.setSpacing(35)
self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
self.frame_6 = QFrame(self.frame_5) self.frame_6 = QFrame(self.frame_5)
@ -1137,7 +1158,7 @@ class Ui_SettingsWindow(object):
self.stackedWidget.setCurrentIndex(0) self.stackedWidget.setCurrentIndex(0)
self.comboBox_highEndProcess.setCurrentIndex(4) self.comboBox_highEndProcess.setCurrentIndex(4)
self.comboBox_winSize.setCurrentIndex(0) self.comboBox_winSize.setCurrentIndex(0)
self.models_stackedWidget.setCurrentIndex(0) self.models_stackedWidget.setCurrentIndex(1)
self.pushButton_de.setDefault(False) self.pushButton_de.setDefault(False)
self.pushButton_en.setDefault(False) self.pushButton_en.setDefault(False)
@ -1203,36 +1224,43 @@ class Ui_SettingsWindow(object):
"SettingsWindow", u"Instrumental Model", None)) "SettingsWindow", u"Instrumental Model", None))
self.label_4.setText(QCoreApplication.translate( self.label_4.setText(QCoreApplication.translate(
"SettingsWindow", u"Vocal Model", None)) "SettingsWindow", u"Vocal Model", None))
self.label_9.setText(QCoreApplication.translate( ___qtablewidgetitem = self.tableWidget.horizontalHeaderItem(0)
"SettingsWindow", u"Ensemble Page", None)) ___qtablewidgetitem.setText(
___qtreewidgetitem = self.treeWidget.headerItem() QCoreApplication.translate("SettingsWindow", u"Type", None))
___qtreewidgetitem.setText( ___qtablewidgetitem1 = self.tableWidget.horizontalHeaderItem(1)
0, QCoreApplication.translate("SettingsWindow", u"1", None)) ___qtablewidgetitem1.setText(
QCoreApplication.translate("SettingsWindow", u"Name", None))
___qtablewidgetitem2 = self.tableWidget.horizontalHeaderItem(2)
___qtablewidgetitem2.setText(QCoreApplication.translate(
"SettingsWindow", u"Description", None))
___qtablewidgetitem3 = self.tableWidget.verticalHeaderItem(0)
___qtablewidgetitem3.setText(QCoreApplication.translate(
"SettingsWindow", u"1234567", None))
___qtablewidgetitem4 = self.tableWidget.verticalHeaderItem(1)
___qtablewidgetitem4.setText(QCoreApplication.translate(
"SettingsWindow", u"2353426", None))
__sortingEnabled = self.treeWidget.isSortingEnabled() __sortingEnabled = self.tableWidget.isSortingEnabled()
self.treeWidget.setSortingEnabled(False) self.tableWidget.setSortingEnabled(False)
___qtreewidgetitem1 = self.treeWidget.topLevelItem(0) ___qtablewidgetitem5 = self.tableWidget.item(0, 0)
___qtreewidgetitem1.setText(0, QCoreApplication.translate( ___qtablewidgetitem5.setText(
QCoreApplication.translate("SettingsWindow", u"Vocal", None))
___qtablewidgetitem6 = self.tableWidget.item(0, 1)
___qtablewidgetitem6.setText(QCoreApplication.translate(
"SettingsWindow", u"VOCALMODELV5", None))
___qtablewidgetitem7 = self.tableWidget.item(0, 2)
___qtablewidgetitem7.setText(QCoreApplication.translate(
"SettingsWindow", u"My Vocal Model", None))
___qtablewidgetitem8 = self.tableWidget.item(1, 0)
___qtablewidgetitem8.setText(QCoreApplication.translate(
"SettingsWindow", u"Instrumental", None)) "SettingsWindow", u"Instrumental", None))
___qtreewidgetitem2 = ___qtreewidgetitem1.child(0) ___qtablewidgetitem9 = self.tableWidget.item(1, 1)
___qtreewidgetitem2.setText(0, QCoreApplication.translate( ___qtablewidgetitem9.setText(QCoreApplication.translate(
"SettingsWindow", u"Model 1", None)) "SettingsWindow", u"INSTRUMENTALMODEL", None))
___qtreewidgetitem3 = ___qtreewidgetitem1.child(1) ___qtablewidgetitem10 = self.tableWidget.item(1, 2)
___qtreewidgetitem3.setText(0, QCoreApplication.translate( ___qtablewidgetitem10.setText(QCoreApplication.translate(
"SettingsWindow", u"Model 2", None)) "SettingsWindow", u"My Instrumental best model", None))
___qtreewidgetitem4 = self.treeWidget.topLevelItem(1) self.tableWidget.setSortingEnabled(__sortingEnabled)
___qtreewidgetitem4.setText(
0, QCoreApplication.translate("SettingsWindow", u"Vocal", None))
___qtreewidgetitem5 = ___qtreewidgetitem4.child(0)
___qtreewidgetitem5.setText(0, QCoreApplication.translate(
"SettingsWindow", u"Vocal Model 1", None))
___qtreewidgetitem6 = ___qtreewidgetitem4.child(1)
___qtreewidgetitem6.setText(0, QCoreApplication.translate(
"SettingsWindow", u"Vocal Model 2", None))
___qtreewidgetitem7 = self.treeWidget.topLevelItem(2)
___qtreewidgetitem7.setText(0, QCoreApplication.translate(
"SettingsWindow", u"Custom", None))
self.treeWidget.setSortingEnabled(__sortingEnabled)
self.label_6.setText(QCoreApplication.translate( self.label_6.setText(QCoreApplication.translate(
"SettingsWindow", u"Themes", None)) "SettingsWindow", u"Themes", None))

View File

@ -6,6 +6,7 @@ from PySide2 import QtCore
from PySide2 import QtGui from PySide2 import QtGui
from PySide2.QtGui import Qt from PySide2.QtGui import Qt
# -Root imports- # -Root imports-
from ..resources.models.modelmanager import ModelManager
from ..inference.lib.model_param_init import ModelParameters from ..inference.lib.model_param_init import ModelParameters
from ..resources.resources_manager import ResourcePaths from ..resources.resources_manager import ResourcePaths
from ..app import CustomApplication from ..app import CustomApplication
@ -51,6 +52,7 @@ class SettingsWindow(QtWidgets.QWidget):
2: self.update_page_customization, 2: self.update_page_customization,
3: self.update_page_preferences, 3: self.update_page_preferences,
} }
self.modelmanager = ModelManager()
# Independent data # Independent data
self.exportDirectory = self.settings.value('user/exportDirectory', self.exportDirectory = self.settings.value('user/exportDirectory',
const.DEFAULT_SETTINGS['exportDirectory'], const.DEFAULT_SETTINGS['exportDirectory'],
@ -384,8 +386,6 @@ class SettingsWindow(QtWidgets.QWidget):
# -Before setup- # -Before setup-
self.search_for_preset = False self.search_for_preset = False
# Update available model lists
self._update_selectable_models()
# Open settings window on startup # Open settings window on startup
open_settings = self.settings.value('settingswindow/checkBox_settingsStartup', open_settings = self.settings.value('settingswindow/checkBox_settingsStartup',
const.DEFAULT_SETTINGS['checkBox_settingsStartup'], const.DEFAULT_SETTINGS['checkBox_settingsStartup'],
@ -410,11 +410,13 @@ class SettingsWindow(QtWidgets.QWidget):
# Load menu (Preferences) # Load menu (Preferences)
self.update_window() self.update_window()
self.menu_loadPage(0, True) self.menu_loadPage(0, True)
self.search_for_preset = True
if not torch.cuda.is_available(): if not torch.cuda.is_available():
self.ui.checkBox_gpuConversion.setEnabled(False) self.ui.checkBox_gpuConversion.setEnabled(False)
self.ui.checkBox_gpuConversion.setChecked(False) self.ui.checkBox_gpuConversion.setChecked(False)
self.ui.checkBox_gpuConversion.setToolTip("CUDA is not available on your system") self.ui.checkBox_gpuConversion.setToolTip("CUDA is not available on your system")
self.modelmanager.set_callback(self.changed_available_models)
self.modelmanager.search_for_models(force_callback=True)
self.search_for_preset = True
self.logger.indent_backwards() self.logger.indent_backwards()
def load_window(self): def load_window(self):
@ -479,54 +481,42 @@ class SettingsWindow(QtWidgets.QWidget):
self.logger.indent_backwards() self.logger.indent_backwards()
def _update_selectable_models(self): def changed_available_models(self):
""" """
Update the list of models to select from in the Update the list of models to select from in the
seperation settings page based on the selected AI Engine seperation settings page based on the selected AI Engine
""" """
def get_model_id(path: str) -> str: print(self.modelmanager.available_models)
buffer_size = 65536 # def fill_model_comboBox(widget: QtWidgets.QComboBox, folder: str):
sha1 = hashlib.sha1() # """
# Fill the combobox for the model
# """
# currently_selected_model_name = widget.currentText()
# widget.clear()
# for index, f in enumerate(os.listdir(folder)):
# if not f.endswith('.pth'):
# # File is not a model file, so skip
# continue
# # Get data
# full_path = os.path.join(folder, f)
# model_id = get_model_id(full_path)
# model_name = os.path.splitext(os.path.basename(f))[0]
# # Add item to combobox
# widget.addItem(model_name,
# {
# 'path': full_path,
# 'id': model_id
# })
# if model_name == currently_selected_model_name:
# # This model was selected before clearing the
# # QComboBox, so reselect
# widget.setCurrentIndex(index)
with open(path, 'rb') as f: # # Fill Comboboxes
while True: # fill_model_comboBox(widget=self.ui.comboBox_instrumental,
data = f.read(buffer_size) # folder=ResourcePaths.instrumentalModelsDir)
if not data: # fill_model_comboBox(widget=self.ui.comboBox_vocal,
break # folder=ResourcePaths.vocalModelsDir)
sha1.update(data)
return sha1.hexdigest()
def fill_model_comboBox(widget: QtWidgets.QComboBox, folder: str):
"""
Fill the combobox for the model
"""
currently_selected_model_name = widget.currentText()
widget.clear()
for index, f in enumerate(os.listdir(folder)):
if not f.endswith('.pth'):
# File is not a model file, so skip
continue
# Get data
full_path = os.path.join(folder, f)
model_id = get_model_id(full_path)
model_name = os.path.splitext(os.path.basename(f))[0]
# Add item to combobox
widget.addItem(model_name,
{
'path': full_path,
'id': model_id
})
if model_name == currently_selected_model_name:
# This model was selected before clearing the
# QComboBox, so reselect
widget.setCurrentIndex(index)
# Fill Comboboxes
fill_model_comboBox(widget=self.ui.comboBox_instrumental,
folder=ResourcePaths.instrumentalModelsDir)
fill_model_comboBox(widget=self.ui.comboBox_vocal,
folder=ResourcePaths.vocalModelsDir)
# Custom Models Page # Custom Models Page
def update_page_customModels(self): def update_page_customModels(self):
@ -767,7 +757,7 @@ class SettingsManager:
value = widget.currentText() value = widget.currentText()
elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or
isinstance(widget, QtWidgets.QSpinBox)): isinstance(widget, QtWidgets.QSpinBox)):
value = widget.value() value = round(widget.value(), 2)
else: else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget) raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
@ -825,7 +815,7 @@ class SettingsManager:
widget.setCurrentIndex(i) widget.setCurrentIndex(i)
elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or
isinstance(widget, QtWidgets.QSpinBox)): isinstance(widget, QtWidgets.QSpinBox)):
widget.setValue(value) widget.setValue(round(value, 2))
else: else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget) raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
self.win.update_window() self.win.update_window()
@ -838,6 +828,7 @@ class SettingsManager:
""" """
# Before # Before
self.win.logger.info('Settings: Loading window') self.win.logger.info('Settings: Loading window')
settings: Dict[str, Union[bool, str, float]] = {}
# -Load states- # -Load states-
self.win.settings.beginGroup('settingswindow') self.win.settings.beginGroup('settingswindow')
for widget in self.get_widgets(): for widget in self.get_widgets():
@ -855,35 +846,23 @@ class SettingsManager:
value = self.win.settings.value(widget_objectName, value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName], defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=bool) type=bool)
widget.setChecked(value)
elif isinstance(widget, QtWidgets.QLineEdit): elif isinstance(widget, QtWidgets.QLineEdit):
value = self.win.settings.value(widget_objectName, value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName], defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=str) type=str)
widget.setText(value)
elif isinstance(widget, QtWidgets.QComboBox): elif isinstance(widget, QtWidgets.QComboBox):
value = self.win.settings.value(widget_objectName, value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName], defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=str) type=str)
if widget.isEditable():
# Allows self-typing
widget.setCurrentText(value)
else:
# Only allows a list to choose from
all_items = [widget.itemText(i) for i in range(widget.count())]
for i, item in enumerate(all_items):
if item == value:
# Both have the same text
widget.setCurrentIndex(i)
elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or
isinstance(widget, QtWidgets.QSpinBox)): isinstance(widget, QtWidgets.QSpinBox)):
value = self.win.settings.value(widget_objectName, value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName], defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=float) type=float)
widget.setValue(value)
else: else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget) raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
settings[widget_objectName] = value
self.set_settings(settings)
self.win.settings.endGroup() self.win.settings.endGroup()
def save_window(self): def save_window(self):

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>941</width> <width>941</width>
<height>551</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -288,7 +288,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>741</width> <width>741</width>
<height>551</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -356,7 +356,7 @@
<widget class="QFrame" name="horizontalFrame_1"> <widget class="QFrame" name="horizontalFrame_1">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="5,2"> <layout class="QHBoxLayout" name="horizontalLayout_4" stretch="5,2">
<property name="spacing"> <property name="spacing">
<number>45</number> <number>35</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -471,7 +471,7 @@
<property name="settingsContent" stdset="0"> <property name="settingsContent" stdset="0">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0">
<property name="leftMargin"> <property name="leftMargin">
<number>20</number> <number>20</number>
</property> </property>
@ -1094,12 +1094,12 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<property name="settingsContent" stdset="0"> <property name="settingsContent" stdset="0">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="models_stackedWidget_page_1" native="true"> <widget class="QWidget" name="models_stackedWidget_page_1">
<layout class="QGridLayout" name="gridLayout_18" rowstretch="0"> <layout class="QGridLayout" name="gridLayout_18" rowstretch="0">
<property name="leftMargin"> <property name="leftMargin">
<number>20</number> <number>20</number>
@ -1285,84 +1285,101 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<widget class="QLabel" name="label_9"> <widget class="QTableWidget" name="tableWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>350</x> <x>50</x>
<y>30</y> <y>20</y>
<width>151</width> <width>611</width>
<height>31</height> <height>91</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="editTriggers">
<string>Ensemble Page</string> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
</widget> <property name="tabKeyNavigation">
<widget class="QTreeWidget" name="treeWidget"> <bool>true</bool>
<property name="geometry">
<rect>
<x>40</x>
<y>0</y>
<width>256</width>
<height>192</height>
</rect>
</property> </property>
<property name="styleSheet"> <property name="alternatingRowColors">
<string notr="true"/> <bool>true</bool>
</property> </property>
<attribute name="headerVisible"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<row>
<property name="text">
<string>1234567</string>
</property>
</row>
<row>
<property name="text">
<string>2353426</string>
</property>
</row>
<column> <column>
<property name="text"> <property name="text">
<string>1</string> <string>Type</string>
</property> </property>
</column> </column>
<item> <column>
<property name="text"> <property name="text">
<string>Instrumental</string> <string>Name</string>
</property> </property>
<item> </column>
<property name="text"> <column>
<string>Model 1</string> <property name="text">
</property> <string>Description</string>
<property name="checkState"> </property>
<enum>Checked</enum> </column>
</property> <item row="0" column="0">
</item>
<item>
<property name="text">
<string>Model 2</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
</item>
</item>
<item>
<property name="text"> <property name="text">
<string>Vocal</string> <string>Vocal</string>
</property> </property>
<item>
<property name="text">
<string>Vocal Model 1</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
</item>
<item>
<property name="text">
<string>Vocal Model 2</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
</item>
</item> </item>
<item> <item row="0" column="1">
<property name="text"> <property name="text">
<string>Custom</string> <string>VOCALMODELV5</string>
</property>
</item>
<item row="0" column="2">
<property name="text">
<string>My Vocal Model</string>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string>Instrumental</string>
</property>
</item>
<item row="1" column="1">
<property name="text">
<string>INSTRUMENTALMODEL</string>
</property>
</item>
<item row="1" column="2">
<property name="text">
<string>My Instrumental best model</string>
</property> </property>
</item> </item>
</widget> </widget>
@ -1420,8 +1437,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>656</width> <width>741</width>
<height>551</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -1497,8 +1514,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>656</width> <width>741</width>
<height>551</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -1622,8 +1639,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>656</width> <width>741</width>
<height>551</height> <height>550</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -1693,7 +1710,7 @@
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0"> <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0">
<property name="spacing"> <property name="spacing">
<number>45</number> <number>35</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>