diff --git a/.gitignore b/.gitignore index 454625e..b7e99e2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ cudnn_windows build wd14_tagger_model .DS_Store -locon \ No newline at end of file +locon +gui-user.bat +gui-user.ps1 diff --git a/gui.ps1 b/gui.ps1 index 81b43a0..349ce97 100644 --- a/gui.ps1 +++ b/gui.ps1 @@ -4,7 +4,14 @@ # Validate the requirements and store the exit code python.exe .\tools\validate_requirements.py -# If the exit code is 0, run the kohya_gui.py script with the command-line arguments +# If the exit code is 0, read arguments from gui_parameters.txt (if it exists) +# and run the kohya_gui.py script with the command-line arguments if ($LASTEXITCODE -eq 0) { - python.exe kohya_gui.py $args -} \ No newline at end of file + $argsFromFile = @() + if (Test-Path .\gui_parameters.txt) { + $argsFromFile = Get-Content .\gui_parameters.txt -Encoding UTF8 | Where-Object { $_ -notmatch "^#" } | Foreach-Object { $_ -split " " } + } + $args_combo = $argsFromFile + $args + Write-Host "The arguments passed to this script were: $args_combo" + python.exe kohya_gui.py $args_combo +} diff --git a/setup.py b/setup.py index 55fe23b..8aa7c07 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,10 @@ from setuptools import setup, find_packages - -setup(name = "library", version="1.0.2", packages = find_packages()) \ No newline at end of file +import subprocess +import os +import sys + +# Call the create_user_files.py script +script_path = os.path.join("tools", "create_user_files.py") +subprocess.run([sys.executable, script_path]) + +setup(name="library", version="1.0.3", packages=find_packages()) diff --git a/tools/create_user_files.py b/tools/create_user_files.py new file mode 100644 index 0000000..9c3d003 --- /dev/null +++ b/tools/create_user_files.py @@ -0,0 +1,37 @@ +import os + +bat_content = r'''@echo off +REM Example of how to start the GUI with custom arguments. In this case how to auto launch the browser: +REM call gui.bat --inbrowser +REM +REM You can add many arguments on the same line +REM +call gui.bat --inbrowser +''' + +ps1_content = r'''# Example of how to start the GUI with custom arguments. In this case how to auto launch the browser: +# .\gui.ps1 --inbrowser +# +# You can add many arguments on the same line +# +# & .\gui.ps1 --inbrowser --server_port 2345 + +& .\gui.ps1 --inbrowser +''' + +bat_filename = 'gui-user.bat' +ps1_filename = 'gui-user.ps1' + +if not os.path.exists(bat_filename): + with open(bat_filename, 'w') as bat_file: + bat_file.write(bat_content) + print(f"File created: {bat_filename}") +else: + print(f"File already exists: {bat_filename}") + +if not os.path.exists(ps1_filename): + with open(ps1_filename, 'w') as ps1_file: + ps1_file.write(ps1_content) + print(f"File created: {ps1_filename}") +else: + print(f"File already exists: {ps1_filename}")