{ "cells": [ { "cell_type": "markdown", "id": "9e42bc1e-9825-4587-b533-c74607b1a377", "metadata": {}, "source": [ "## A1111 Runpod Notebook From https://github.com/TheLastBen/fast-stable-diffusion, if you encounter any issues, feel free to discuss them." ] }, { "cell_type": "markdown", "id": "813d4d10-e6d1-42b1-ae37-ae41ad47e595", "metadata": {}, "source": [ "# Dependencies" ] }, { "cell_type": "code", "execution_count": null, "id": "bfd51417-bba8-41fb-ae56-c6555e2a0465", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Install the dependencies\n", "\n", "force_reinstall= False\n", "\n", "# Set to true only if you want to install the dependencies again.\n", "\n", "#--------------------\n", "with open('/dev/null', 'w') as devnull:import requests, os, time, importlib;open('/workspace/mainrunpodA1111.py', 'wb').write(requests.get('https://huggingface.co/spaces/stlaurentjr/RNPD/raw/main/scripts/mainrunpodA1111.py').content);os.chdir('/workspace');time.sleep(2);import mainrunpodA1111;importlib.reload(mainrunpodA1111);from mainrunpodA1111 import *;Deps(force_reinstall)" ] }, { "cell_type": "markdown", "id": "76ae705b-15e3-47b9-b226-52e71ef1737d", "metadata": {}, "source": [ "# Install/Update AUTOMATIC1111 repo" ] }, { "cell_type": "code", "execution_count": null, "id": "652afdee-64a4-483b-926a-094c884dd260", "metadata": { "tags": [] }, "outputs": [], "source": [ "Huggingface_token_optional=\"\"\n", "\n", "# Restore your backed-up SD folder by entering your huggingface token, leave it empty to start fresh or continue with the existing sd folder (if any).\n", "\n", "#--------------------\n", "repo(Huggingface_token_optional)" ] }, { "cell_type": "markdown", "id": "ca3a26bb-8625-42b9-9e2f-e55939a536ef", "metadata": {}, "source": [ "# Model Download/Load" ] }, { "cell_type": "code", "execution_count": null, "id": "1e5dbca1-5ee2-41db-be94-9d2919dc3aef", "metadata": { "tags": [] }, "outputs": [], "source": [ "Original_Model_Version = \"SDXL\"\n", "\n", "# Choices are \"SDXL\", \"v1.5\", \"v2-512\", \"v2-768\"\n", "\n", "#-------------- Or\n", "\n", "Path_to_MODEL = \"\"\n", "\n", "# Insert the full path of your trained model or to a folder containing multiple models.\n", "\n", "\n", "MODEL_LINK = \"\"\n", "\n", "# A direct link to a Model or a shared gdrive link.\n", "\n", "\n", "#--------------------\n", "model=mdl(Original_Model_Version, Path_to_MODEL, MODEL_LINK)" ] }, { "cell_type": "markdown", "id": "9c578da4-3164-411c-9255-226ce8157545", "metadata": {}, "source": [ "# LoRA Download" ] }, { "cell_type": "code", "execution_count": null, "id": "a0f3dfba-4127-4619-8bb1-4589e84a5fe4", "metadata": { "tags": [] }, "outputs": [], "source": [ "LoRA_LINK = \"\"\n", "\n", "# Downlad the LoRA model directly to A1111 LoRA folder\n", "\n", "#--------------------\n", "loradwn(LoRA_LINK)", "loradwn(\"1kkhb7J8nlJMI7GPd4QCrKxVh6emv94at\")", "loradwn(\"1lqJOnwnPu6IqrkvQEFM1TPW8osG-J5kK\")", "loradwn(\"1g8dJX-5XlvHZJGJ_Ys_xyfbuQnb6T7oz\")" ] }, { "cell_type": "markdown", "id": "9c578da4-3164-411c-9255-226ce8157545", "metadata": {}, "source": [ "# Checkpoints Download" ] }, { "cell_type": "code", "execution_count": null, "id": "a0f3dfba-4127-4619-8bb1-4589e84a5fe4", "metadata": { "tags": [] }, "outputs": [], "source": [ "model_LINK = \"\"\n", "\n", "# Downlad the Checkpoints model directly to A1111 Checkpoints folder\n", "\n", "#--------------------\n", "modeldwn(model_LINK)", "modeldwn(\"1O0ez3jYp_u0DLcdsQ9EsIHSQZciOakWn\")\n", "modeldwn(\"1ldaJzlooJ9CYm96s9FOirpiUH4GU8_jd\")\n", "modeldwn(\"1nNERcpaW09L4HlqEnsN9JpDpQXU9EOfB\")\n" ] }, { "cell_type": "markdown", "id": "02706779-fec8-4661-8589-0e28f0d4fb3b", "metadata": {}, "source": [ "# ControlNet" ] }, { "cell_type": "code", "execution_count": null, "id": "222cdfd7-38f1-422b-81a2-963a2a8d504b", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Download/update ControlNet extension and its models.\n", "\n", "ControlNet_v1_Model = \"none\"\n", "\n", "# Choices are : none; all; 1: Canny; 2: Depth; 3: Lineart; 4: MLSD; 5: Normal; 6: OpenPose; 7: Scribble; 8: Seg; 9: ip2p; 10:Shuffle; 11: Inpaint; 12: Softedge; 13: Lineart_Anime; 14: Tile; 15: T2iadapter_Models\n", "\n", "ControlNet_XL_Model = \"none\"\n", "\n", "# Choices are : none; all; 1: Canny; 2: Depth; 3: Sketch; 4: OpenPose; 5: Recolor\n", "\n", "#--------------------\n", "CNet(ControlNet_v1_Model, ControlNet_XL_Model)\n", "CNet(\"1\", ControlNet_XL_Model)\n", "CNet(\"2\", ControlNet_XL_Model)\n", "CNet(\"3\", ControlNet_XL_Model)\n", "CNet(\"6\", ControlNet_XL_Model)\n", "CNet(\"11\", ControlNet_XL_Model)\n", "CNet(\"15\", ControlNet_XL_Model)\n" ] }, { "cell_type": "markdown", "id": "48184b7b-9cd0-4f04-9c85-4464031d6596", "metadata": { "tags": [] }, "source": [ "# Start Stable-Diffusion" ] }, { "cell_type": "code", "execution_count": null, "id": "e73f76a6-01a4-44d0-87a7-77fed9c9b77c", "metadata": { "tags": [] }, "outputs": [], "source": [ "User = \"\"\n", "\n", "Password= \"\"\n", "\n", "# Add credentials to your Gradio interface (optional).\n", "\n", "#-----------------\n", "configf=sd(User, Password, model) if 'model' in locals() else sd(User, Password, \"\");import gradio;gradio.close_all()\n", "!python /workspace/sd/stable-diffusion-webui/webui.py $configf" ] }, { "cell_type": "markdown", "id": "5ac65e18-810c-4825-a507-d96beec805df", "metadata": {}, "source": [ "# Backup SD folder" ] }, { "cell_type": "code", "execution_count": null, "id": "332a8b52-29b4-494a-bf12-817feb87b745", "metadata": { "tags": [] }, "outputs": [], "source": [ "# This will backup your sd folder -without the models- to your huggingface account, so you can restore it whenever you start an instance.\n", "\n", "Huggingface_Write_token=\"\"\n", "\n", "# Must be a WRITE token, get yours here : https://huggingface.co/settings/tokens\n", "\n", "#--------------------\n", "save(Huggingface_Write_token)" ] } ], "metadata": { "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.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }