Added Google Drive mount feature to Colab Notebook.

This commit is contained in:
Lt.Dr.Data 2023-03-20 10:40:01 +09:00
parent 3ff4c155c9
commit ae87d8816f

View File

@ -1,29 +1,13 @@
{ {
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU",
"gpuClass": "standard"
},
"cells": [ "cells": [
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [
"Git clone the repo and install the requirements. (ignore the pip errors about protobuf)"
],
"metadata": { "metadata": {
"id": "aaaaaaaaaa" "id": "aaaaaaaaaa"
} },
"source": [
"Git clone the repo and install the requirements. (ignore the pip errors about protobuf)"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -33,22 +17,55 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!git clone https://github.com/comfyanonymous/ComfyUI\n", "#@title Environment Setup\n",
"%cd ComfyUI\n", "\n",
"!pip install xformers -r requirements.txt" "from pathlib import Path\n",
"\n",
"OPTIONS = {}\n",
"\n",
"USE_GOOGLE_DRIVE = True #@param {type:\"boolean\"}\n",
"UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n",
"WORKSPACE = 'ComfyUI'\n",
"OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n",
"OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n",
"\n",
"if OPTIONS['USE_GOOGLE_DRIVE']:\n",
" from google.colab import drive\n",
" drive.mount('/content/drive')\n",
"\n",
" global WORKSPACE\n",
" WORKSPACE = str(\n",
" Path('drive', 'MyDrive', WORKSPACE).resolve()\n",
" )\n",
" %cd /content/drive/MyDrive\n",
"\n",
"![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI\n",
"%cd $WORKSPACE\n",
"\n",
"if OPTIONS['UPDATE_COMFY_UI']:\n",
" !echo -= Updating ComfyUI =-\n",
" !git pull\n",
"\n",
"!pip -q install xformers -r requirements.txt\n",
"!pip -q install triton"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [
"Download some models/checkpoints/vae or custom comfyui nodes (uncomment the commands for the ones you want)"
],
"metadata": { "metadata": {
"id": "cccccccccc" "id": "cccccccccc"
} },
"source": [
"Download some models/checkpoints/vae or custom comfyui nodes (uncomment the commands for the ones you want)"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "dddddddddd"
},
"outputs": [],
"source": [ "source": [
"# Checkpoints\n", "# Checkpoints\n",
"\n", "\n",
@ -110,26 +127,26 @@
"#!wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth -P ./models/upscale_models/\n", "#!wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth -P ./models/upscale_models/\n",
"\n", "\n",
"\n" "\n"
], ]
"metadata": {
"id": "dddddddddd"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {
"id": "kkkkkkkkkkkkkk"
},
"source": [ "source": [
"### Run ComfyUI with localtunnel (Recommended Way)\n", "### Run ComfyUI with localtunnel (Recommended Way)\n",
"\n", "\n",
"\n" "\n"
], ]
"metadata": {
"id": "kkkkkkkkkkkkkk"
}
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "jjjjjjjjjjjjj"
},
"outputs": [],
"source": [ "source": [
"!npm install -g localtunnel\n", "!npm install -g localtunnel\n",
"\n", "\n",
@ -154,15 +171,13 @@
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n", "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
"\n", "\n",
"!python main.py --dont-print-server" "!python main.py --dont-print-server"
], ]
"metadata": {
"id": "jjjjjjjjjjjjj"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {
"id": "gggggggggg"
},
"source": [ "source": [
"### Run ComfyUI with colab iframe (use only in case the previous way with localtunnel doesn't work)\n", "### Run ComfyUI with colab iframe (use only in case the previous way with localtunnel doesn't work)\n",
"\n", "\n",
@ -171,13 +186,15 @@
"If you want to open it in another window use the link.\n", "If you want to open it in another window use the link.\n",
"\n", "\n",
"Note that some UI features like live image previews won't work because the colab iframe blocks websockets." "Note that some UI features like live image previews won't work because the colab iframe blocks websockets."
], ]
"metadata": {
"id": "gggggggggg"
}
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "hhhhhhhhhh"
},
"outputs": [],
"source": [ "source": [
"import threading\n", "import threading\n",
"import time\n", "import time\n",
@ -198,12 +215,23 @@
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n", "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
"\n", "\n",
"!python main.py --dont-print-server" "!python main.py --dont-print-server"
], ]
"metadata": {
"id": "hhhhhhhhhh"
},
"execution_count": null,
"outputs": []
} }
] ],
"metadata": {
"accelerator": "GPU",
"colab": {
"provenance": []
},
"gpuClass": "standard",
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
} }