stable-diffusion-paperspace/Old/voldy's_colab_paperspace_09...

297 lines
7.7 KiB
Plaintext
Raw Normal View History

2022-09-07 19:41:29 -06:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"# Voldemort's Stable Diffusion WebUI"
]
},
{
"cell_type": "markdown",
2022-09-07 23:33:47 -06:00
"metadata": {
"tags": []
},
2022-09-07 19:41:29 -06:00
"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"
]
},
2022-09-07 23:33:47 -06:00
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### Clone the central repositories"
]
},
2022-09-07 19:41:29 -06:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If they already exist they will be updated."
]
},
{
"cell_type": "code",
2022-09-07 23:33:47 -06:00
"execution_count": null,
2022-09-07 19:41:29 -06:00
"metadata": {
"id": "LSCxESSsDGVh"
},
2022-09-07 23:33:47 -06:00
"outputs": [],
2022-09-07 19:41:29 -06:00
"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"
]
},
2022-09-07 23:33:47 -06:00
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### Download the model"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Pick only one!**"
]
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"#### Standard Model"
]
},
2022-09-07 19:41:29 -06:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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": {},
2022-09-07 23:33:47 -06:00
"outputs": [],
2022-09-07 19:41:29 -06:00
"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...')"
]
},
2022-09-07 23:33:47 -06:00
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"#### Waifu Diffusion"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"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",
" !wget https://storage.googleapis.com/ws-store2/wd-v1-2-full-ema.ckpt -O /notebooks/stable-diffusion/models/ldm/stable-diffusion-v1/model.ckpt\n",
"else:\n",
" print('Already downloaded, moving on...')"
]
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### Install Miniconda3"
]
},
2022-09-07 19:41:29 -06:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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",
2022-09-07 23:33:47 -06:00
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
2022-09-07 19:41:29 -06:00
"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",
2022-09-08 00:48:19 -06:00
"%cd /notebooks/stable-diffusion/stable-diffusion-webui\n",
2022-09-07 19:41:29 -06:00
"!pip install -e . #OCD\n",
"\n",
2022-09-08 00:48:19 -06:00
"!wget https://github.com/matomo-org/travis-scripts/raw/master/fonts/Arial.ttf -O /notebooks/stable-diffusion/Arial.ttf\n",
"!wget https://github.com/matomo-org/travis-scripts/raw/master/fonts/Arial.ttf -O /notebooks/stable-diffusion/stable-diffusion-webui/Arial.ttf #OCD\n",
2022-09-07 19:41:29 -06:00
"\n",
2022-09-08 00:48:19 -06:00
"!wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -O /notebooks/stable-diffusion/stable-diffusion-webui/GFPGANv1.3.pth\n",
2022-09-07 19:41:29 -06:00
"\n",
2022-09-08 00:48:19 -06:00
"!mkdir -p /notebooks/stable-diffusion/src\n",
"%cd /notebooks/stable-diffusion/src\n",
2022-09-07 19:41:29 -06:00
"!git clone https://github.com/CompVis/taming-transformers.git\n",
2022-09-08 00:48:19 -06:00
"%cd /notebooks/stable-diffusion/src/taming-transformers\n",
"!git pull\n",
"!pip install -e .\n",
2022-09-07 19:41:29 -06:00
"\n",
2022-09-08 00:48:19 -06:00
"%cd /notebooks/stable-diffusion/src\n",
2022-09-07 19:41:29 -06:00
"!git clone https://github.com/hlky/k-diffusion-sd.git\n",
2022-09-08 00:48:19 -06:00
"%cd /notebooks/stable-diffusion/src/k-diffusion-sd\n",
"!git pull\n",
"!pip install ."
2022-09-07 19:41:29 -06:00
]
},
{
"cell_type": "markdown",
"metadata": {
2022-09-08 00:48:19 -06:00
"id": "E1kYjBY9Rmi-",
"jp-MarkdownHeadingCollapsed": true,
"tags": []
2022-09-07 19:41:29 -06:00
},
"source": [
"## Launch the WebUI"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "BTH_drY9KZ4k"
},
"outputs": [],
"source": [
"%cd /notebooks/stable-diffusion\n",
2022-09-08 00:48:19 -06:00
"!python stable-diffusion-webui/webui.py --share"
2022-09-07 19:41:29 -06:00
]
2022-09-08 00:48:19 -06:00
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2022-09-07 19:41:29 -06:00
}
],
"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
}