From d45af5abdfad242ca8973d7458e9539b44eaa60c Mon Sep 17 00:00:00 2001 From: JingShing Date: Sun, 9 Oct 2022 21:31:00 +0800 Subject: [PATCH] Add files via upload --- ...iffusionUI_(adapted_to_NovelAILeaks).ipynb | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 StableDiffusionUI_(adapted_to_NovelAILeaks).ipynb diff --git a/StableDiffusionUI_(adapted_to_NovelAILeaks).ipynb b/StableDiffusionUI_(adapted_to_NovelAILeaks).ipynb new file mode 100644 index 0000000..c318d28 --- /dev/null +++ b/StableDiffusionUI_(adapted_to_NovelAILeaks).ipynb @@ -0,0 +1,251 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "collapsed_sections": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU", + "gpuClass": "standard" + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "Clone webui repository" + ], + "metadata": { + "id": "OHCtG9MT0jLq" + } + }, + { + "cell_type": "code", + "source": [ + "!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui\n", + "%cd stable-diffusion-webui" + ], + "metadata": { + "id": "sBbcB4vwj_jm", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "7d5fbd3c-fca4-4223-e0b0-4b7c34996d6f" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Cloning into 'stable-diffusion-webui'...\n", + "remote: Enumerating objects: 4564, done.\u001b[K\n", + "remote: Counting objects: 100% (143/143), done.\u001b[K\n", + "remote: Compressing objects: 100% (74/74), done.\u001b[K\n", + "remote: Total 4564 (delta 84), reused 104 (delta 69), pack-reused 4421\u001b[K\n", + "Receiving objects: 100% (4564/4564), 20.39 MiB | 11.05 MiB/s, done.\n", + "Resolving deltas: 100% (3192/3192), done.\n", + "/content/stable-diffusion-webui\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "Download the model from NovelAILeaks." + ], + "metadata": { + "id": "F0EINk5M0s-w" + } + }, + { + "cell_type": "code", + "source": [ + "!mkdir -p /content/stable-diffusion-webui/models/Stable-diffusion /content/stable-diffusion-webui/models/hypernetworks\n", + "%cd /content/stable-diffusion-webui/models/Stable-diffusion/\n", + "\n", + "# 7G animefull-final-latest (may not work)\n", + "# !gdown 17WWd6KEsBj7D_0TyGp8aXHQDlchYVs1a -O /content/stable-diffusion-webui/models/Stable-diffusion/model.ckpt\n", + "\n", + "# 4G animefull-final-pruned\n", + "# !gdown 1d3f2fvN2gLRocBahZrXe_v1EEHuqpUzT -O /content/stable-diffusion-webui/models/Stable-diffusion/model.ckpt\n", + "\n", + "# 4G animefull-final-pruned (backup)\n", + "!curl -Lo model.ckpt https://cloudflare-ipfs.com/ipfs/bafybeicpamreyp2bsocyk3hpxr7ixb2g2rnrequub3j2ahrkdxbvfbvjc4/model.ckpt\n", + "\n", + "# Install VAE Weights (optional)\n", + "!curl -Lo model.vae.pt https://cloudflare-ipfs.com/ipfs/bafybeiccldswdd3wvg57jhclcq53lvsc6gizasiblwayvhlv6eq4wow7wu/animevae.pt \n", + "\n", + "# Install hypernetwork (optional)\n", + "!curl -L https://cloudflare-ipfs.com/ipfs/bafybeiduanx2b3mcvxlwr66igcwnpfmk3nc3qgxlpwh6oq6m6pxii3f77e/_modules.tar | tar x -C /content/stable-diffusion-webui/models/hypernetworks\n", + "\n", + "# Install custom embeddings (modified, optional)\n", + "# !curl -L https://cloudflare-ipfs.com/ipfs/bafybeie3hdjchxs5tz4n75bos53nhcklslguxchdurc2ynrzcfv2kwyklu/embeddings.tar | tar x -C /content/stable-diffusion-webui/embeddings" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "ZzRNMT42Gw_p", + "outputId": "5f256bc3-ce49-4444-e232-72ecbe282330" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/stable-diffusion-webui/models/Stable-diffusion\n", + " % Total % Received % Xferd Average Speed Time Time Time Current\n", + " Dload Upload Total Spent Left Speed\n", + "100 4067M 100 4067M 0 0 111M 0 0:00:36 0:00:36 --:--:-- 145M\n" + ] + } + ] + }, + { + "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": [ + "%cd /content/stable-diffusion-webui\n", + "!COMMANDLINE_ARGS=\"--share --gradio-debug --medvram\" REQS_FILE=\"requirements.txt\" python launch.py" + ], + "metadata": { + "id": "R-xAdMA5wxXd", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "9e234b7e-95f1-4456-d0ed-483989838fef" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "/content/stable-diffusion-webui\n", + "Python 3.7.14 (default, Sep 8 2022, 00:06:44) \n", + "[GCC 7.5.0]\n", + "Commit hash: 97bc0b9504572d2df80598d0b694703bcd626de6\n", + "Installing requirements for Web UI\n", + "Launching Web UI with arguments: --share --gradio-debug --medvram\n", + "LatentDiffusion: Running in eps-prediction mode\n", + "DiffusionWrapper has 859.52 M params.\n", + "making attention of type 'vanilla' with 512 in_channels\n", + "Working with z of shape (1, 4, 32, 32) = 4096 dimensions.\n", + "making attention of type 'vanilla' with 512 in_channels\n", + "Loading weights [925997e9] from /content/stable-diffusion-webui/models/Stable-diffusion/model.ckpt\n", + "Model loaded.\n", + "Loaded a total of 0 textual inversion embeddings.\n", + "Running on local URL: http://127.0.0.1:7860\n", + "Running on public URL: https://13759.gradio.app\n", + "\n", + "This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co/spaces\n", + " 0% 0/20 [00:00\n" + ] + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "commands for ***after*** you have gotten done with a session\n", + "============================================================================" + ], + "metadata": { + "id": "T3957x2AY7iP" + } + }, + { + "cell_type": "markdown", + "source": [ + "Zip images for downloading on local drive (click the folder icon on the left, the one below {x})" + ], + "metadata": { + "id": "aCtJffM2ZE06" + } + }, + { + "cell_type": "code", + "source": [ + "!zip -r /content/stable-diffusion-webui /content/stable-diffusion-webui/outputs " + ], + "metadata": { + "id": "TmRqNyiAZCHu" + }, + "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": "tcslU-S2ZNr9" + } + }, + { + "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": "-N0lnu-TZOTW" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file