Fix #7
Former-commit-id: a9c079c2e51d4366e74d27aa6afa0d98718565a5 [formerly 240973ba5e3011aaac09939d8516597d726eaf48] Former-commit-id: bfa92879fb47b20bdccbf65c8b8f1e53e728f3e0
This commit is contained in:
parent
993d227d1f
commit
ed998fcc2d
|
@ -65,20 +65,32 @@
|
||||||
"source": [
|
"source": [
|
||||||
"# Free tier\n",
|
"# Free tier\n",
|
||||||
"# free_tier = True # Enables the creation of symlinks back to /notebooks/\n",
|
"# free_tier = True # Enables the creation of symlinks back to /notebooks/\n",
|
||||||
"# model_storage_dir = '/tmp/stable-diffusion/models' # Where the models will be downloaded to\n",
|
"# model_storage_dir = '/tmp/stable-diffusion/models' # Where the models will be downloaded to.\n",
|
||||||
"# repo_storage_dir = '/notebooks' # Where the repository will be downloaded to\n",
|
"# repo_storage_dir = '/notebooks' # Where the repository will be downloaded to.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Paid Tier\n",
|
"# Paid Tier\n",
|
||||||
"# free_tier = False\n",
|
"# free_tier = False\n",
|
||||||
"# model_storage_dir = '/storage/models'\n",
|
"# model_storage_dir = '/storage/models'\n",
|
||||||
"# repo_storage_dir = '/notebooks'\n",
|
"# repo_storage_dir = '/notebooks'\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"activate_xformers = False # Enables the xformers optimizations using pre-built wheels.\n",
|
||||||
|
" # Setting to True will automatically set up your environment/machine for xformers. \n",
|
||||||
|
"\n",
|
||||||
|
"link_novelai_anime_vae = False # Enables the linking of animevae.pt to each of the NovelAI models.\n",
|
||||||
|
" # Set to True if you've downloaded both the NovelAI models and hypernetworks.\n",
|
||||||
|
" \n",
|
||||||
|
"download_scripts = False # Download custom scripts? Only reason why you would leave it disabled is because it may\n",
|
||||||
|
" # take a while to complete.\n",
|
||||||
|
"\n",
|
||||||
|
"activate_deepdanbooru = False # Enable and install DeepDanbooru -> https://github.com/KichangKim/DeepDanbooru\n",
|
||||||
|
"\n",
|
||||||
"# Don't put a trailing slash on directory paths.\n",
|
"# Don't put a trailing slash on directory paths.\n",
|
||||||
"# To reset your storage directory, rerun this cell.\n",
|
"# To reset your storage directory, rerun this cell.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# ===============================================================\n",
|
"# ===============================================================\n",
|
||||||
"# Save variables to Jupiter's temp storage so we can access it even if the kernel restarts.\n",
|
"# Save variables to Jupiter's temp storage so we can access it even if the kernel restarts.\n",
|
||||||
"%store free_tier model_storage_dir repo_storage_dir"
|
"%store free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -107,7 +119,7 @@
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae activate_deepdanbooru\n",
|
||||||
"%cd /notebooks/\n",
|
"%cd /notebooks/\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def delete_broken_symlinks(path):\n",
|
"def delete_broken_symlinks(path):\n",
|
||||||
|
@ -156,25 +168,23 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru\n",
|
||||||
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Import launch.py which will automatically run the install script but not launch the WebUI.\n",
|
"# Import launch.py which will automatically run the install script but not launch the WebUI.\n",
|
||||||
"# They require a few specific external git repo commits so we have to do it their way. \n",
|
"# They require a few specific external git repo commits so we have to do it their way. \n",
|
||||||
"import launch\n",
|
"import launch\n",
|
||||||
|
"launch.prepare_enviroment()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Install requirements for this notebooks\n",
|
"# The installer isn't installing deepdanbooru right now so we'll do it manually\n",
|
||||||
"!pip install requests validators\n",
|
"if activate_deepdanbooru:\n",
|
||||||
|
" !pip install \"git+https://github.com/KichangKim/DeepDanbooru.git@edf73df4cdaeea2cf00e9ac08bd8a9026b7a7b26#egg=deepdanbooru[tensorflow]\" # tensorflow==2.10.0 tensorflow-io==0.27.0 flatbuffers==1.12\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# latent-diffusion is a requirement but launch.py isn't downloading it so we'll do it manually.\n",
|
"# latent-diffusion is a requirement but launch.py isn't downloading it so we'll do it manually.\n",
|
||||||
"if not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion'):\n",
|
"if not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion'):\n",
|
||||||
" !git clone https://github.com/crowsonkb/k-diffusion.git \"{repo_storage_dir}/stable-diffusion-webui/repositories/k-diffusion\"\n",
|
" !git clone https://github.com/crowsonkb/k-diffusion.git \"{repo_storage_dir}/stable-diffusion-webui/repositories/k-diffusion\"\n",
|
||||||
" !git clone https://github.com/Hafiidz/latent-diffusion.git \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion\"\n",
|
" !git clone https://github.com/Hafiidz/latent-diffusion.git \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion\"\n",
|
||||||
" # I don't think it's necessary to do this:\n",
|
|
||||||
" # %mkdir \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion/experiments/\"\n",
|
|
||||||
" # %mkdir \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion/experiments/pretrained_models\"\n",
|
|
||||||
" # !wget https://raw.githubusercontent.com/Engineer-of-Stuff/stable-diffusion-paperspace/main/lfs/latent-diffusion/project.yaml -O \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion/experiments/pretrained_models/project.yaml\"\n",
|
|
||||||
" # !wget https://github.com/Engineer-of-Stuff/stable-diffusion-paperspace/blob/main/lfs/latent-diffusion/model.ckpt?raw=true -O \"{repo_storage_dir}/stable-diffusion-webui/repositories/latent-diffusion/experiments/pretrained_models/model.ckpt\"\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Download the GFPGAN face restorer.\n",
|
"# Download the GFPGAN face restorer.\n",
|
||||||
"if not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/GFPGANv1.3.pth'):\n",
|
"if not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/GFPGANv1.3.pth'):\n",
|
||||||
|
@ -184,79 +194,119 @@
|
||||||
"\n",
|
"\n",
|
||||||
"# Download popular custom scripts. This is basically remote code execution so be careful.\n",
|
"# Download popular custom scripts. This is basically remote code execution so be careful.\n",
|
||||||
"# See https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts\n",
|
"# See https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts\n",
|
||||||
"import os\n",
|
"if download_scripts:\n",
|
||||||
"import shutil\n",
|
" !pip install requests\n",
|
||||||
"import requests\n",
|
" import shutil\n",
|
||||||
"!pip install moviepy==1.0.3\n",
|
" import requests\n",
|
||||||
"!apt update\n",
|
" !pip install moviepy==1.0.3\n",
|
||||||
"!apt install -y potrace python3-tk\n",
|
" !apt update\n",
|
||||||
|
" !apt install -y potrace python3-tk\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def download_file_dir(url, output_dir):\n",
|
" def download_file_dir(url, output_dir):\n",
|
||||||
" # output_dir must have a trailing slash\n",
|
" # output_dir must have a trailing slash\n",
|
||||||
" local_filename = url.split('/')[-1]\n",
|
" local_filename = url.split('/')[-1]\n",
|
||||||
" with requests.get(url, stream=True) as r:\n",
|
" with requests.get(url, stream=True) as r:\n",
|
||||||
" r.raise_for_status()\n",
|
" r.raise_for_status()\n",
|
||||||
" with open(f'{output_dir}{local_filename}', 'wb') as f:\n",
|
" with open(f'{output_dir}{local_filename}', 'wb') as f:\n",
|
||||||
" for chunk in r.iter_content(chunk_size=8192):\n",
|
" for chunk in r.iter_content(chunk_size=8192):\n",
|
||||||
" f.write(chunk)\n",
|
" f.write(chunk)\n",
|
||||||
" return local_filename\n",
|
" return local_filename\n",
|
||||||
|
" def do_script_download(scripts_list, domain, path):\n",
|
||||||
|
" for item in scripts_list:\n",
|
||||||
|
" download_file_dir(f'https://{domain}/{item}', path)\n",
|
||||||
|
" print(f'{item.split(\"/\")[-1]} downloaded...')\n",
|
||||||
"\n",
|
"\n",
|
||||||
"custom_scripts = [\n",
|
" do_script_download([\n",
|
||||||
" 'https://raw.githubusercontent.com/GRMrGecko/stable-diffusion-webui-automatic/advanced_matrix/scripts/advanced_prompt_matrix.py',\n",
|
" 'GRMrGecko/stable-diffusion-webui-automatic/advanced_matrix/scripts/advanced_prompt_matrix.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards.py',\n",
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/dfaker/stable-diffusion-webui-cv2-external-masking-script/main/external_masking.py',\n",
|
" 'dfaker/stable-diffusion-webui-cv2-external-masking-script/main/external_masking.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/memes-forever/Stable-diffusion-webui-video/main/videos.py',\n",
|
" 'memes-forever/Stable-diffusion-webui-video/main/videos.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/yownas/seed_travel/main/scripts/seed_travel.py',\n",
|
" 'yownas/seed_travel/main/scripts/seed_travel.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/Animator-Anon/Animator/main/animation.py',\n",
|
" 'Animator-Anon/Animator/main/animation.py',\n",
|
||||||
" 'https://gist.githubusercontent.com/dfaker/f88aa62e3a14b559fe4e5f6b345db664/raw/791dabfa0ab26399aa2635bcbc1cf6267aa4ffc2/alternate_sampler_noise_schedules.py',\n",
|
" 'Filarius/stable-diffusion-webui/master/scripts/vid2vid.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/Filarius/stable-diffusion-webui/master/scripts/vid2vid.py',\n",
|
" 'GeorgLegato/Txt2Vectorgraphics/main/txt2vectorgfx.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/GeorgLegato/Txt2Vectorgraphics/main/txt2vectorgfx.py',\n",
|
" 'yownas/shift-attention/main/scripts/shift_attention.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/yownas/shift-attention/main/scripts/shift_attention.py',\n",
|
" 'DiceOwl/StableDiffusionStuff/main/loopback_superimpose.py',\n",
|
||||||
" 'https://raw.githubusercontent.com/DiceOwl/StableDiffusionStuff/main/loopback_superimpose.py',\n",
|
" 'Engineer-of-Stuff/stable-diffusion-paperspace/main/lfs/save_steps.py',\n",
|
||||||
" 'https://gist.githubusercontent.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/c1a03eb447548adbef1858c0e69d3567a390d2f4/run_n_times.py',\n",
|
" 'Pfaeff/sd-web-ui-scripts/main/moisaic.py'\n",
|
||||||
" 'https://raw.githubusercontent.com/Engineer-of-Stuff/stable-diffusion-paperspace/main/lfs/save_steps.py',\n",
|
" ], 'raw.githubusercontent.com', f'{repo_storage_dir}/stable-diffusion-webui/scripts/')\n",
|
||||||
" 'https://raw.githubusercontent.com/Pfaeff/sd-web-ui-scripts/main/moisaic.py'\n",
|
|
||||||
"]\n",
|
|
||||||
"for item in custom_scripts:\n",
|
|
||||||
" download_file_dir(item, f'{repo_storage_dir}/stable-diffusion-webui/scripts/')\n",
|
|
||||||
" print(f'{item.split(\"/\")[-1]} downloaded...')\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Download and set up txt2img2img\n",
|
" do_script_download([\n",
|
||||||
"update_repo_if_not_exists(f'{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root', 'https://github.com/ThereforeGames/txt2img2img.git')\n",
|
" 'dfaker/f88aa62e3a14b559fe4e5f6b345db664/raw/791dabfa0ab26399aa2635bcbc1cf6267aa4ffc2/alternate_sampler_noise_schedules.py',\n",
|
||||||
"!cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/scripts\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
" 'camenduru/9ec5f8141db9902e375967e93250860f/raw/c1a03eb447548adbef1858c0e69d3567a390d2f4/run_n_times.py'\n",
|
||||||
"!cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/txt2img2img\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
" ], 'gist.githubusercontent.com', f'{repo_storage_dir}/stable-diffusion-webui/scripts/')\n",
|
||||||
"!cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/venv\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
|
||||||
" \n",
|
|
||||||
"# Download and set up txt2mask\n",
|
|
||||||
"update_repo_if_not_exists(f'{repo_storage_dir}/stable-diffusion-webui/txt2mask', 'https://github.com/ThereforeGames/txt2mask.git')\n",
|
|
||||||
"!cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2mask/repositories/clipseg\" \"{repo_storage_dir}/stable-diffusion-webui/repositories\"\n",
|
|
||||||
"!cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2mask/scripts/\" \"{repo_storage_dir}/stable-diffusion-webui/\"\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Do the wildcard script\n",
|
" # Download and set up txt2img2img\n",
|
||||||
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/scripts/wildcards\"\n",
|
" update_repo_if_not_exists(f'{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root', 'https://github.com/ThereforeGames/txt2img2img.git')\n",
|
||||||
"wildcard_lists = [\n",
|
" !cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/scripts\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/adjective.txt',\n",
|
" !cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/txt2img2img\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/artist.txt',\n",
|
" !cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2img2img_root/venv\" \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/genre.txt',\n",
|
"\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/site.txt',\n",
|
" # Download and set up txt2mask\n",
|
||||||
" 'https://raw.githubusercontent.com/jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/style.txt'\n",
|
" update_repo_if_not_exists(f'{repo_storage_dir}/stable-diffusion-webui/txt2mask', 'https://github.com/ThereforeGames/txt2mask.git')\n",
|
||||||
"]\n",
|
" !echo \"Copying txt2mask...\"\n",
|
||||||
"for item in wildcard_lists:\n",
|
" !cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2mask/repositories/clipseg\" \"{repo_storage_dir}/stable-diffusion-webui/repositories\"\n",
|
||||||
" download_file_dir(item, f'{repo_storage_dir}/stable-diffusion-webui/scripts/wildcards/')\n",
|
" !cp -r \"{repo_storage_dir}/stable-diffusion-webui/txt2mask/scripts/\" \"{repo_storage_dir}/stable-diffusion-webui/\"\n",
|
||||||
|
"\n",
|
||||||
|
" # Do the wildcard script\n",
|
||||||
|
" !mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/scripts/wildcards\"\n",
|
||||||
|
" do_script_download([\n",
|
||||||
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/adjective.txt',\n",
|
||||||
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/artist.txt',\n",
|
||||||
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/genre.txt',\n",
|
||||||
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/site.txt',\n",
|
||||||
|
" 'jtkelm2/stable-diffusion-webui-1/master/scripts/wildcards/style.txt'\n",
|
||||||
|
" ], 'raw.githubusercontent.com', f'{repo_storage_dir}/stable-diffusion-webui/scripts/wildcards/')\n",
|
||||||
|
"\n",
|
||||||
|
"if activate_xformers:\n",
|
||||||
|
" # Completly remove cuda from your system\n",
|
||||||
|
" # The container comes with cuda 11.2 installed which is incompatable with pytorch\n",
|
||||||
|
" # We MUST install cuda 11.3\n",
|
||||||
|
" !apt update\n",
|
||||||
|
" !apt purge -y cuda*\n",
|
||||||
|
" !apt autoremove --purge -y\n",
|
||||||
|
" !wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004-keyring.gpg -O /usr/share/keyrings/cuda-archive-keyring.gpg\n",
|
||||||
|
" !echo \"deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /\" | sudo tee /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list\n",
|
||||||
|
" # Reinstall the cuda packages we removed, but in version 11.3\n",
|
||||||
|
" !apt update && apt install -y cuda-command-line-tools-11-3 cuda-compat-11-3 cuda-minimal-build-11-3 cuda-compiler-11-3 cuda-libraries-dev-11-3 cuda-cupti-dev-11-3 cuda-cupti-11-3 cuda-nvcc-11-3 cuda-cudart-dev-11-3 cuda-libraries-11-3 cuda-cudart-11-3 cuda-gdb-11-3 cuda-cuobjdump-11-3 cuda-cuxxfilt-11-3 cuda-driver-dev-11-3 cuda-memcheck-11-3 cuda-nvdisasm-11-3 cuda-nvml-dev-11-3 cuda-nvprof-11-3 cuda-nvprune-11-3 cuda-nvrtc-dev-11-3 cuda-nvrtc-11-3 cuda-nvtx-11-3 cuda-sanitizer-11-3\n",
|
||||||
|
" # Set up pip packages\n",
|
||||||
|
" !pip uninstall -y torch torchvision torchaudio # Remove existing pytorch install.\n",
|
||||||
|
" !pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 # Install pytorch for cuda 11.3\n",
|
||||||
|
" from subprocess import getoutput\n",
|
||||||
|
" s = getoutput('nvidia-smi')\n",
|
||||||
|
" if 'A4000' in s:\n",
|
||||||
|
" !pip install https://raw.githubusercontent.com/Cyberes/xformers-compiled/main/A4000/xformers-0.0.14.dev0-cp39-cp39-linux_x86_64.whl\n",
|
||||||
|
" elif 'P5000' in s:\n",
|
||||||
|
" !pip install https://raw.githubusercontent.com/Cyberes/xformers-compiled/main/P5000/xformers-0.0.14.dev0-cp39-cp39-linux_x86_64.whl\n",
|
||||||
|
" elif 'RTX 5000' in s:\n",
|
||||||
|
" !pip install https://raw.githubusercontent.com/Cyberes/xformers-compiled/main/RTX%205000/xformers-0.0.14.dev0-cp39-cp39-linux_x86_64.whl\n",
|
||||||
|
" elif 'RTX 4000' in s:\n",
|
||||||
|
" !pip install https://raw.githubusercontent.com/Cyberes/xformers-compiled/main/RTX%204000/xformers-0.0.14.dev0-cp39-cp39-linux_x86_64.whl\n",
|
||||||
|
" else:\n",
|
||||||
|
" print('XFORMERS ERROR: no wheel built for your GPU! Xformers disabled.')\n",
|
||||||
|
" activate_xformers = False\n",
|
||||||
|
" %store activate_xformers\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Make sure your models storage directory exists\n",
|
"# Make sure your models storage directory exists\n",
|
||||||
"!mkdir -p \"{model_storage_dir}\"\n",
|
"!mkdir -p \"{model_storage_dir}/hypernetworks\"\n",
|
||||||
|
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/models/hypernetworks\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Link the output folder to /notebooks/outputs\n",
|
"# Make sure the log dir exists\n",
|
||||||
|
"\n",
|
||||||
|
"# Link the output folders to /notebooks/outputs\n",
|
||||||
|
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/log/images\"\n",
|
||||||
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/outputs\"\n",
|
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/outputs\"\n",
|
||||||
"!ln -s \"{repo_storage_dir}/stable-diffusion-webui/outputs\" /notebooks/"
|
"!ln -s \"{repo_storage_dir}/stable-diffusion-webui/outputs\" /notebooks/\n",
|
||||||
|
"!ln -s \"{repo_storage_dir}/stable-diffusion-webui/log\" \"{repo_storage_dir}/stable-diffusion-webui/outputs\"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"!echo \"Done!\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"id": "F0EINk5M0s-w",
|
"id": "F0EINk5M0s-w",
|
||||||
"jp-MarkdownHeadingCollapsed": true,
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -312,41 +362,11 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!apt update\n",
|
"!apt update\n",
|
||||||
"!apt install -y aria2\n",
|
"!apt install -y aria2\n",
|
||||||
"%cd $model_storage_dir\n",
|
"%cd $model_storage_dir\n",
|
||||||
"!aria2c --seed-time=0 --max-overall-upload-limit=1K \"magnet:?xt=urn:btih:3A4A612D75ED088EA542ACAC52F9F45987488D1C&tr=udp://tracker.opentrackr.org:1337/announce\""
|
"!aria2c --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:3A4A612D75ED088EA542ACAC52F9F45987488D1C&tr=udp://tracker.opentrackr.org:1337/announce\""
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"**Web Download**\n",
|
|
||||||
"\n",
|
|
||||||
"Voldy provided an alternative download if you don't want to use HuggingFace.\n",
|
|
||||||
"\n",
|
|
||||||
"[https://drive.google.com/file/d/1wHFgl0ivCmIZv88hVZXkb8oy9qCuaBGA/view](https://drive.google.com/file/d/1wHFgl0ivCmIZv88hVZXkb8oy9qCuaBGA/view)\n",
|
|
||||||
"\n",
|
|
||||||
"Download it to your computer then upload it to your model storage directory (make sure it's named `sd-v1-4.ckpt`).\n",
|
|
||||||
"\n",
|
|
||||||
"HuggingFace is much faster and reliable but you need to get access to the repo and provide your user token."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {
|
|
||||||
"id": "CT_J9L7oqLxG"
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"user_token = \"<put your user token here>\"\n",
|
|
||||||
"\n",
|
|
||||||
"# ===============================================================================================\n",
|
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
|
||||||
"!wget --header=\"Authorization: Bearer {user_token}\" https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt -O \"{model_storage_dir}/sd-v1-4.ckpt\""
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -357,7 +377,9 @@
|
||||||
"source": [
|
"source": [
|
||||||
"#### Waifu Diffusion\n",
|
"#### Waifu Diffusion\n",
|
||||||
"\n",
|
"\n",
|
||||||
"The original Stable Diffusion anime finetune."
|
"The original Stable Diffusion anime finetune.\n",
|
||||||
|
"\n",
|
||||||
|
"**v1.3**"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -366,11 +388,31 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!apt update\n",
|
"!apt update\n",
|
||||||
"!apt install -y aria2\n",
|
"!apt install -y aria2\n",
|
||||||
"%cd \"{model_storage_dir}\"\n",
|
"%cd \"{model_storage_dir}\"\n",
|
||||||
"!aria2c --seed-time=0 --max-overall-upload-limit=1K \"magnet:?xt=urn:btih:153590FD7E93EE11D8DB951451056C362E3A9150&dn=wd-v1-2-full-ema-pruned.ckpt&tr=udp://tracker.opentrackr.org:1337/announce\""
|
"!aria2c --seed-time=0 --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:AWJJJZNFOOK7R2XXXGZ4GFNKUEU2TSFP&dn=wd-v1-3-float16.ckpt&xl=2132889245&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**v1.2**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
|
"!apt update\n",
|
||||||
|
"!apt install -y aria2\n",
|
||||||
|
"%cd \"{model_storage_dir}\"\n",
|
||||||
|
"!aria2c --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:153590FD7E93EE11D8DB951451056C362E3A9150&dn=wd-v1-2-full-ema-pruned.ckpt&tr=udp://tracker.opentrackr.org:1337\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -406,7 +448,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step60000.ckpt -O \"{model_storage_dir}/trinart2_step60000.ckpt\""
|
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step60000.ckpt -O \"{model_storage_dir}/trinart2_step60000.ckpt\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -423,7 +465,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt -O \"{model_storage_dir}/trinart2_step95000.ckpt\""
|
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt -O \"{model_storage_dir}/trinart2_step95000.ckpt\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -440,10 +482,109 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step115000.ckpt -O \"{model_storage_dir}/trinart2_step115000.ckpt\""
|
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step115000.ckpt -O \"{model_storage_dir}/trinart2_step115000.ckpt\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### NovelAI Leak"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**animefull-final-pruned**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
|
"!apt update\n",
|
||||||
|
"!apt install -y aria2\n",
|
||||||
|
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
|
||||||
|
"import re\n",
|
||||||
|
"infohash = re.search(\"^magnet:\\?xt=urn:btih:(.*?)&.*?$\", metalink).group(1)\n",
|
||||||
|
"import subprocess\n",
|
||||||
|
"tmp_dir = subprocess.check_output(['mktemp', '-d']).decode('ascii').strip('\\n')\n",
|
||||||
|
"%cd \"{tmp_dir}\"\n",
|
||||||
|
"# Have to convert the metalink to a torrent file so aria2c can read the files inside\n",
|
||||||
|
"!aria2c -d . --bt-metadata-only=true --bt-save-metadata=true --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce\"\n",
|
||||||
|
"!aria2c --select-file=64,65 --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"{infohash}.torrent\"\n",
|
||||||
|
"!mv \"novelaileak/stableckpt/animefull-final-pruned/config.yaml\" \"{model_storage_dir}/novelai-animefull-final-pruned.yaml\"\n",
|
||||||
|
"!mv \"novelaileak/stableckpt/animefull-final-pruned/model.ckpt\" \"{model_storage_dir}/novelai-animefull-final-pruned.ckpt\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**animesfw-final-pruned**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
|
"!apt update\n",
|
||||||
|
"!apt install -y aria2\n",
|
||||||
|
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
|
||||||
|
"import re\n",
|
||||||
|
"infohash = re.search(\"^magnet:\\?xt=urn:btih:(.*?)&.*?$\", metalink).group(1)\n",
|
||||||
|
"import subprocess\n",
|
||||||
|
"tmp_dir = subprocess.check_output(['mktemp', '-d']).decode('ascii').strip('\\n')\n",
|
||||||
|
"%cd \"{tmp_dir}\"\n",
|
||||||
|
"# Have to convert the metalink to a torrent file so aria2c can read the files inside\n",
|
||||||
|
"!aria2c -d . --bt-metadata-only=true --bt-save-metadata=true --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce\"\n",
|
||||||
|
"!aria2c --select-file=70,71 --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"{infohash}.torrent\"\n",
|
||||||
|
"!mv \"novelaileak/stableckpt/animesfw-final-pruned/config.yaml\" \"{model_storage_dir}/novelai-animesfw-final-pruned.yaml\"\n",
|
||||||
|
"!mv \"novelaileak/stableckpt/animesfw-final-pruned/model.ckpt\" \"{model_storage_dir}/novelai-animesfw-final-pruned.ckpt\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**Hypernetworks**\n",
|
||||||
|
"\n",
|
||||||
|
"A hypernetwork is trained much like a neural network and helps to guide the neural net towards the intended output."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
|
"!apt update\n",
|
||||||
|
"!apt install -y aria2\n",
|
||||||
|
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
|
||||||
|
"import re\n",
|
||||||
|
"infohash = re.search(\"^magnet:\\?xt=urn:btih:(.*?)&.*?$\", metalink).group(1)\n",
|
||||||
|
"import subprocess\n",
|
||||||
|
"tmp_dir = subprocess.check_output(['mktemp', '-d']).decode('ascii').strip('\\n')\n",
|
||||||
|
"%cd \"{tmp_dir}\"\n",
|
||||||
|
"# Have to convert the metalink to a torrent file so aria2c can read the files inside\n",
|
||||||
|
"!aria2c -d . --bt-metadata-only=true --bt-save-metadata=true --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce\"\n",
|
||||||
|
"!aria2c --select-file=76,81,82,83,84,85,86,87,88,89,90,91,92,93 --seed-time=0 --max-overall-upload-limit=1K --bt-max-peers=120 --summary-interval=0 --file-allocation=none \"{infohash}.torrent\"\n",
|
||||||
|
"# -exec mv doesn't work with python variables so we'll set an environment variable instead\n",
|
||||||
|
"import os\n",
|
||||||
|
"os.environ[\"MODEL_STORAGE_DIR\"] = model_storage_dir\n",
|
||||||
|
"!rm novelaileak/stableckpt/extra-sd-prune/sd-prune/anime700k-64bs-0.1ucg-penultimate-1epoch-clip-ema-continue-76000.pt # aria2 downloads this file even though I told it not to\n",
|
||||||
|
"!find novelaileak/ -type f -name '*.pt' -exec mv {} \"$MODEL_STORAGE_DIR/hypernetworks\" \\;"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
@ -459,7 +600,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Get some storage back\n",
|
"# Get some storage back\n",
|
||||||
"!pip cache purge\n",
|
"!pip cache purge\n",
|
||||||
|
@ -467,6 +608,7 @@
|
||||||
"!apt remove --purge -y aria2 p7zip-full\n",
|
"!apt remove --purge -y aria2 p7zip-full\n",
|
||||||
"!apt autoremove --purge -y\n",
|
"!apt autoremove --purge -y\n",
|
||||||
"!apt clean\n",
|
"!apt clean\n",
|
||||||
|
"!rm -rf /var/lib/apt/lists/*\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Restart the kernel\n",
|
"# Restart the kernel\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
|
@ -488,29 +630,63 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
|
"import glob\n",
|
||||||
|
"\n",
|
||||||
|
"def delete_broken_symlinks(dir):\n",
|
||||||
|
" deleted = False\n",
|
||||||
|
" for file in os.listdir(dir):\n",
|
||||||
|
" path = f'{dir}/{file}'\n",
|
||||||
|
" if os.path.islink(path) and not os.path.exists(os.readlink(path)):\n",
|
||||||
|
" print(f'Symlink broken, removing: {file}')\n",
|
||||||
|
" os.unlink(path)\n",
|
||||||
|
" deleted = True\n",
|
||||||
|
" if deleted:\n",
|
||||||
|
" print('')\n",
|
||||||
|
" \n",
|
||||||
|
"def symlink_models(source_dir, filetype, destination_dir):\n",
|
||||||
|
" # don't pass directory paths with trailing slash\n",
|
||||||
|
" for file in os.listdir(source_dir):\n",
|
||||||
|
" if file.endswith(filetype):\n",
|
||||||
|
" path = f'{destination_dir}/{file}'\n",
|
||||||
|
" if not os.path.exists(path):\n",
|
||||||
|
" print(f'New model: {file}')\n",
|
||||||
|
" !ln -s \"{source_dir}/{file}\" \"{destination_dir}/{file}\"\n",
|
||||||
|
" !ls -la --block-size=GB \"{destination_dir}/{file}\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Check for broken symlinks and remove them\n",
|
"# Check for broken symlinks and remove them\n",
|
||||||
"deleted = False\n",
|
"delete_broken_symlinks(f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion')\n",
|
||||||
"for file in os.listdir(f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/'):\n",
|
"delete_broken_symlinks(f'{repo_storage_dir}/stable-diffusion-webui/models/hypernetworks')\n",
|
||||||
" path = f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{file}'\n",
|
|
||||||
" if os.path.islink(path) and not os.path.exists(os.readlink(path)):\n",
|
|
||||||
" print(f'Symlink broken, removing: {file}')\n",
|
|
||||||
" os.unlink(path)\n",
|
|
||||||
" deleted = True\n",
|
|
||||||
"if deleted:\n",
|
|
||||||
" print('')\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Make symlinks for new files\n",
|
"# Link models\n",
|
||||||
"for file in os.listdir(model_storage_dir):\n",
|
"symlink_models(model_storage_dir, 'ckpt', f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion')\n",
|
||||||
" if file.endswith(\"ckpt\"):\n",
|
"\n",
|
||||||
" path = f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{file}'\n",
|
"# Link config yaml files\n",
|
||||||
" if not os.path.exists(path):\n",
|
"symlink_models(model_storage_dir, 'yaml', f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion')\n",
|
||||||
" print(f'New model: {file}')\n",
|
"\n",
|
||||||
" !ln -s \"{model_storage_dir}/$file\" \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/$file\"\n",
|
"# Link hypernetworks\n",
|
||||||
" !ls -la --block-size=GB \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/$file\"\n",
|
"symlink_models(f'{model_storage_dir}/hypernetworks', 'pt', f'{repo_storage_dir}/stable-diffusion-webui/models/hypernetworks')\n",
|
||||||
" print('')"
|
"\n",
|
||||||
|
"# Link the NovelAI files for each of the NovelAI models\n",
|
||||||
|
"os.chdir(f'{model_storage_dir}')\n",
|
||||||
|
"for model in glob.glob('novelai-*.ckpt'):\n",
|
||||||
|
" yaml = model.replace('.ckpt', '.yaml')\n",
|
||||||
|
" if os.path.exists(yaml) and not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{yaml}'): \n",
|
||||||
|
" print(f'New NovelAI model config: {yaml}')\n",
|
||||||
|
" !ln -s \"{model_storage_dir}/{yaml}\" \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{yaml}\"\n",
|
||||||
|
" !ls -la --block-size=GB \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{yaml}\"\n",
|
||||||
|
"\n",
|
||||||
|
"if link_novelai_anime_vae:\n",
|
||||||
|
" for model in glob.glob('novelai-*.ckpt'):\n",
|
||||||
|
" if os.path.exists(f'{model_storage_dir}/hypernetworks/animevae.pt'):\n",
|
||||||
|
" vae = model.replace('.ckpt', '.vae.pt')\n",
|
||||||
|
" if not os.path.exists(f'{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{vae}'):\n",
|
||||||
|
" print(f'Linking NovelAI {vae} and {model}')\n",
|
||||||
|
" !ln -s \"{model_storage_dir}/hypernetworks/animevae.pt\" \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{vae}\"\n",
|
||||||
|
" !ls -la --block-size=GB \"{repo_storage_dir}/stable-diffusion-webui/models/Stable-diffusion/{vae}\"\n",
|
||||||
|
" else:\n",
|
||||||
|
" print(f'{model_storage_dir}/hypernetworks/animevae.pt NOT FOUND')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -530,7 +706,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"Run this block to launch the WebUI. You will get a link to nnn.gradio.app, that's your WebUI. Follow it.\n",
|
"Run this block to launch the WebUI. You will get a link to nnn.gradio.app, that's your WebUI. Follow it.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"- See [webui.py](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/shared.py#L22) to view the code for the launch args. There's a lot of good info in here about exactly what the args do. If you aren't a programmer, [here's the wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Run-with-Custom-Parameters).\n",
|
"- See [webui.py](https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/shared.py#L22) to view the code for the launch args. There's a lot of good info in there about exactly what the args do. If you aren't a programmer, [here's the wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Run-with-Custom-Parameters).\n",
|
||||||
"- If you have a lot of VRAM and desire high generation speeds, add `--disable-opt-split-attention` to disable VRAM optimizations.\n",
|
"- If you have a lot of VRAM and desire high generation speeds, add `--disable-opt-split-attention` to disable VRAM optimizations.\n",
|
||||||
"- If you have a decent about of VRAM and aren't generating large images you can remove `--medvram` for a speed boost.\n",
|
"- If you have a decent about of VRAM and aren't generating large images you can remove `--medvram` for a speed boost.\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -549,11 +725,15 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers activate_deepdanbooru\n",
|
||||||
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"# Enable optional args automatically\n",
|
||||||
|
"x_arg = '--xformers' if activate_xformers else ''\n",
|
||||||
|
"dd_arg = '--deepdanbooru' if activate_deepdanbooru else ''\n",
|
||||||
|
"\n",
|
||||||
"# Launch args go below:\n",
|
"# Launch args go below:\n",
|
||||||
"!python webui.py --gradio-debug --share --medvram # --gradio-auth me:password1234"
|
"!python webui.py {x_arg} {dd_arg} --gradio-debug --share --medvram # --gradio-auth me:password1234"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -582,14 +762,14 @@
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"!apt update\n",
|
"!apt update\n",
|
||||||
"!apt install -y p7zip-full\n",
|
"!apt install -y p7zip-full\n",
|
||||||
"from datetime import datetime\n",
|
"from datetime import datetime\n",
|
||||||
"datetime_str = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n",
|
"datetime_str = datetime.now().strftime('%m-%d-%Y_%H:%M:%S')\n",
|
||||||
"%cd /notebooks/\n",
|
"%cd /notebooks/\n",
|
||||||
"!mkdir \"{datetime_str}\"\n",
|
"!mkdir -p \"{datetime_str}/log\"\n",
|
||||||
"!mv \"{repo_storage_dir}/stable-diffusion-webui/log\" \"/notebooks/{datetime_str}\"\n",
|
"!cd \"{repo_storage_dir}/stable-diffusion-webui/log/\" && mv * \"/notebooks/{datetime_str}/log\"\n",
|
||||||
"!cd \"{repo_storage_dir}/stable-diffusion-webui/outputs/\" && mv * \"/notebooks/{datetime_str}\"\n",
|
"!cd \"{repo_storage_dir}/stable-diffusion-webui/outputs/\" && mv * \"/notebooks/{datetime_str}\"\n",
|
||||||
"!TEMP=\"/notebooks/{datetime_str}\" # find command has issues with ipynb variables??\n",
|
"!TEMP=\"/notebooks/{datetime_str}\" # find command has issues with ipynb variables??\n",
|
||||||
"# !find $TEMP -name .ipynb_checkpoints -exec rm -rf \"{}\" +\n",
|
"# !find $TEMP -name .ipynb_checkpoints -exec rm -rf \"{}\" +\n",
|
||||||
|
@ -659,7 +839,8 @@
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"!mv /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb.backup # save your old notebook to a backup\n",
|
"!mv /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb.backup # save your old notebook to a backup\n",
|
||||||
"!wget https://raw.githubusercontent.com/Engineer-of-Stuff/stable-diffusion-paperspace/main/StableDiffusionUI_Voldemort_paperspace.ipynb -O /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb"
|
"!wget https://raw.githubusercontent.com/Engineer-of-Stuff/stable-diffusion-paperspace/main/StableDiffusionUI_Voldemort_paperspace.ipynb -O /notebooks/StableDiffusionUI_Voldemort_paperspace.ipynb\n",
|
||||||
|
"!echo \"Downloaded! Now, refresh the page (press F5). Don't save anything or you will overwrite the downloaded file.\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -672,6 +853,9 @@
|
||||||
"\n",
|
"\n",
|
||||||
"Sometimes AUTOMATIC1111 breaks something. Go to https://github.com/AUTOMATIC1111/stable-diffusion-webui/commits/master and choose a commit to revert to.\n",
|
"Sometimes AUTOMATIC1111 breaks something. Go to https://github.com/AUTOMATIC1111/stable-diffusion-webui/commits/master and choose a commit to revert to.\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"If you're looking for a specific date, do: `git log --since='Sept 17 2022' --until='Sept 18 2022'`\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
"**This shouldn't delete your outputs or any changes you've made to files, but I'd back up anything important just to be safe.**"
|
"**This shouldn't delete your outputs or any changes you've made to files, but I'd back up anything important just to be safe.**"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -681,7 +865,7 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
|
||||||
"!git reset --hard <commit>"
|
"!git reset --hard <commit>"
|
||||||
]
|
]
|
||||||
|
@ -722,7 +906,7 @@
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Uncomment the lines below to run this block. You can highlight the lines and do ctrl + /\n",
|
"# Uncomment the lines below to run this block. You can highlight the lines and do ctrl + /\n",
|
||||||
"# %store -r free_tier model_storage_dir repo_storage_dir\n",
|
"# %store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
|
||||||
"# !rm -rf /storage/*\n",
|
"# !rm -rf /storage/*\n",
|
||||||
"# !mv /notebooks/*.ipynb / # move the notebook out of the directory before we nuke it\n",
|
"# !mv /notebooks/*.ipynb / # move the notebook out of the directory before we nuke it\n",
|
||||||
"# !rm -rf /notebooks/*\n",
|
"# !rm -rf /notebooks/*\n",
|
||||||
|
@ -737,13 +921,16 @@
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"### Download and Install Custom Scripts\n",
|
"### Build and Install Xformers\n",
|
||||||
"\n",
|
"\n",
|
||||||
"This block will prompt you to enter the URL of the script you want to download.\n",
|
"This is an advanced feature that should boost your generation speeds.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"See [https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts)\n",
|
"1. Run the block below to download the install script to `/notebooks/`\n",
|
||||||
|
"2. Go to https://developer.nvidia.com/cuda-gpus and find the Cuda arch for your GPU model. It's likely 7.5, but double check.\n",
|
||||||
|
"3. Once you have read these instructions, uncomment the second line and insert your Cuda arch.\n",
|
||||||
|
"4. Add `--xformers` to your launch args.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"<mark>This is basically remote code execution so be careful.</mark>"
|
"If you have any issues, open the Jpyter Lab and run `build-xformers.sh` from the terminal."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -752,45 +939,9 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"%store -r free_tier model_storage_dir repo_storage_dir\n",
|
"!wget https://raw.githubusercontent.com/Engineer-of-Stuff/stable-diffusion-paperspace/main/other/build-xformers.sh -O /notebooks/build-xformers.sh\n",
|
||||||
"import validators\n",
|
"# !bash /notebooks/build-xformers.sh [your cuda arch]\n",
|
||||||
"import requests\n",
|
"!echo \"COMPLETED!\""
|
||||||
"import sys\n",
|
|
||||||
"\n",
|
|
||||||
"def download_file(url, directory):\n",
|
|
||||||
" print('Checking if text...', end='\\r')\n",
|
|
||||||
" content_type = requests.head(url).headers['content-type'].split(';')[0]\n",
|
|
||||||
" if (content_type != 'text/plain'):\n",
|
|
||||||
" while True:\n",
|
|
||||||
" print(f'This is not a text file, it\\'s {content_type}! Continue? y/n', end='\\r')\n",
|
|
||||||
" ask = input().lower()\n",
|
|
||||||
" if (ask == 'y'):\n",
|
|
||||||
" break\n",
|
|
||||||
" if (ask == 'n'):\n",
|
|
||||||
" sys.exit(0)\n",
|
|
||||||
" print('\\033[F' + '\\033[K' + 'Downloading...', end='\\r')\n",
|
|
||||||
" local_filename = f'{directory}{url.split(\"/\")[-1]}'\n",
|
|
||||||
" with requests.get(url, stream=True) as r:\n",
|
|
||||||
" try:\n",
|
|
||||||
" r.raise_for_status()\n",
|
|
||||||
" except requests.exceptions.HTTPError as err:\n",
|
|
||||||
" print(err)\n",
|
|
||||||
" raise Exception(err)\n",
|
|
||||||
" with open(local_filename, 'wb') as f:\n",
|
|
||||||
" for chunk in r.iter_content(chunk_size=8192): \n",
|
|
||||||
" f.write(chunk)\n",
|
|
||||||
" print('Downloading... done!')\n",
|
|
||||||
" return local_filename\n",
|
|
||||||
"\n",
|
|
||||||
"print('URL to script then press ENTER: ')\n",
|
|
||||||
"i = input().strip()\n",
|
|
||||||
"valid_url = validators.url(i)\n",
|
|
||||||
"if not valid_url:\n",
|
|
||||||
" print('Not a valid URL')\n",
|
|
||||||
"else:\n",
|
|
||||||
" download_file(i, f'{repo_storage_dir}/stable-diffusion-webui/scripts/') # this will overwrite any existing files\n",
|
|
||||||
" print('\\nScripts folder content:')\n",
|
|
||||||
" !ls \"{repo_storage_dir}/stable-diffusion-webui/scripts\""
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue