mirror of
https://github.com/Sygil-Dev/sygil-webui.git
synced 2024-12-13 17:33:31 +03:00
Update Web_based_UI_for_Stable_Diffusion_colab.ipynb
New to git and this is my first pull request so pls don't laugh. Just tried to clean it up a bit. No need to change directory when we're already in the correct one. Also, if we're crashing/rebooting kernel, best to do it sooner than later. No need to load/reload things. Also redirected localtunnel to txt file, so Streamlit can send output to cell. (Streamlit should also save output in 'log.txt'.)
This commit is contained in:
parent
26045908fc
commit
b80576eb9e
@ -265,7 +265,7 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Utils"
|
||||
"# Setup"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "IZjJSr-WPNxB"
|
||||
@ -274,113 +274,14 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "yKFE49BHaWTb",
|
||||
"cellView": "form"
|
||||
},
|
||||
"source": [
|
||||
"#@title <-- Press play on the music player to keep the tab alive, then you can continue with everything below (Uses only 13MB of data)\n",
|
||||
"%%html\n",
|
||||
"<b>Press play on the music player to keep the tab alive, then start your generation below (Uses only 13MB of data)</b><br/>\n",
|
||||
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "-o8F1NCNTK2u"
|
||||
},
|
||||
"source": [
|
||||
"JS to prevent idle timeout:\n",
|
||||
"\n",
|
||||
"Press F12 OR CTRL + SHIFT + I OR right click on this website -> inspect.\n",
|
||||
"Then click on the console tab and paste in the following code.\n",
|
||||
"\n",
|
||||
"```javascript\n",
|
||||
"function ClickConnect(){\n",
|
||||
"console.log(\"Working\");\n",
|
||||
"document.querySelector(\"colab-toolbar-button#connect\").click()\n",
|
||||
"}\n",
|
||||
"setInterval(ClickConnect,60000)\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "eq0-E5mjSpmP"
|
||||
},
|
||||
"source": [
|
||||
"#@markdown #**Check GPU type**\n",
|
||||
"#@markdown ### Factory reset runtime if you don't have the desired GPU.\n",
|
||||
"\n",
|
||||
"#@markdown ---\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#@markdown V100 = Excellent (*Available only for Colab Pro users*)\n",
|
||||
"\n",
|
||||
"#@markdown P100 = Very Good\n",
|
||||
"\n",
|
||||
"#@markdown T4 = Good (*preferred*)\n",
|
||||
"\n",
|
||||
"#@markdown K80 = Meh\n",
|
||||
"\n",
|
||||
"#@markdown P4 = (*Not Recommended*) \n",
|
||||
"\n",
|
||||
"#@markdown ---\n",
|
||||
"\n",
|
||||
"!nvidia-smi -L"
|
||||
],
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Clone the repository and install dependencies."
|
||||
],
|
||||
"metadata": {
|
||||
"id": "WcZH9VE6JOCd"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "NG3JxFE6IreU"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!git clone https://github.com/sd-webui/stable-diffusion-webui.git"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"%cd /content/stable-diffusion-webui/"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "pZHGf03Vp305"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!git checkout dev\n",
|
||||
"!git pull"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "__8TYN2_jfga"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
@ -402,10 +303,14 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!python --version"
|
||||
"!git clone https://github.com/sd-webui/stable-diffusion-webui.git\n",
|
||||
"%cd /content/stable-diffusion-webui/\n",
|
||||
"!git checkout dev\n",
|
||||
"!git pull\n",
|
||||
"!wget -O arial.ttf https://github.com/matomo-org/travis-scripts/blob/master/fonts/Arial.ttf?raw=true"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "xd_2zFWSfNCB"
|
||||
"id": "pZHGf03Vp305"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
@ -424,32 +329,12 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"%cd /content/stable-diffusion-webui/"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "vXX0OaR8KyLQ"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"#@title Install dependencies.\n",
|
||||
"!python --version\n",
|
||||
"!pip install -r requirements.txt"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "REEG0zJtRC8w"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"%cd /content/stable-diffusion-webui/"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "Kp1PjqxPijZ1"
|
||||
"id": "vXX0OaR8KyLQ"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
@ -468,15 +353,39 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Huggingface Token"
|
||||
"#Launch the WebUI"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "RnlaaLAVGYal"
|
||||
"id": "csi6cj6gQZmC"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"#@title Mount Google Drive\n",
|
||||
"import os\n",
|
||||
"mount_google_drive = True #@param {type:\"boolean\"}\n",
|
||||
"save_outputs_to_drive = True #@param {type:\"boolean\"}\n",
|
||||
"\n",
|
||||
"if mount_google_drive:\n",
|
||||
" # Mount google drive to store your outputs.\n",
|
||||
" from google.colab import drive\n",
|
||||
" drive.mount('/content/drive/', force_remount=True)\n",
|
||||
"\n",
|
||||
"if save_outputs_to_drive:\n",
|
||||
" os.makedirs(\"/content/drive/MyDrive/stable-diffusion-webui/outputs\", exist_ok=True)\n",
|
||||
" os.symlink(\"/content/drive/MyDrive/stable-diffusion-webui/outputs\", \"/content/stable-diffusion-webui/outputs\", target_is_directory=True)\n"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "pcSWo9Zkzbsf"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"#@title Enter Huggingface token\n",
|
||||
"!git config --global credential.helper store\n",
|
||||
"!huggingface-cli login"
|
||||
],
|
||||
@ -486,36 +395,16 @@
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"# Google drive config"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "xMWVQOg0G1Pj"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"import os, shutil\n",
|
||||
"mount_google_drive = True #@param {type:\"boolean\"}\n",
|
||||
"save_outputs_to_drive = True #@param {type:\"boolean\"}\n",
|
||||
"#save_model_to_drive = True #@param {type:\"boolean\"}\n",
|
||||
"\n",
|
||||
"if mount_google_drive:\n",
|
||||
" # Mount google drive to store your outputs.\n",
|
||||
" from google.colab import drive\n",
|
||||
" drive.mount('/content/drive/', force_remount=True)\n",
|
||||
"\n",
|
||||
"if save_outputs_to_drive:\n",
|
||||
" os.makedirs(\"/content/drive/MyDrive/stable-diffusion-webui/outputs\", exist_ok=True)\n",
|
||||
" #os.makedirs(\"/content/stable-diffusion-webui/outputs\", exist_ok=True)\n",
|
||||
" os.symlink(\"/content/drive/MyDrive/stable-diffusion-webui/outputs\", \"/content/stable-diffusion-webui/outputs\", target_is_directory=True)\n"
|
||||
"#@title <-- Press play on the music player to keep the tab alive (Uses only 13MB of data)\n",
|
||||
"%%html\n",
|
||||
"<b>Press play on the music player to keep the tab alive, then start your generation below (Uses only 13MB of data)</b><br/>\n",
|
||||
"<audio src=\"https://henk.tech/colabkobold/silence.m4a\" controls>"
|
||||
],
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "pcSWo9Zkzbsf"
|
||||
"id": "-WknaU7uu_q6"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
@ -523,39 +412,26 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"#Launch the WebUI"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "csi6cj6gQZmC"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!streamlit run scripts/webui_streamlit.py --theme.base dark --server.headless True &>/content/logs.txt &"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "SN7C9-dyRlkM"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## Expose the port 8501\n",
|
||||
"Then just click in the `url` showed.\n",
|
||||
"JS to prevent idle timeout:\n",
|
||||
"\n",
|
||||
"A `log.txt`file will be created."
|
||||
"Press F12 OR CTRL + SHIFT + I OR right click on this website -> inspect. Then click on the console tab and paste in the following code.\n",
|
||||
"\n",
|
||||
"function ClickConnect(){\n",
|
||||
"console.log(\"Working\");\n",
|
||||
"document.querySelector(\"colab-toolbar-button#connect\").click()\n",
|
||||
"}\n",
|
||||
"setInterval(ClickConnect,60000)"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "h_KW9juhOCuH"
|
||||
"id": "pjIjiCuJysJI"
|
||||
}
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"!npx localtunnel --port 8501"
|
||||
"#@title Open port 8501 and start Streamlit server. Open link in 'link.txt' file in file pane on left.\n",
|
||||
"!npx localtunnel --port 8501 &>/content/link.txt &\n",
|
||||
"!streamlit run scripts/webui_streamlit.py --theme.base dark --server.headless true true 2>&1 | tee -a /content/log.txt"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "5whXm2nfSZ39"
|
||||
@ -564,4 +440,4 @@
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user