Last active
March 7, 2023 03:23
-
-
Save primeinc/de08105b4eb4969e35509f3e93b54ebb to your computer and use it in GitHub Desktop.
SDA1111-SparseCheckout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
######################################################### | |
# Uncomment and change the variables below to your need:# | |
######################################################### | |
# Set defaults | |
# Install directory without trailing slash | |
if [[ -z "${install_dir}" ]] | |
then | |
install_dir="/content" | |
fi | |
# Name of the subdirectory (defaults to stable-diffusion-webui) | |
if [[ -z "${clone_dir}" ]] | |
then | |
clone_dir="sd-webui" | |
fi | |
# git executable | |
if [[ -z "${GIT}" ]] | |
then | |
export GIT="git" | |
fi | |
# Pretty print | |
delimiter="################################################################" | |
printf "\n%s\n" "${delimiter}" | |
printf "\e[1m\e[32mInstall script for sparse checkout of stable-diffusion + Web UI\n" | |
printf "\e[1m\e[34mTested on Google Colab with Python310\e[0m" | |
printf "\n%s\n" "${delimiter}" | |
cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; } | |
if [[ -d "${clone_dir}" ]] | |
then | |
cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } | |
else | |
printf "\n%s\n" "${delimiter}" | |
printf "Clone stable-diffusion-webui" | |
printf "\n%s\n" "${delimiter}" | |
mkdir "${clone_dir}" || { printf "\e[1m\e[31mERROR: Can't create directory %s/, aborting...\e[0m" "${clone_dir}"; exit 1; } | |
cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } | |
"${GIT}" init | |
"${GIT}" config core.sparsecheckout true | |
echo "!embeddings/*" >> .git/info/sparse-checkout | |
echo "!extensions/*" >> .git/info/sparse-checkout | |
echo "!models/*" >> .git/info/sparse-checkout | |
echo "!outputs/*" >> .git/info/sparse-checkout | |
echo "!scripts/*" >> .git/info/sparse-checkout | |
echo "!textual_inversion_templates/*" >> .git/info/sparse-checkout | |
echo "/*" >> .git/info/sparse-checkout | |
"${GIT}" remote add origin https://github.com/AUTOMATIC1111/stable-diffusion-webui.git | |
"${GIT}" pull origin master | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment