236 lines
6.4 KiB
Plaintext
236 lines
6.4 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"tags": []
|
||
|
},
|
||
|
"source": [
|
||
|
"# Voldemort's Stable Diffusion WebUI"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Installation and Setup\n",
|
||
|
"\n",
|
||
|
"You must reinstall everything each time you restart the machine. The script will check if you've already downloaded certain items."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"id": "cAsdhafsBvEr"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"!nvidia-smi -L"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Clone the central repositories\n",
|
||
|
"\n",
|
||
|
"If they already exist they will be updated."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {
|
||
|
"id": "LSCxESSsDGVh"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/notebooks/stable-diffusion\n",
|
||
|
"Already up to date.\n",
|
||
|
"/notebooks/stable-diffusion/stable-diffusion-webui\n",
|
||
|
"Already up to date.\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import os.path\n",
|
||
|
"\n",
|
||
|
"if not os.path.exists('/notebooks/stable-diffusion'):\n",
|
||
|
" !git clone https://github.com/CompVis/stable-diffusion\n",
|
||
|
" %cd /notebooks/stable-diffusion\n",
|
||
|
" !git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n",
|
||
|
"else:\n",
|
||
|
" %cd /notebooks/stable-diffusion\n",
|
||
|
" !git pull\n",
|
||
|
" %cd /notebooks/stable-diffusion/stable-diffusion-webui\n",
|
||
|
" !git pull"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Download the main model\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, create the directory `/notebooks/stable-diffusion/models/ldm/stable-diffusion-v1` in this notebook (pro-tip: use `mkdir -p`), then upload it to that dir (make sure it's named `model.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": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Already downloaded, moving on...\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"user_token = \"<enter user_token here>\"\n",
|
||
|
"\n",
|
||
|
"# ===============================================================================================\n",
|
||
|
"\n",
|
||
|
"if not os.path.exists('/notebooks/stable-diffusion/models/ldm/stable-diffusion-v1/model.ckpt'):\n",
|
||
|
" !mkdir -p /notebooks/stable-diffusion/models/ldm/stable-diffusion-v1\n",
|
||
|
" user_header = f\"'Authorization: Bearer {user_token}'\"\n",
|
||
|
" !wget --header={user_header} https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt -O /notebooks/stable-diffusion/models/ldm/stable-diffusion-v1/model.ckpt\n",
|
||
|
"else:\n",
|
||
|
" print('Already downloaded, moving on...')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Install Miniconda3\n",
|
||
|
"\n",
|
||
|
"Automated install, initialization, and environment setup."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"id": "4bXKqpANZ997"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Install miniconda3\n",
|
||
|
"import sys\n",
|
||
|
"%cd /notebooks/\n",
|
||
|
"!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh\n",
|
||
|
"!bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local # Sorry, but it MUST be installed in /usr/local\n",
|
||
|
"sys.path.append('/usr/local/lib/python3.7/site-packages/')\n",
|
||
|
"!rm Miniconda3-latest-Linux-x86_64.sh\n",
|
||
|
"!conda update --yes -n base -c defaults conda\n",
|
||
|
"!conda env update -f /notebooks/stable-diffusion/environment.yaml"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Install pip dependencies"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"id": "pl9sfO6rEN8L",
|
||
|
"scrolled": true,
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"%cd /notebooks/stable-diffusion/stable-diffusion-webui\n",
|
||
|
"!pip install -r requirements.txt\n",
|
||
|
"!pip install -e .\n",
|
||
|
"\n",
|
||
|
"%cd /notebooks/stable-diffusion/\n",
|
||
|
"!pip install -e . #Actually do this\n",
|
||
|
"%cd stable-diffusion-webui\n",
|
||
|
"!pip install -e . #OCD\n",
|
||
|
"\n",
|
||
|
"%cd /notebooks/stable-diffusion/\n",
|
||
|
"!wget https://github.com/matomo-org/travis-scripts/raw/master/fonts/Arial.ttf #Need this to get prompt matrix grids to save with text\n",
|
||
|
"%cd /notebooks/stable-diffusion-webui\n",
|
||
|
"!wget https://github.com/matomo-org/travis-scripts/raw/master/fonts/Arial.ttf #OCD\n",
|
||
|
"\n",
|
||
|
"%cd /notebooks/stable-diffusion/stable-diffusion-webui\n",
|
||
|
"!wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth #Need this to fix faces\n",
|
||
|
"\n",
|
||
|
"%cd /notebooks/\n",
|
||
|
"!git clone https://github.com/CompVis/taming-transformers.git\n",
|
||
|
"!pip install -e /notebooks/taming-transformers\n",
|
||
|
"\n",
|
||
|
"%cd /notebooks/stable-diffusion/\n",
|
||
|
"!git clone https://github.com/hlky/k-diffusion-sd.git\n",
|
||
|
"!pip install /notebooks/stable-diffusion/k-diffusion-sd"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "E1kYjBY9Rmi-"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Launch the WebUI"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"id": "BTH_drY9KZ4k"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"%cd /notebooks/stable-diffusion\n",
|
||
|
"!python stable-diffusion-webui/webui.py --medvram --share"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"accelerator": "GPU",
|
||
|
"colab": {
|
||
|
"collapsed_sections": [],
|
||
|
"machine_shape": "hm",
|
||
|
"provenance": []
|
||
|
},
|
||
|
"gpuClass": "standard",
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.9.13"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|