Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uchidama/441b1ff09b0b9860c5250cda2552877a to your computer and use it in GitHub Desktop.
Save uchidama/441b1ff09b0b9860c5250cda2552877a to your computer and use it in GitHub Desktop.
stablediffusionui-voldemort-v1-2-waifudiffusionv1-3-easystart.ipynb
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": [
"9qrpRUJpno7L"
],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/uchidama/441b1ff09b0b9860c5250cda2552877a/stablediffusionui-voldemort-v1-2-waifudiffusionv1-3-easystart.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"Adapted from: https://colab.research.google.com/drive/1AfAmwLMd_Vx33O9IwY2TmO9wKZ8ABRRa"
],
"metadata": {
"id": "gfKvWAVnz8OB"
}
},
{
"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": "markdown",
"source": [],
"metadata": {
"id": "Vfl2w8Xiv56F"
}
},
{
"cell_type": "code",
"source": [
"!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n",
"%cd 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 WaifuDiffusion 1.3 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 /content/stable-diffusion-webui/model.ckpt\n",
"!wget --header={user_header} https://huggingface.co/hakurei/waifu-diffusion-v1-3/resolve/main/wd-v1-3-float16.ckpt -O models/wd-v1-3-float16.ckpt"
],
"metadata": {
"id": "CT_J9L7oqLxG"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Voldy doesn't explian what this does but it appears to replace the prior dependencies section, saving a few lines lmao "
],
"metadata": {
"id": "v2kY0Z05DwIN"
}
},
{
"cell_type": "code",
"source": [
"!COMMANDLINE_ARGS=\"--exit\" REQS_FILE=\"requirements.txt\" python launch.py"
],
"metadata": {
"id": "IB19TzabDtYF"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Change into Web UI directory and download updates"
],
"metadata": {
"id": "S8nvm5f6AfaL"
}
},
{
"cell_type": "code",
"source": [
"%cd 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",
" - `--gradio-auth me:qwerty` - add authentication to gradio: username me, password qwerty"
],
"metadata": {
"id": "xt8lbdmC04ox"
}
},
{
"cell_type": "code",
"source": [
"!COMMANDLINE_ARGS=\"--share --gradio-debug --gradio-auth me:qwerty --deepdanbooru\" REQS_FILE=\"requirements.txt\" python launch.py"
],
"metadata": {
"id": "R-xAdMA5wxXd"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"commands for ***after*** you have gotten done with a session\n",
"============================================================================"
],
"metadata": {
"id": "9qrpRUJpno7L"
}
},
{
"cell_type": "markdown",
"source": [
"Zip images for downloading on local drive (click the folder icon on the left, the one below {x})"
],
"metadata": {
"id": "zB-L8JpElKp-"
}
},
{
"cell_type": "code",
"source": [
"!zip -r /content/stable-diffusion-webui /content/stable-diffusion-webui/outputs "
],
"metadata": {
"id": "gBt5g_Dn0NFo"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Save images to Google Drive **Warning: this will cause google to scan your drive, so if you intend to use this and worry about that kind of stuff, probablly just set this up on a clean account that's just for this colab**"
],
"metadata": {
"id": "odNn2KF5lFmb"
}
},
{
"cell_type": "code",
"source": [
"from google.colab import drive # type: ignore\n",
"\n",
"try:\n",
" drive_path = \"/content/drive\"\n",
" drive.mount(drive_path,force_remount=False)\n",
"except:\n",
" print(\"...error mounting drive or with drive path variables\")\n",
"\n",
"!cp -r \"/content/stable-diffusion-webui/outputs\" \"/content/drive/MyDrive\""
],
"metadata": {
"id": "zNEgJfbhDwI6"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment