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
'aggressiveness': 'doubleSpinBox_aggressiveness',
'highEndProcess': 'comboBox_highEndProcess',
'windowSize': 'comboBox_winSize',
# -Models-
'ensemble': 'checkBox_ensemble',
'instrumentalModelName': 'comboBox_instrumental',
'vocalModelName': 'comboBox_vocal',
'windowSize': 'comboBox_winSize',
})
DEFAULT_SETTINGS = {
# --Independent Data (Data not directly connected with widgets)--
@ -54,11 +55,12 @@ DEFAULT_SETTINGS = {
'outputImage': True,
'modelFolder': True,
'deepExtraction': True,
'windowSize': 1024,
# Number
'aggressiveness': 0.1,
'highEndProcess': 'Bypass',
# -Models-
'windowSize': 1024,
'ensemble': True,
}],
['NONE', {
# -Conversion-
@ -68,11 +70,12 @@ DEFAULT_SETTINGS = {
'outputImage': False,
'modelFolder': False,
'deepExtraction': False,
'windowSize': 352,
# Number
'aggressiveness': -0.1,
'highEndProcess': 'Mirroring',
# -Models-
'windowSize': 352,
'ensemble': False,
}]
],
# 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]
size=@Size(1028 551)
pos=@Point(585 245)
size=@Size(941 550)
pos=@Point(274 296)
checkBox_gpuConversion=false
checkBox_tta=false
checkBox_modelFolder=false
checkBox_outputImage=false
checkBox_postProcess=false
checkBox_deepExtraction=false
comboBox_winSize=352
comboBox_highEndProcess=Mirroring
doubleSpinBox_aggressiveness=-0.1
checkBox_tta=true
checkBox_modelFolder=true
checkBox_outputImage=true
checkBox_postProcess=true
checkBox_deepExtraction=true
comboBox_winSize=1024
comboBox_highEndProcess=Bypass
doubleSpinBox_aggressiveness=0.1
checkBox_ensemble=false
comboBox_instrumental=MGM-v5-2Band-32000-BETA1 - Kopie
comboBox_instrumental=
comboBox_vocal=
comboBox_presets=NONE
comboBox_presets=Custom
checkBox_notifiyOnFinish=false
checkBox_notifyUpdates=true
checkBox_settingsStartup=false
checkBox_settingsStartup=true
checkBox_enableAnimations=true
checkBox_showInfoButtons=false
checkBox_showInfoButtons=true
checkBox_multithreading=false
comboBox_command=Off
checkBox_autoSaveInstrumentals=true
@ -29,17 +29,12 @@ exportDirectory=C:/Users/boska/Desktop
language=en
inputPaths=@Invalid()
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_saveDir=C:/Users/boska/Desktop
theme=dark
[mainwindow]
size=@Size(906 559)
pos=@Point(503 220)
isMaximized=false
[infowindow]
size=@Size(596 440)
pos=@Point(662 204)
pos=@Point(507 260)
isMaximized=false

View File

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

View File

@ -18,7 +18,7 @@ class Ui_SettingsWindow(object):
if not SettingsWindow.objectName():
SettingsWindow.setObjectName(u"SettingsWindow")
SettingsWindow.setEnabled(True)
SettingsWindow.resize(941, 551)
SettingsWindow.resize(941, 550)
SettingsWindow.setStyleSheet(u"")
self.horizontalLayout = QHBoxLayout(SettingsWindow)
self.horizontalLayout.setSpacing(0)
@ -134,7 +134,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents_2 = QWidget()
self.scrollAreaWidgetContents_2.setObjectName(
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.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
@ -164,7 +164,7 @@ class Ui_SettingsWindow(object):
self.horizontalFrame_1 = QFrame(self.frame_3)
self.horizontalFrame_1.setObjectName(u"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.setContentsMargins(0, 0, 0, 0)
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.setFrameShape(QFrame.NoFrame)
self.frame_12.setFrameShadow(QFrame.Raised)
self.label_9 = QLabel(self.frame_12)
self.label_9.setObjectName(u"label_9")
self.label_9.setGeometry(QRect(350, 30, 151, 31))
self.treeWidget = QTreeWidget(self.frame_12)
__qtreewidgetitem = QTreeWidgetItem(self.treeWidget)
__qtreewidgetitem1 = QTreeWidgetItem(__qtreewidgetitem)
__qtreewidgetitem1.setCheckState(0, Qt.Checked)
__qtreewidgetitem2 = QTreeWidgetItem(__qtreewidgetitem)
__qtreewidgetitem2.setCheckState(0, Qt.Unchecked)
__qtreewidgetitem3 = QTreeWidgetItem(self.treeWidget)
__qtreewidgetitem4 = QTreeWidgetItem(__qtreewidgetitem3)
__qtreewidgetitem4.setCheckState(0, Qt.Unchecked)
__qtreewidgetitem5 = QTreeWidgetItem(__qtreewidgetitem3)
__qtreewidgetitem5.setCheckState(0, Qt.Unchecked)
QTreeWidgetItem(self.treeWidget)
self.treeWidget.setObjectName(u"treeWidget")
self.treeWidget.setGeometry(QRect(40, 0, 256, 192))
self.treeWidget.setStyleSheet(u"")
self.treeWidget.header().setVisible(False)
self.tableWidget = QTableWidget(self.frame_12)
if (self.tableWidget.columnCount() < 3):
self.tableWidget.setColumnCount(3)
__qtablewidgetitem = QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
__qtablewidgetitem1 = QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
__qtablewidgetitem2 = QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, __qtablewidgetitem2)
if (self.tableWidget.rowCount() < 2):
self.tableWidget.setRowCount(2)
__qtablewidgetitem3 = QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(0, __qtablewidgetitem3)
__qtablewidgetitem4 = QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(1, __qtablewidgetitem4)
__qtablewidgetitem5 = QTableWidgetItem()
self.tableWidget.setItem(0, 0, __qtablewidgetitem5)
__qtablewidgetitem6 = QTableWidgetItem()
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)
@ -622,7 +643,7 @@ class Ui_SettingsWindow(object):
self.scrollAreaWidgetContents = QWidget()
self.scrollAreaWidgetContents.setObjectName(
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"
" 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.setObjectName(
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"
" 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.setObjectName(
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.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"
@ -741,7 +762,7 @@ class Ui_SettingsWindow(object):
self.frame_5.setFrameShape(QFrame.NoFrame)
self.frame_5.setFrameShadow(QFrame.Raised)
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.setContentsMargins(0, 0, 0, 0)
self.frame_6 = QFrame(self.frame_5)
@ -1137,7 +1158,7 @@ class Ui_SettingsWindow(object):
self.stackedWidget.setCurrentIndex(0)
self.comboBox_highEndProcess.setCurrentIndex(4)
self.comboBox_winSize.setCurrentIndex(0)
self.models_stackedWidget.setCurrentIndex(0)
self.models_stackedWidget.setCurrentIndex(1)
self.pushButton_de.setDefault(False)
self.pushButton_en.setDefault(False)
@ -1203,36 +1224,43 @@ class Ui_SettingsWindow(object):
"SettingsWindow", u"Instrumental Model", None))
self.label_4.setText(QCoreApplication.translate(
"SettingsWindow", u"Vocal Model", None))
self.label_9.setText(QCoreApplication.translate(
"SettingsWindow", u"Ensemble Page", None))
___qtreewidgetitem = self.treeWidget.headerItem()
___qtreewidgetitem.setText(
0, QCoreApplication.translate("SettingsWindow", u"1", None))
___qtablewidgetitem = self.tableWidget.horizontalHeaderItem(0)
___qtablewidgetitem.setText(
QCoreApplication.translate("SettingsWindow", u"Type", None))
___qtablewidgetitem1 = self.tableWidget.horizontalHeaderItem(1)
___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()
self.treeWidget.setSortingEnabled(False)
___qtreewidgetitem1 = self.treeWidget.topLevelItem(0)
___qtreewidgetitem1.setText(0, QCoreApplication.translate(
__sortingEnabled = self.tableWidget.isSortingEnabled()
self.tableWidget.setSortingEnabled(False)
___qtablewidgetitem5 = self.tableWidget.item(0, 0)
___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))
___qtreewidgetitem2 = ___qtreewidgetitem1.child(0)
___qtreewidgetitem2.setText(0, QCoreApplication.translate(
"SettingsWindow", u"Model 1", None))
___qtreewidgetitem3 = ___qtreewidgetitem1.child(1)
___qtreewidgetitem3.setText(0, QCoreApplication.translate(
"SettingsWindow", u"Model 2", None))
___qtreewidgetitem4 = self.treeWidget.topLevelItem(1)
___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)
___qtablewidgetitem9 = self.tableWidget.item(1, 1)
___qtablewidgetitem9.setText(QCoreApplication.translate(
"SettingsWindow", u"INSTRUMENTALMODEL", None))
___qtablewidgetitem10 = self.tableWidget.item(1, 2)
___qtablewidgetitem10.setText(QCoreApplication.translate(
"SettingsWindow", u"My Instrumental best model", None))
self.tableWidget.setSortingEnabled(__sortingEnabled)
self.label_6.setText(QCoreApplication.translate(
"SettingsWindow", u"Themes", None))

View File

@ -6,6 +6,7 @@ from PySide2 import QtCore
from PySide2 import QtGui
from PySide2.QtGui import Qt
# -Root imports-
from ..resources.models.modelmanager import ModelManager
from ..inference.lib.model_param_init import ModelParameters
from ..resources.resources_manager import ResourcePaths
from ..app import CustomApplication
@ -51,6 +52,7 @@ class SettingsWindow(QtWidgets.QWidget):
2: self.update_page_customization,
3: self.update_page_preferences,
}
self.modelmanager = ModelManager()
# Independent data
self.exportDirectory = self.settings.value('user/exportDirectory',
const.DEFAULT_SETTINGS['exportDirectory'],
@ -384,8 +386,6 @@ class SettingsWindow(QtWidgets.QWidget):
# -Before setup-
self.search_for_preset = False
# Update available model lists
self._update_selectable_models()
# Open settings window on startup
open_settings = self.settings.value('settingswindow/checkBox_settingsStartup',
const.DEFAULT_SETTINGS['checkBox_settingsStartup'],
@ -410,11 +410,13 @@ class SettingsWindow(QtWidgets.QWidget):
# Load menu (Preferences)
self.update_window()
self.menu_loadPage(0, True)
self.search_for_preset = True
if not torch.cuda.is_available():
self.ui.checkBox_gpuConversion.setEnabled(False)
self.ui.checkBox_gpuConversion.setChecked(False)
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()
def load_window(self):
@ -479,54 +481,42 @@ class SettingsWindow(QtWidgets.QWidget):
self.logger.indent_backwards()
def _update_selectable_models(self):
def changed_available_models(self):
"""
Update the list of models to select from in the
seperation settings page based on the selected AI Engine
"""
def get_model_id(path: str) -> str:
buffer_size = 65536
sha1 = hashlib.sha1()
print(self.modelmanager.available_models)
# 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)
with open(path, 'rb') as f:
while True:
data = f.read(buffer_size)
if not data:
break
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)
# # 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
def update_page_customModels(self):
@ -767,7 +757,7 @@ class SettingsManager:
value = widget.currentText()
elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or
isinstance(widget, QtWidgets.QSpinBox)):
value = widget.value()
value = round(widget.value(), 2)
else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
@ -825,7 +815,7 @@ class SettingsManager:
widget.setCurrentIndex(i)
elif (isinstance(widget, QtWidgets.QDoubleSpinBox) or
isinstance(widget, QtWidgets.QSpinBox)):
widget.setValue(value)
widget.setValue(round(value, 2))
else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
self.win.update_window()
@ -838,6 +828,7 @@ class SettingsManager:
"""
# Before
self.win.logger.info('Settings: Loading window')
settings: Dict[str, Union[bool, str, float]] = {}
# -Load states-
self.win.settings.beginGroup('settingswindow')
for widget in self.get_widgets():
@ -855,35 +846,23 @@ class SettingsManager:
value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=bool)
widget.setChecked(value)
elif isinstance(widget, QtWidgets.QLineEdit):
value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=str)
widget.setText(value)
elif isinstance(widget, QtWidgets.QComboBox):
value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
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
isinstance(widget, QtWidgets.QSpinBox)):
value = self.win.settings.value(widget_objectName,
defaultValue=const.DEFAULT_SETTINGS[widget_objectName],
type=float)
widget.setValue(value)
else:
raise TypeError('Invalid widget type that is not supported!\nWidget: ', widget)
settings[widget_objectName] = value
self.set_settings(settings)
self.win.settings.endGroup()
def save_window(self):

View File

@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>941</width>
<height>551</height>
<height>550</height>
</rect>
</property>
<property name="windowTitle">
@ -288,7 +288,7 @@
<x>0</x>
<y>0</y>
<width>741</width>
<height>551</height>
<height>550</height>
</rect>
</property>
<property name="sizePolicy">
@ -356,7 +356,7 @@
<widget class="QFrame" name="horizontalFrame_1">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="5,2">
<property name="spacing">
<number>45</number>
<number>35</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -471,7 +471,7 @@
<property name="settingsContent" stdset="0">
<bool>true</bool>
</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">
<number>20</number>
</property>
@ -1094,12 +1094,12 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="settingsContent" stdset="0">
<bool>true</bool>
</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">
<property name="leftMargin">
<number>20</number>
@ -1285,84 +1285,101 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label_9">
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>350</x>
<y>30</y>
<width>151</width>
<height>31</height>
<x>50</x>
<y>20</y>
<width>611</width>
<height>91</height>
</rect>
</property>
<property name="text">
<string>Ensemble Page</string>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<widget class="QTreeWidget" name="treeWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>0</y>
<width>256</width>
<height>192</height>
</rect>
<property name="tabKeyNavigation">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
<property name="alternatingRowColors">
<bool>true</bool>
</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>
</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>
<property name="text">
<string>1</string>
<string>Type</string>
</property>
</column>
<item>
<column>
<property name="text">
<string>Instrumental</string>
<string>Name</string>
</property>
<item>
<property name="text">
<string>Model 1</string>
</property>
<property name="checkState">
<enum>Checked</enum>
</property>
</item>
<item>
<property name="text">
<string>Model 2</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
</item>
</item>
<item>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<item row="0" column="0">
<property name="text">
<string>Vocal</string>
</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 row="0" column="1">
<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>
</item>
</widget>
@ -1420,8 +1437,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<height>551</height>
<width>741</width>
<height>550</height>
</rect>
</property>
<property name="styleSheet">
@ -1497,8 +1514,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<height>551</height>
<width>741</width>
<height>550</height>
</rect>
</property>
<property name="styleSheet">
@ -1622,8 +1639,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>656</width>
<height>551</height>
<width>741</width>
<height>550</height>
</rect>
</property>
<property name="minimumSize">
@ -1693,7 +1710,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0">
<property name="spacing">
<number>45</number>
<number>35</number>
</property>
<property name="leftMargin">
<number>0</number>