Merge pull request #509 from jstayco/fixed_git_clone

Small fix to default to pre-existing git branch if detected in install script
This commit is contained in:
bmaltais 2023-04-01 16:01:41 -04:00 committed by GitHub
commit 79b99f1085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 13 deletions

View File

@ -219,7 +219,7 @@ This will store your a backup file with your current locally installed pip packa
- Fix an issue that images are loaded twice in Windows environment. - Fix an issue that images are loaded twice in Windows environment.
- Add Min-SNR Weighting strategy. Details are in [#308](https://github.com/kohya-ss/sd-scripts/pull/308). Thank you to AI-Casanova for this great work! - Add Min-SNR Weighting strategy. Details are in [#308](https://github.com/kohya-ss/sd-scripts/pull/308). Thank you to AI-Casanova for this great work!
- Add `--min_snr_gamma` option to training scripts, 5 is recommended by paper. - Add `--min_snr_gamma` option to training scripts, 5 is recommended by paper.
- The Min SNR gamma fiels can be found unser the advanced training tab in all trainers. - The Min SNR gamma fields can be found under the advanced training tab in all trainers.
- Fixed the error while images are ended with capital image extensions. Thanks to @kvzn. https://github.com/bmaltais/kohya_ss/pull/454 - Fixed the error while images are ended with capital image extensions. Thanks to @kvzn. https://github.com/bmaltais/kohya_ss/pull/454
* 2023/03/26 (v21.3.5) * 2023/03/26 (v21.3.5)
- Fix for https://github.com/bmaltais/kohya_ss/issues/230 - Fix for https://github.com/bmaltais/kohya_ss/issues/230
@ -227,11 +227,11 @@ This will store your a backup file with your current locally installed pip packa
* 2023/03/25 (v21.3.4) * 2023/03/25 (v21.3.4)
- Added untested support for MacOS base on this gist: https://gist.github.com/jstayco/9f5733f05b9dc29de95c4056a023d645 - Added untested support for MacOS base on this gist: https://gist.github.com/jstayco/9f5733f05b9dc29de95c4056a023d645
Let me know how this work. From the look of it it appear to be well tought out. I modified a few things to make it fit better with the rest of the code in the repo. Let me know how this work. From the look of it it appears to be well-thought-out. I modified a few things to make it fit better with the rest of the code in the repo.
- Fix for issue https://github.com/bmaltais/kohya_ss/issues/433 by implementing default of 0. - Fix for issue https://github.com/bmaltais/kohya_ss/issues/433 by implementing default of 0.
- Removed non applicable save_model_as choices for LoRA and TI. - Removed non applicable save_model_as choices for LoRA and TI.
* 2023/03/24 (v21.3.3) * 2023/03/24 (v21.3.3)
- Add support for custom user gui files. THey will be created at installation time or when upgrading is missing. You will see two files in the root of the folder. One named `gui-user.bat` and the other `gui-user.ps1`. Edit the file based on your prefered terminal. Simply add the parameters you want to pass the gui in there and execute it to start the gui with them. Enjoy! - Add support for custom user gui files. THey will be created at installation time or when upgrading is missing. You will see two files in the root of the folder. One named `gui-user.bat` and the other `gui-user.ps1`. Edit the file based on your preferred terminal. Simply add the parameters you want to pass the gui in there and execute it to start the gui with them. Enjoy!
* 2023/03/23 (v21.3.2) * 2023/03/23 (v21.3.2)
- Fix issue reported: https://github.com/bmaltais/kohya_ss/issues/439 - Fix issue reported: https://github.com/bmaltais/kohya_ss/issues/439
* 2023/03/23 (v21.3.1) * 2023/03/23 (v21.3.1)

View File

@ -84,6 +84,7 @@ INTERACTIVE=false
PUBLIC=false PUBLIC=false
SKIP_SPACE_CHECK=false SKIP_SPACE_CHECK=false
SKIP_GIT_UPDATE=false SKIP_GIT_UPDATE=false
MANUAL_BRANCH_SWITCH=false
while getopts ":vb:d:g:inprs-:" opt; do while getopts ":vb:d:g:inprs-:" opt; do
# support long options: https://stackoverflow.com/a/28466267/519360 # support long options: https://stackoverflow.com/a/28466267/519360
@ -93,7 +94,7 @@ while getopts ":vb:d:g:inprs-:" opt; do
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=` OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi fi
case $opt in case $opt in
b | branch) BRANCH="$OPTARG" ;; b | branch) BRANCH="$OPTARG" && MANUAL_BRANCH_SWITCH=true ;;
d | dir) DIR="$OPTARG" ;; d | dir) DIR="$OPTARG" ;;
g | git-repo) GIT_REPO="$OPTARG" ;; g | git-repo) GIT_REPO="$OPTARG" ;;
i | interactive) INTERACTIVE=true ;; i | interactive) INTERACTIVE=true ;;
@ -342,20 +343,29 @@ update_kohya_ss() {
exit 1 exit 1
fi fi
echo "Attempting to clone $GIT_REPO." echo "Attempting to clone ${GIT_REPO}:${BRANCH}"
if [ ! -d "$DIR/.git" ]; then if [ ! -d "$DIR/.git" ]; then
echo "Cloning and switching to $GIT_REPO:$BRANCH" >&4
git -C "$PARENT_DIR" clone -b "$BRANCH" "$GIT_REPO" "$(basename "$DIR")" >&3 git -C "$PARENT_DIR" clone -b "$BRANCH" "$GIT_REPO" "$(basename "$DIR")" >&3
git -C "$DIR" switch "$BRANCH" >&4 git -C "$DIR" switch "$BRANCH" >&4
else else
echo "git repo detected. Attempting to update repository instead." echo "git repo detected. Attempting to update repository instead."
echo "Updating: $GIT_REPO" echo "Updating: $GIT_REPO"
if [ "$MANUAL_BRANCH_SWITCH" = false ]; then
git -C "$DIR" pull "$GIT_REPO" "$(git rev-parse --abbrev-ref HEAD)" >&3
else
git -C "$DIR" pull "$GIT_REPO" "$BRANCH" >&3 git -C "$DIR" pull "$GIT_REPO" "$BRANCH" >&3
fi
if [ "$MANUAL_BRANCH_SWITCH" = false ]; then
git -C "$DIR" switch "$(git rev-parse --abbrev-ref HEAD)" >&3
else
if ! git -C "$DIR" switch "$BRANCH" >&4; then if ! git -C "$DIR" switch "$BRANCH" >&4; then
echo "Branch $BRANCH did not exist. Creating it." >&4 echo "Branch $BRANCH did not exist. Creating it." >&4
git -C "$DIR" switch -c "$BRANCH" >&4 git -C "$DIR" switch -c "$BRANCH" >&4
fi fi
fi fi
fi
else else
echo "You need to install git." echo "You need to install git."
echo "Rerun this after installing git or run this script with -n to skip the git operations." echo "Rerun this after installing git or run this script with -n to skip the git operations."
@ -578,10 +588,10 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
configure_accelerate configure_accelerate
echo -e "Setup finished! Run ./gui.sh to start." echo -e "Setup finished! Run ./gui.sh to start."
elif [[ "$OSTYPE" == "cygwin" ]]; then elif [[ "$OSTYPE" == "cygwin" ]]; then
# Cygwin is a standalone suite of Linux utilies on Windows # Cygwin is a standalone suite of Linux utilities on Windows
echo "This hasn't been validated on cygwin yet." echo "This hasn't been validated on cygwin yet."
elif [[ "$OSTYPE" == "msys" ]]; then elif [[ "$OSTYPE" == "msys" ]]; then
# MinGW has the msys environment which is a standalone suite of Linux utilies on Windows # MinGW has the msys environment which is a standalone suite of Linux utilities on Windows
# "git bash" on Windows may also be detected as msys. # "git bash" on Windows may also be detected as msys.
echo "This hasn't been validated in msys (mingw) on Windows yet." echo "This hasn't been validated in msys (mingw) on Windows yet."
fi fi

View File

@ -10,7 +10,7 @@ if %errorlevel%==1 (
git pull git pull
:: Activate the virtual environment :: Activate the virtual environment
call .\venv\Scripts\activate.baT call .\venv\Scripts\activate.bat
:: Upgrade the required packages :: Upgrade the required packages
pip install --upgrade -r requirements.txt pip install --upgrade -r requirements.txt