This contains all popular colab stable diffusion notebooks released.
Created
December 20, 2022 10:22
-
-
Save CypherpunkSamurai/e5aff8828cdf3cc7711730e411640712 to your computer and use it in GitHub Desktop.
Colab-Stable-diffusion
This file contains hidden or 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
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "private_outputs": true, | |
| "provenance": [], | |
| "collapsed_sections": [] | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| }, | |
| "language_info": { | |
| "name": "python" | |
| }, | |
| "accelerator": "GPU", | |
| "gpuClass": "standard" | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Adapted from: https://colab.research.google.com/drive/1AfAmwLMd_Vx33O9IwY2TmO9wKZ8ABRRa" | |
| ], | |
| "metadata": { | |
| "id": "gfKvWAVnz8OB" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "id": "OL82Y4rBjZIV" | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "!nvidia-smi" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "import os\n", | |
| "os.kill(os.getpid(), 9) # This will crash Colab (required, everything will still be intact so dont worry)" | |
| ], | |
| "metadata": { | |
| "id": "p8FI40sFj9tU" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Clone webui repository" | |
| ], | |
| "metadata": { | |
| "id": "OHCtG9MT0jLq" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /content/stable-diffusion-webui\n", | |
| "%cd /content/stable-diffusion-webui" | |
| ], | |
| "metadata": { | |
| "id": "sBbcB4vwj_jm" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Download the model from huggingface. See link at the start for different ways." | |
| ], | |
| "metadata": { | |
| "id": "F0EINk5M0s-w" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "#@title Normal 1.4 model\n", | |
| "# get a token from https://huggingface.co/settings/tokens\n", | |
| "user_token = \"\" #@param {type:\"string\"}\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 models/sd-v1-4.ckpt" | |
| ], | |
| "metadata": { | |
| "id": "CT_J9L7oqLxG" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Install requirements, download repositories of stable diffusion" | |
| ], | |
| "metadata": { | |
| "id": "C68TUpkq0nj_" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "!COMMANDLINE_ARGS=\"--exit\" REQS_FILE=\"requirements.txt\" python launch.py" | |
| ], | |
| "metadata": { | |
| "id": "SaAJk33ppFw1" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Kill the runtime." | |
| ], | |
| "metadata": { | |
| "id": "Nshm7G9VAbIA" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "import os\n", | |
| "os.kill(os.getpid(), 9) # This will crash Colab (required, everything will still be intact so dont worry)" | |
| ], | |
| "metadata": { | |
| "id": "B977dVS6AZcL" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Optional: check that the model is whole and correct. The checksum must be `210783247af4f65a3d23d026490cc37a670964dd`" | |
| ], | |
| "metadata": { | |
| "id": "IWvC5Yth2I4v" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "!sha1sum /content/stable-diffusion-webui/models/sd-v1-4.ckpt" | |
| ], | |
| "metadata": { | |
| "id": "cfo-yDnrbgQ5" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Change into Web UI directory and download updates" | |
| ], | |
| "metadata": { | |
| "id": "S8nvm5f6AfaL" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "%cd /content/stable-diffusion-webui\n", | |
| "!git pull" | |
| ], | |
| "metadata": { | |
| "id": "I1j4j2NfAQye" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "source": [ | |
| "Launch web ui. You will get a link to nnn.gradio.app, follow it.\n", | |
| "\n", | |
| "Commandline arguments are:\n", | |
| " - `--share` - create online gradio.app link\n", | |
| " - `--gradio-debug` - print outputs to console\n", | |
| " - optional: `--gradio-auth me:qwerty` - add authentication to gradio: username me, password qwerty\n", | |
| " - see [wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Run-with-Custom-Parameters) for more options" | |
| ], | |
| "metadata": { | |
| "id": "xt8lbdmC04ox" | |
| } | |
| }, | |
| { | |
| "cell_type": "code", | |
| "source": [ | |
| "!COMMANDLINE_ARGS=\"--share --gradio-debug\" REQS_FILE=\"requirements.txt\" python launch.py" | |
| ], | |
| "metadata": { | |
| "id": "R-xAdMA5wxXd" | |
| }, | |
| "execution_count": null, | |
| "outputs": [] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment