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+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": [],
|
| 7 |
+
"gpuType": "T4"
|
| 8 |
+
},
|
| 9 |
+
"kernelspec": {
|
| 10 |
+
"name": "python3",
|
| 11 |
+
"display_name": "Python 3"
|
| 12 |
+
},
|
| 13 |
+
"language_info": {
|
| 14 |
+
"name": "python"
|
| 15 |
+
},
|
| 16 |
+
"accelerator": "GPU"
|
| 17 |
+
},
|
| 18 |
+
"cells": [
|
| 19 |
+
{
|
| 20 |
+
"cell_type": "code",
|
| 21 |
+
"source": [
|
| 22 |
+
"#@title 1. Install ComfyUI. { display-mode: \"form\" }\n",
|
| 23 |
+
"\n",
|
| 24 |
+
"# STEP 0: Install Python dependencies (termcolor, tqdm) silently\n",
|
| 25 |
+
"import subprocess\n",
|
| 26 |
+
"import os\n",
|
| 27 |
+
"import requests\n",
|
| 28 |
+
"import sys\n",
|
| 29 |
+
"\n",
|
| 30 |
+
"subprocess.run(\n",
|
| 31 |
+
" [sys.executable, \"-m\", \"pip\", \"install\", \"termcolor\", \"tqdm\", \"--quiet\"],\n",
|
| 32 |
+
" stdout=subprocess.DEVNULL,\n",
|
| 33 |
+
" stderr=subprocess.DEVNULL\n",
|
| 34 |
+
")\n",
|
| 35 |
+
"\n",
|
| 36 |
+
"# STEP 1: Imports\n",
|
| 37 |
+
"import os\n",
|
| 38 |
+
"import time\n",
|
| 39 |
+
"from IPython.display import clear_output\n",
|
| 40 |
+
"from tqdm.notebook import tqdm\n",
|
| 41 |
+
"from termcolor import cprint\n",
|
| 42 |
+
"\n",
|
| 43 |
+
"# === User-configurable Git Versions ===\n",
|
| 44 |
+
"# e.g., \"dev\", \"v1.3\", or commit hash\n",
|
| 45 |
+
"comfyui_version = \"\" #@param [\"255f1398\"] {allow-input: true}\n",
|
| 46 |
+
"custom_node_versions = {\n",
|
| 47 |
+
" \"ComfyUI-Manager\": \"\",\n",
|
| 48 |
+
" \"comfyui-impact-pack\": \"\",\n",
|
| 49 |
+
" \"comfyui-impact-subpack\": \"\"\n",
|
| 50 |
+
"}\n",
|
| 51 |
+
"\n",
|
| 52 |
+
"# === Logging Functions ===\n",
|
| 53 |
+
"def run_command_clean(cmd, cwd=None, show=True):\n",
|
| 54 |
+
" result = subprocess.run(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
|
| 55 |
+
" if show and result.stdout:\n",
|
| 56 |
+
" last_line = result.stdout.strip().split(\"\\n\")[-1]\n",
|
| 57 |
+
" cprint(\" βͺοΈ \" + last_line, \"cyan\")\n",
|
| 58 |
+
" return result\n",
|
| 59 |
+
"\n",
|
| 60 |
+
"def print_step(msg): cprint(f\"\\nβ€ {msg}\", \"yellow\")\n",
|
| 61 |
+
"def print_success(msg): cprint(f\"β
{msg}\", \"green\")\n",
|
| 62 |
+
"def print_info(msg): cprint(f\" β {msg}\", \"blue\")\n",
|
| 63 |
+
"def print_error(msg): cprint(f\"β {msg}\", \"red\")\n",
|
| 64 |
+
"\n",
|
| 65 |
+
"def checkout_version(path, version):\n",
|
| 66 |
+
" if version:\n",
|
| 67 |
+
" subprocess.run([\"git\", \"fetch\"], cwd=path, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\n",
|
| 68 |
+
" subprocess.run([\"git\", \"checkout\", version], cwd=path, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\n",
|
| 69 |
+
"\n",
|
| 70 |
+
"def get_git_commit_hash(path):\n",
|
| 71 |
+
" try:\n",
|
| 72 |
+
" return subprocess.check_output([\"git\", \"rev-parse\", \"--short\", \"HEAD\"], cwd=path).decode().strip()\n",
|
| 73 |
+
" except:\n",
|
| 74 |
+
" return \"unknown\"\n",
|
| 75 |
+
"\n",
|
| 76 |
+
"# === Setup Progress ===\n",
|
| 77 |
+
"tasks = [\n",
|
| 78 |
+
" \"Clone ComfyUI\",\n",
|
| 79 |
+
" \"Install ComfyUI Requirements\",\n",
|
| 80 |
+
" \"Clone/Pull Custom Nodes\",\n",
|
| 81 |
+
" \"Install Custom Node Requirements\",\n",
|
| 82 |
+
" \"Install Imp Models\"\n",
|
| 83 |
+
"]\n",
|
| 84 |
+
"\n",
|
| 85 |
+
"overall_start = time.time()\n",
|
| 86 |
+
"progress_bar = tqdm(total=len(tasks), desc=\"π§ Setting Up ComfyUI\", bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}]')\n",
|
| 87 |
+
"\n",
|
| 88 |
+
"# STEP 2: Clone ComfyUI\n",
|
| 89 |
+
"comfyui_path = \"/content/ComfyUI\"\n",
|
| 90 |
+
"if not os.path.exists(comfyui_path):\n",
|
| 91 |
+
" print_step(\"Cloning ComfyUI...\")\n",
|
| 92 |
+
" t0 = time.time()\n",
|
| 93 |
+
" run_command_clean([\"git\", \"clone\", \"https://github.com/comfyanonymous/ComfyUI\", comfyui_path], show=False)\n",
|
| 94 |
+
" if comfyui_version:\n",
|
| 95 |
+
" print_info(f\"Switching to version: {comfyui_version}\")\n",
|
| 96 |
+
" checkout_version(comfyui_path, comfyui_version)\n",
|
| 97 |
+
" hash = get_git_commit_hash(comfyui_path)\n",
|
| 98 |
+
" print_success(f\"ComfyUI cloned (version: {hash}) in {time.time() - t0:.2f}s\")\n",
|
| 99 |
+
"else:\n",
|
| 100 |
+
" print_step(\"ComfyUI already exists. Skipping clone.\")\n",
|
| 101 |
+
" if comfyui_version:\n",
|
| 102 |
+
" print_info(f\"Switching to version: {comfyui_version}\")\n",
|
| 103 |
+
" checkout_version(comfyui_path, comfyui_version)\n",
|
| 104 |
+
" hash = get_git_commit_hash(comfyui_path)\n",
|
| 105 |
+
" print_success(f\"Using ComfyUI (version: {hash})\")\n",
|
| 106 |
+
"progress_bar.update(1)\n",
|
| 107 |
+
"\n",
|
| 108 |
+
"# STEP 3: Install ComfyUI requirements\n",
|
| 109 |
+
"print_step(\"Installing ComfyUI requirements...\")\n",
|
| 110 |
+
"t0 = time.time()\n",
|
| 111 |
+
"run_command_clean([\n",
|
| 112 |
+
" \"pip\", \"install\", \"-r\", f\"{comfyui_path}/requirements.txt\",\n",
|
| 113 |
+
" \"--no-cache-dir\", \"--no-warn-script-location\", \"--quiet\"\n",
|
| 114 |
+
"], show=False)\n",
|
| 115 |
+
"print_success(f\"ComfyUI requirements installed in {time.time() - t0:.2f}s\")\n",
|
| 116 |
+
"progress_bar.update(1)\n",
|
| 117 |
+
"\n",
|
| 118 |
+
"# STEP 4: Clone or Pull Custom Nodes\n",
|
| 119 |
+
"custom_nodes = {\n",
|
| 120 |
+
" \"ComfyUI-Manager\": \"https://github.com/ltdrdata/ComfyUI-Manager.git\",\n",
|
| 121 |
+
" \"comfyui-impact-pack\": \"https://github.com/ltdrdata/comfyui-impact-pack.git\",\n",
|
| 122 |
+
" \"comfyui-impact-subpack\": \"https://github.com/ltdrdata/comfyui-impact-subpack.git\"\n",
|
| 123 |
+
"}\n",
|
| 124 |
+
"base_path = f\"{comfyui_path}/custom_nodes\"\n",
|
| 125 |
+
"os.makedirs(base_path, exist_ok=True)\n",
|
| 126 |
+
"\n",
|
| 127 |
+
"for name, url in custom_nodes.items():\n",
|
| 128 |
+
" repo_path = os.path.join(base_path, name)\n",
|
| 129 |
+
" if not os.path.exists(repo_path):\n",
|
| 130 |
+
" print_step(f\"Cloning {name}...\")\n",
|
| 131 |
+
" t0 = time.time()\n",
|
| 132 |
+
" run_command_clean([\"git\", \"clone\", url, repo_path], show=False)\n",
|
| 133 |
+
" if custom_node_versions.get(name):\n",
|
| 134 |
+
" print_info(f\"Switching {name} to {custom_node_versions[name]}\")\n",
|
| 135 |
+
" checkout_version(repo_path, custom_node_versions[name])\n",
|
| 136 |
+
" hash = get_git_commit_hash(repo_path)\n",
|
| 137 |
+
" print_success(f\"{name} cloned (version: {hash}) in {time.time() - t0:.2f}s\")\n",
|
| 138 |
+
" else:\n",
|
| 139 |
+
" print_step(f\"Pulling latest for {name}...\")\n",
|
| 140 |
+
" t0 = time.time()\n",
|
| 141 |
+
" run_command_clean([\"git\", \"pull\"], cwd=repo_path, show=False)\n",
|
| 142 |
+
" if custom_node_versions.get(name):\n",
|
| 143 |
+
" print_info(f\"Switching {name} to {custom_node_versions[name]}\")\n",
|
| 144 |
+
" checkout_version(repo_path, custom_node_versions[name])\n",
|
| 145 |
+
" hash = get_git_commit_hash(repo_path)\n",
|
| 146 |
+
" print_success(f\"{name} updated (version: {hash}) in {time.time() - t0:.2f}s\")\n",
|
| 147 |
+
"progress_bar.update(1)\n",
|
| 148 |
+
"\n",
|
| 149 |
+
"# STEP 5: Install requirements.txt in each custom node\n",
|
| 150 |
+
"for name in custom_nodes:\n",
|
| 151 |
+
" req_path = f\"{base_path}/{name}/requirements.txt\"\n",
|
| 152 |
+
" if os.path.exists(req_path):\n",
|
| 153 |
+
" print_step(f\"Installing requirements for {name}...\")\n",
|
| 154 |
+
" t0 = time.time()\n",
|
| 155 |
+
" run_command_clean([\n",
|
| 156 |
+
" \"pip\", \"install\", \"-r\", req_path,\n",
|
| 157 |
+
" \"--no-cache-dir\", \"--no-warn-script-location\", \"--quiet\"\n",
|
| 158 |
+
" ], show=False)\n",
|
| 159 |
+
" print_success(f\"{name} requirements installed in {time.time() - t0:.2f}s\")\n",
|
| 160 |
+
"progress_bar.update(1)\n",
|
| 161 |
+
"\n",
|
| 162 |
+
"#STEP 6: Download Imp Models\n",
|
| 163 |
+
"# Model URLs and target folders\n",
|
| 164 |
+
"print_step(\"Install Imp Models\")\n",
|
| 165 |
+
"models = {\n",
|
| 166 |
+
" \"sam_vit_b_01ec64.pth\": {\n",
|
| 167 |
+
" \"url\": \"https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/sams/sam_vit_b_01ec64.pth\",\n",
|
| 168 |
+
" \"folder\": f\"{comfyui_path}/models/sams\"\n",
|
| 169 |
+
" },\n",
|
| 170 |
+
" \"face_yolov8m.pt\": {\n",
|
| 171 |
+
" \"url\": \"https://huggingface.co/outfly/face_yolov8m/resolve/main/face_yolov8m.pt\",\n",
|
| 172 |
+
" \"folder\": f\"{comfyui_path}/models/ultralytics/bbox\"\n",
|
| 173 |
+
" },\n",
|
| 174 |
+
" \"sdxl.vae.safetensors\": {\n",
|
| 175 |
+
" \"url\": \"https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl.vae.safetensors\",\n",
|
| 176 |
+
" \"folder\": f\"{comfyui_path}/models/vae/SDXL\"\n",
|
| 177 |
+
" },\n",
|
| 178 |
+
" \"taesdxl_decoder.pth\": {\n",
|
| 179 |
+
" \"url\": \"https://github.com/madebyollin/taesd/raw/main/taesdxl_decoder.pth\",\n",
|
| 180 |
+
" \"folder\": f\"{comfyui_path}/models/vae_approx\"\n",
|
| 181 |
+
" },\n",
|
| 182 |
+
" \"taesdxl_encoder.pth\": {\n",
|
| 183 |
+
" \"url\": \"https://github.com/madebyollin/taesd/raw/main/taesdxl_encoder.pth\",\n",
|
| 184 |
+
" \"folder\": f\"{comfyui_path}/models/vae_approx\"\n",
|
| 185 |
+
" },\n",
|
| 186 |
+
" \"comfy.settings.json\": {\n",
|
| 187 |
+
" \"url\": \"https://huggingface.co/datasets/ysb123/cmfUI/resolve/main/comfy.settings.json\",\n",
|
| 188 |
+
" \"folder\": f\"{comfyui_path}/user/default/\"\n",
|
| 189 |
+
" },\n",
|
| 190 |
+
" \"config.ini\": {\n",
|
| 191 |
+
" \"url\": \"https://huggingface.co/datasets/ysb123/cmfUI/resolve/main/ui/config.ini\",\n",
|
| 192 |
+
" \"folder\": f\"{comfyui_path}/user/default/ComfyUI-Manager/\"\n",
|
| 193 |
+
" }\n",
|
| 194 |
+
"}\n",
|
| 195 |
+
"\n",
|
| 196 |
+
"def download_model(name, url, folder):\n",
|
| 197 |
+
" os.makedirs(folder, exist_ok=True)\n",
|
| 198 |
+
" file_path = os.path.join(folder, name)\n",
|
| 199 |
+
"\n",
|
| 200 |
+
" if os.path.exists(file_path):\n",
|
| 201 |
+
" print(f\"β
{name} already exists at {file_path}. Skipping download.\")\n",
|
| 202 |
+
" return\n",
|
| 203 |
+
"\n",
|
| 204 |
+
" print(f\"β¬οΈ Downloading {name} to {file_path}...\")\n",
|
| 205 |
+
" try:\n",
|
| 206 |
+
" with requests.get(url, stream=True) as r:\n",
|
| 207 |
+
" r.raise_for_status()\n",
|
| 208 |
+
" with open(file_path, 'wb') as f:\n",
|
| 209 |
+
" for chunk in r.iter_content(chunk_size=8192):\n",
|
| 210 |
+
" if chunk:\n",
|
| 211 |
+
" f.write(chunk)\n",
|
| 212 |
+
" print_success(f\"{name} requirements installed in {time.time() - t0:.2f}s\")\n",
|
| 213 |
+
" except Exception as e:\n",
|
| 214 |
+
" print(f\"β Failed to download {name}: {e}\")\n",
|
| 215 |
+
"\n",
|
| 216 |
+
"# Loop through and download each model\n",
|
| 217 |
+
"for model_name, info in models.items():\n",
|
| 218 |
+
" download_model(model_name, info[\"url\"], info[\"folder\"])\n",
|
| 219 |
+
"\n",
|
| 220 |
+
"progress_bar.update(1)\n",
|
| 221 |
+
"\n",
|
| 222 |
+
"# Final Output\n",
|
| 223 |
+
"progress_bar.close()\n",
|
| 224 |
+
"clear_output()\n",
|
| 225 |
+
"cprint(\"π All components installed successfully!\", \"green\", attrs=[\"bold\"])\n",
|
| 226 |
+
"cprint(f\"β±οΈ Total setup time: {time.time() - overall_start:.2f} seconds.\", \"blue\", attrs=[\"bold\"])\n"
|
| 227 |
+
],
|
| 228 |
+
"metadata": {
|
| 229 |
+
"id": "wYii9YaCYKIy"
|
| 230 |
+
},
|
| 231 |
+
"execution_count": null,
|
| 232 |
+
"outputs": []
|
| 233 |
+
},
|
| 234 |
+
{
|
| 235 |
+
"cell_type": "code",
|
| 236 |
+
"source": [
|
| 237 |
+
"#@title 2. Download model. { display-mode: \"form\" }\n",
|
| 238 |
+
"import os\n",
|
| 239 |
+
"import requests\n",
|
| 240 |
+
"def download_civitai_model(bearer_token, download_url, save_path):\n",
|
| 241 |
+
" \"\"\"\n",
|
| 242 |
+
" Downloads a model from Civitai using a bearer token with progress bar.\n",
|
| 243 |
+
"\n",
|
| 244 |
+
" Args:\n",
|
| 245 |
+
" bearer_token: Your Civitai bearer token.\n",
|
| 246 |
+
" download_url: The URL of the model to download.\n",
|
| 247 |
+
" save_path: The full path to save the downloaded file.\n",
|
| 248 |
+
" \"\"\"\n",
|
| 249 |
+
" headers = {\"Authorization\": f\"Bearer {bearer_token}\"}\n",
|
| 250 |
+
" response = requests.get(download_url, headers=headers, stream=True)\n",
|
| 251 |
+
"\n",
|
| 252 |
+
" if response.status_code == 200:\n",
|
| 253 |
+
" os.makedirs(os.path.dirname(save_path), exist_ok=True)\n",
|
| 254 |
+
"\n",
|
| 255 |
+
" total_size = int(response.headers.get(\"Content-Length\", 0))\n",
|
| 256 |
+
" chunk_size = 1024\n",
|
| 257 |
+
"\n",
|
| 258 |
+
" with open(save_path, \"wb\") as f, tqdm(\n",
|
| 259 |
+
" desc=\"π₯ Downloading model\",\n",
|
| 260 |
+
" total=total_size,\n",
|
| 261 |
+
" unit=\"B\",\n",
|
| 262 |
+
" unit_scale=True,\n",
|
| 263 |
+
" unit_divisor=1024,\n",
|
| 264 |
+
" colour=\"green\"\n",
|
| 265 |
+
" ) as bar:\n",
|
| 266 |
+
" for chunk in response.iter_content(chunk_size=chunk_size):\n",
|
| 267 |
+
" if chunk:\n",
|
| 268 |
+
" f.write(chunk)\n",
|
| 269 |
+
" bar.update(len(chunk))\n",
|
| 270 |
+
"\n",
|
| 271 |
+
" cprint(\"β
Model downloaded successfully.\", \"cyan\", attrs=[\"bold\"])\n",
|
| 272 |
+
" else:\n",
|
| 273 |
+
" cprint(\"β Failed to download model\", \"red\", attrs=[\"bold\"])\n",
|
| 274 |
+
"\n",
|
| 275 |
+
"# Example usage:\n",
|
| 276 |
+
"bearer_token = \"6748e0f8e6085cd9349551385ce8943a\"\n",
|
| 277 |
+
"download_url = \"https://civitai.com/api/download/models/2120520?type=Model&format=SafeTensor&size=pruned&fp=fp16\" # @param {type: \"string\"}\n",
|
| 278 |
+
"model_name = \"Banana_Splitz\" # @param {type: \"string\"}\n",
|
| 279 |
+
"save_path = f\"/content/ComfyUI/models/checkpoints/{model_name}.safetensors\"\n",
|
| 280 |
+
"\n",
|
| 281 |
+
"download_civitai_model(bearer_token, download_url, save_path)"
|
| 282 |
+
],
|
| 283 |
+
"metadata": {
|
| 284 |
+
"id": "C3aD3qzOWeJ7"
|
| 285 |
+
},
|
| 286 |
+
"execution_count": null,
|
| 287 |
+
"outputs": []
|
| 288 |
+
},
|
| 289 |
+
{
|
| 290 |
+
"cell_type": "code",
|
| 291 |
+
"source": [
|
| 292 |
+
"#@title 2. Download model. { display-mode: \"form\" }\n",
|
| 293 |
+
"import os\n",
|
| 294 |
+
"import requests\n",
|
| 295 |
+
"def download_civitai_model(bearer_token, download_url, save_path):\n",
|
| 296 |
+
" \"\"\"\n",
|
| 297 |
+
" Downloads a model from Civitai using a bearer token with progress bar.\n",
|
| 298 |
+
"\n",
|
| 299 |
+
" Args:\n",
|
| 300 |
+
" bearer_token: Your Civitai bearer token.\n",
|
| 301 |
+
" download_url: The URL of the model to download.\n",
|
| 302 |
+
" save_path: The full path to save the downloaded file.\n",
|
| 303 |
+
" \"\"\"\n",
|
| 304 |
+
" headers = {\"Authorization\": f\"Bearer {bearer_token}\"}\n",
|
| 305 |
+
" response = requests.get(download_url, headers=headers, stream=True)\n",
|
| 306 |
+
"\n",
|
| 307 |
+
" if response.status_code == 200:\n",
|
| 308 |
+
" os.makedirs(os.path.dirname(save_path), exist_ok=True)\n",
|
| 309 |
+
"\n",
|
| 310 |
+
" total_size = int(response.headers.get(\"Content-Length\", 0))\n",
|
| 311 |
+
" chunk_size = 1024\n",
|
| 312 |
+
"\n",
|
| 313 |
+
" with open(save_path, \"wb\") as f, tqdm(\n",
|
| 314 |
+
" desc=\"π₯ Downloading model\",\n",
|
| 315 |
+
" total=total_size,\n",
|
| 316 |
+
" unit=\"B\",\n",
|
| 317 |
+
" unit_scale=True,\n",
|
| 318 |
+
" unit_divisor=1024,\n",
|
| 319 |
+
" colour=\"green\"\n",
|
| 320 |
+
" ) as bar:\n",
|
| 321 |
+
" for chunk in response.iter_content(chunk_size=chunk_size):\n",
|
| 322 |
+
" if chunk:\n",
|
| 323 |
+
" f.write(chunk)\n",
|
| 324 |
+
" bar.update(len(chunk))\n",
|
| 325 |
+
"\n",
|
| 326 |
+
" cprint(\"β
Model downloaded successfully.\", \"cyan\", attrs=[\"bold\"])\n",
|
| 327 |
+
" else:\n",
|
| 328 |
+
" cprint(\"β Failed to download model\", \"red\", attrs=[\"bold\"])\n",
|
| 329 |
+
"\n",
|
| 330 |
+
"# Example usage:\n",
|
| 331 |
+
"bearer_token = \"6748e0f8e6085cd9349551385ce8943a\"\n",
|
| 332 |
+
"download_url = \"https://civitai.com/api/download/models/1964784?type=Model&format=SafeTensor&size=pruned&fp=fp16\" # @param {type: \"string\"}\n",
|
| 333 |
+
"model_name = \"Nova_ExAnime\" # @param {type: \"string\"}\n",
|
| 334 |
+
"save_path = f\"/content/ComfyUI/models/checkpoints/{model_name}.safetensors\"\n",
|
| 335 |
+
"\n",
|
| 336 |
+
"download_civitai_model(bearer_token, download_url, save_path)"
|
| 337 |
+
],
|
| 338 |
+
"metadata": {
|
| 339 |
+
"id": "w_p94M38QpMl"
|
| 340 |
+
},
|
| 341 |
+
"execution_count": null,
|
| 342 |
+
"outputs": []
|
| 343 |
+
},
|
| 344 |
+
{
|
| 345 |
+
"cell_type": "code",
|
| 346 |
+
"source": [
|
| 347 |
+
"#@title 4. Start Localtunnel. { display-mode: \"form\" }\n",
|
| 348 |
+
"# %cd into ComfyUI folder\n",
|
| 349 |
+
"%cd /content/ComfyUI\n",
|
| 350 |
+
"\n",
|
| 351 |
+
"# Silent install of termcolor and localtunnel\n",
|
| 352 |
+
"!pip install termcolor > /dev/null 2>&1\n",
|
| 353 |
+
"!npm install -g localtunnel > /dev/null 2>&1\n",
|
| 354 |
+
"\n",
|
| 355 |
+
"# Python setup\n",
|
| 356 |
+
"import subprocess\n",
|
| 357 |
+
"import threading\n",
|
| 358 |
+
"import time\n",
|
| 359 |
+
"import socket\n",
|
| 360 |
+
"import urllib.request\n",
|
| 361 |
+
"from termcolor import cprint\n",
|
| 362 |
+
"from IPython.display import display, HTML\n",
|
| 363 |
+
"\n",
|
| 364 |
+
"def wait_for_server(port):\n",
|
| 365 |
+
" while True:\n",
|
| 366 |
+
" time.sleep(0.5)\n",
|
| 367 |
+
" with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:\n",
|
| 368 |
+
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
| 369 |
+
" if result == 0:\n",
|
| 370 |
+
" break\n",
|
| 371 |
+
"\n",
|
| 372 |
+
" cprint(\"\\nπ ComfyUI has started successfully!\", \"green\", attrs=[\"bold\"])\n",
|
| 373 |
+
" cprint(\"π Setting up LocalTunnel for public access...\\n\", \"cyan\")\n",
|
| 374 |
+
"\n",
|
| 375 |
+
" try:\n",
|
| 376 |
+
" ip = urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\")\n",
|
| 377 |
+
"\n",
|
| 378 |
+
" # Display IP with click-to-copy box\n",
|
| 379 |
+
" html = f\"\"\"\n",
|
| 380 |
+
" <div style=\"font-family: monospace; font-size: 18px;\">\n",
|
| 381 |
+
" <strong>π Public IP:</strong>\n",
|
| 382 |
+
" <div onclick=\"navigator.clipboard.writeText('{ip}'); this.innerHTML='π {ip} (Copied!)'; this.style.color='green';\"\n",
|
| 383 |
+
" style=\"cursor: pointer; border: 1px solid #ccc; padding: 10px; width: fit-content; border-radius: 6px; margin-top: 6px;\">\n",
|
| 384 |
+
" π {ip} (Click to copy)\n",
|
| 385 |
+
" </div>\n",
|
| 386 |
+
" </div>\n",
|
| 387 |
+
" \"\"\"\n",
|
| 388 |
+
" display(HTML(html))\n",
|
| 389 |
+
" except:\n",
|
| 390 |
+
" cprint(\"β οΈ Failed to retrieve public IP\", \"red\")\n",
|
| 391 |
+
"\n",
|
| 392 |
+
" cprint(\"π Connecting LocalTunnel (please wait)...\", \"yellow\")\n",
|
| 393 |
+
" process = subprocess.Popen([\"lt\", \"--port\", f\"{port}\"], stdout=subprocess.PIPE)\n",
|
| 394 |
+
" for line in process.stdout:\n",
|
| 395 |
+
" print(\"π\", line.decode(), end='')\n",
|
| 396 |
+
"\n",
|
| 397 |
+
"# Start server watcher thread\n",
|
| 398 |
+
"threading.Thread(target=wait_for_server, daemon=True, args=(8188,)).start()\n",
|
| 399 |
+
"\n",
|
| 400 |
+
"# Launch ComfyUI silently in CPU mode then add --cpu\n",
|
| 401 |
+
"!python main.py --dont-print-server --use-split-cross-attention --reserve-vram 2048 > /dev/null 2>&1"
|
| 402 |
+
],
|
| 403 |
+
"metadata": {
|
| 404 |
+
"id": "TUfeaupMKOLx"
|
| 405 |
+
},
|
| 406 |
+
"execution_count": null,
|
| 407 |
+
"outputs": []
|
| 408 |
+
},
|
| 409 |
+
{
|
| 410 |
+
"cell_type": "code",
|
| 411 |
+
"source": [
|
| 412 |
+
"#@title Start Zrok. { display-mode: \"form\" }\n",
|
| 413 |
+
"import os\n",
|
| 414 |
+
"import tarfile\n",
|
| 415 |
+
"import requests\n",
|
| 416 |
+
"import subprocess\n",
|
| 417 |
+
"import time\n",
|
| 418 |
+
"import socket\n",
|
| 419 |
+
"import re\n",
|
| 420 |
+
"from termcolor import cprint\n",
|
| 421 |
+
"\n",
|
| 422 |
+
"%cd /content/ComfyUI/\n",
|
| 423 |
+
"\n",
|
| 424 |
+
"zrok_url = \"https://github.com/openziti/zrok/releases/download/v1.0.7/zrok_1.0.7_linux_amd64.tar.gz\"\n",
|
| 425 |
+
"zrok_tar = \"/content/zrok_1.0.7_linux_amd64.tar.gz\"\n",
|
| 426 |
+
"zrok_install_path = \"/usr/local/bin/zrok\"\n",
|
| 427 |
+
"zrok_token = \" \" #@param {type: \"string\"}\n",
|
| 428 |
+
"port = 8188\n",
|
| 429 |
+
"\n",
|
| 430 |
+
"# ========== STEP 1: Launch ComfyUI ==========\n",
|
| 431 |
+
"cprint(\"π Starting ComfyUI...\", \"yellow\")\n",
|
| 432 |
+
"comfy_process = subprocess.Popen([\n",
|
| 433 |
+
" \"python\", \"main.py\",\n",
|
| 434 |
+
" \"--dont-print-server\",\n",
|
| 435 |
+
" \"--reserve-vram\",\n",
|
| 436 |
+
" \"2048\"\n",
|
| 437 |
+
"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)\n",
|
| 438 |
+
"\n",
|
| 439 |
+
"# ========== STEP 2: Wait for ComfyUI to Open Port ==========\n",
|
| 440 |
+
"print(f\"β³ Waiting for ComfyUI to launch on port {port}...\")\n",
|
| 441 |
+
"start_time = time.time()\n",
|
| 442 |
+
"timeout = 60\n",
|
| 443 |
+
"while time.time() - start_time < timeout:\n",
|
| 444 |
+
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
| 445 |
+
" result = sock.connect_ex((\"127.0.0.1\", port))\n",
|
| 446 |
+
" sock.close()\n",
|
| 447 |
+
" if result == 0:\n",
|
| 448 |
+
" print(f\"β
ComfyUI launched on port {port}.\")\n",
|
| 449 |
+
" break\n",
|
| 450 |
+
" time.sleep(1)\n",
|
| 451 |
+
"else:\n",
|
| 452 |
+
" print(\"β ComfyUI failed to start within timeout.\")\n",
|
| 453 |
+
" stderr = comfy_process.stderr.read().decode()\n",
|
| 454 |
+
" print(stderr)\n",
|
| 455 |
+
" comfy_process.kill()\n",
|
| 456 |
+
" raise SystemExit(1)\n",
|
| 457 |
+
"\n",
|
| 458 |
+
"# ========== STEP 3: Download & Install Zrok ==========\n",
|
| 459 |
+
"try:\n",
|
| 460 |
+
" print(f\"π₯ Downloading zrok from {zrok_url} ...\")\n",
|
| 461 |
+
" response = requests.get(zrok_url, stream=True)\n",
|
| 462 |
+
" response.raise_for_status()\n",
|
| 463 |
+
" with open(zrok_tar, 'wb') as f:\n",
|
| 464 |
+
" for chunk in response.iter_content(chunk_size=8192):\n",
|
| 465 |
+
" f.write(chunk)\n",
|
| 466 |
+
"\n",
|
| 467 |
+
" with tarfile.open(zrok_tar, \"r:gz\") as tar:\n",
|
| 468 |
+
" tar.extractall()\n",
|
| 469 |
+
"\n",
|
| 470 |
+
" os.rename(\"zrok\", zrok_install_path)\n",
|
| 471 |
+
" os.chmod(zrok_install_path, 0o755)\n",
|
| 472 |
+
" print(f\"β
zrok installed at {zrok_install_path}\")\n",
|
| 473 |
+
"except Exception as e:\n",
|
| 474 |
+
" print(f\"β Failed to install zrok: {e}\")\n",
|
| 475 |
+
" comfy_process.kill()\n",
|
| 476 |
+
" raise SystemExit(1)\n",
|
| 477 |
+
"\n",
|
| 478 |
+
"!zrok disable\n",
|
| 479 |
+
"!zrok enable --headless dKgBfycQOK3k\n",
|
| 480 |
+
"\n",
|
| 481 |
+
"# ========== STEP 4: Configure Zrok Token ==========\n",
|
| 482 |
+
"try:\n",
|
| 483 |
+
" zrok_config_dir = os.path.expanduser(\"~/.zrok\")\n",
|
| 484 |
+
" os.makedirs(zrok_config_dir, exist_ok=True)\n",
|
| 485 |
+
" with open(os.path.join(zrok_config_dir, \"token\"), \"w\") as f:\n",
|
| 486 |
+
" f.write(zrok_token)\n",
|
| 487 |
+
" print(\"β
zrok token configured.\")\n",
|
| 488 |
+
"except Exception as e:\n",
|
| 489 |
+
" print(f\"β Failed to set token: {e}\")\n",
|
| 490 |
+
" comfy_process.kill()\n",
|
| 491 |
+
" raise SystemExit(1)\n",
|
| 492 |
+
"\n",
|
| 493 |
+
"# ========== STEP 5: Launch Zrok Share ==========\n",
|
| 494 |
+
"try:\n",
|
| 495 |
+
" cprint(\"π Launching zrok tunnel...\", \"yellow\")\n",
|
| 496 |
+
" proc = subprocess.Popen(\n",
|
| 497 |
+
" [zrok_install_path, \"share\", \"public\", \"--headless\", f\"http://localhost:{port}\"],\n",
|
| 498 |
+
" stdout=subprocess.PIPE,\n",
|
| 499 |
+
" stderr=subprocess.STDOUT,\n",
|
| 500 |
+
" text=True,\n",
|
| 501 |
+
" )\n",
|
| 502 |
+
"\n",
|
| 503 |
+
" share_url = None\n",
|
| 504 |
+
" start_time = time.time()\n",
|
| 505 |
+
" while time.time() - start_time < 20:\n",
|
| 506 |
+
" line = proc.stdout.readline()\n",
|
| 507 |
+
" if not line:\n",
|
| 508 |
+
" continue\n",
|
| 509 |
+
" # print(\"π\", line.strip())\n",
|
| 510 |
+
"\n",
|
| 511 |
+
" match = re.search(r'(https://[a-zA-Z0-9]+\\.share\\.zrok\\.io)', line)\n",
|
| 512 |
+
" if match:\n",
|
| 513 |
+
" share_url = match.group(1)\n",
|
| 514 |
+
" break\n",
|
| 515 |
+
"\n",
|
| 516 |
+
" if share_url:\n",
|
| 517 |
+
" cprint(f\"\\nβ
ComfyUI Public URL (via zrok): {share_url}\\n\", \"cyan\", attrs=[\"bold\"])\n",
|
| 518 |
+
" else:\n",
|
| 519 |
+
" print(\"β Could not detect zrok share link.\")\n",
|
| 520 |
+
" comfy_process.kill()\n",
|
| 521 |
+
" proc.kill()\n",
|
| 522 |
+
" raise SystemExit(1)\n",
|
| 523 |
+
"\n",
|
| 524 |
+
"except Exception as e:\n",
|
| 525 |
+
" print(f\"β Error starting zrok: {e}\")\n",
|
| 526 |
+
" comfy_process.kill()\n",
|
| 527 |
+
" raise SystemExit(1)\n",
|
| 528 |
+
"\n",
|
| 529 |
+
"\n",
|
| 530 |
+
"try:\n",
|
| 531 |
+
" cprint(\"π’ ComfyUI and zrok tunnel are running. Press Ctrl+C or stop execution to end.\", \"green\")\n",
|
| 532 |
+
" while True:\n",
|
| 533 |
+
" time.sleep(60)\n",
|
| 534 |
+
"except KeyboardInterrupt:\n",
|
| 535 |
+
" cprint(\"π Shutting down...\", \"red\")\n",
|
| 536 |
+
" comfy_process.kill()\n",
|
| 537 |
+
" proc.kill()\n"
|
| 538 |
+
],
|
| 539 |
+
"metadata": {
|
| 540 |
+
"id": "iykw1m_Hj7AY"
|
| 541 |
+
},
|
| 542 |
+
"execution_count": null,
|
| 543 |
+
"outputs": []
|
| 544 |
+
},
|
| 545 |
+
{
|
| 546 |
+
"cell_type": "code",
|
| 547 |
+
"source": [
|
| 548 |
+
"#@title Start tunnelmole. { display-mode: \"form\" }\n",
|
| 549 |
+
"# ====================== π οΈ SYSTEM BOOT ======================\n",
|
| 550 |
+
"import subprocess, socket, time\n",
|
| 551 |
+
"from termcolor import cprint\n",
|
| 552 |
+
"\n",
|
| 553 |
+
"port = 8188\n",
|
| 554 |
+
"\n",
|
| 555 |
+
"# ========== πΎ Installing Tunnelmole Dependencies ==========\n",
|
| 556 |
+
"!curl -fsSL https://deb.nodesource.com/setup_18.x | bash - > /dev/null\n",
|
| 557 |
+
"!apt-get install -y nodejs > /dev/null\n",
|
| 558 |
+
"!npm install -g tunnelmole > /dev/null\n",
|
| 559 |
+
"\n",
|
| 560 |
+
"# ================== π INIT: ComfyUI LAUNCH ==================\n",
|
| 561 |
+
"%cd /content/ComfyUI\n",
|
| 562 |
+
"cprint(\"π§ [SYS-CPU] Initializing ComfyUI Neural Core...\", \"magenta\", attrs=[\"bold\", \"reverse\"])\n",
|
| 563 |
+
"comfy = subprocess.Popen([\n",
|
| 564 |
+
" \"python3\", \"main.py\",\n",
|
| 565 |
+
"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)\n",
|
| 566 |
+
"\n",
|
| 567 |
+
"# ============ π STATUS: Waiting for Port Ready ============\n",
|
| 568 |
+
"cprint(\"β³ Awaiting port 8188 β‘ Interface boot sequence...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 569 |
+
"while True:\n",
|
| 570 |
+
" try:\n",
|
| 571 |
+
" with socket.create_connection((\"127.0.0.1\", port), timeout=1):\n",
|
| 572 |
+
" break\n",
|
| 573 |
+
" except OSError:\n",
|
| 574 |
+
" time.sleep(1)\n",
|
| 575 |
+
"\n",
|
| 576 |
+
"cprint(\"β
[BOOT SUCCESS] ComfyUI Neural Interface Ready!\", \"green\", attrs=[\"bold\", \"reverse\"])\n",
|
| 577 |
+
"\n",
|
| 578 |
+
"# ============== π LAUNCH: Tunnelmole ==============\n",
|
| 579 |
+
"cprint(\"π Deploying Tunnelmole Gateway...\", \"blue\", attrs=[\"bold\"])\n",
|
| 580 |
+
"try:\n",
|
| 581 |
+
" tunnel = subprocess.Popen([\"tmole\", str(port)],\n",
|
| 582 |
+
" stdout=subprocess.PIPE,\n",
|
| 583 |
+
" stderr=subprocess.STDOUT,\n",
|
| 584 |
+
" text=True)\n",
|
| 585 |
+
" for line in tunnel.stdout:\n",
|
| 586 |
+
" if \"https://\" in line:\n",
|
| 587 |
+
" cprint(f\"π [π LINK READY]: {line.strip()}\", \"cyan\", attrs=[\"bold\", \"underline\"])\n",
|
| 588 |
+
" elif any(x in line for x in [\n",
|
| 589 |
+
" \"200 OK\", \"404\", \".css\", \".js\", \"GET /\", \"vendor\", \"assets/\"\n",
|
| 590 |
+
" ]):\n",
|
| 591 |
+
" continue # Suppress noisy HTTP log entries\n",
|
| 592 |
+
" else:\n",
|
| 593 |
+
" print(\" \", line.strip())\n",
|
| 594 |
+
"except Exception as e:\n",
|
| 595 |
+
" cprint(f\"π₯ [FAIL] Tunnelmole malfunction: {e}\", \"red\", attrs=[\"bold\"])\n"
|
| 596 |
+
],
|
| 597 |
+
"metadata": {
|
| 598 |
+
"id": "6bgJVGtmV_6x"
|
| 599 |
+
},
|
| 600 |
+
"execution_count": null,
|
| 601 |
+
"outputs": []
|
| 602 |
+
},
|
| 603 |
+
{
|
| 604 |
+
"cell_type": "code",
|
| 605 |
+
"source": [
|
| 606 |
+
"#@title π¨ Start Serveo Tunnel (ComfyUI) { display-mode: \"form\" }\n",
|
| 607 |
+
"import subprocess, socket, time\n",
|
| 608 |
+
"from termcolor import cprint\n",
|
| 609 |
+
"import subprocess\n",
|
| 610 |
+
"import socket\n",
|
| 611 |
+
"import time\n",
|
| 612 |
+
"from termcolor import cprint\n",
|
| 613 |
+
"port = 8188\n",
|
| 614 |
+
"url = None\n",
|
| 615 |
+
"\n",
|
| 616 |
+
"# ========== π§ Install SSH Client ==========\n",
|
| 617 |
+
"cprint(\"π§° Installing SSH for Serveo...\", \"magenta\")\n",
|
| 618 |
+
"!apt-get install -y openssh-client > /dev/null\n",
|
| 619 |
+
"\n",
|
| 620 |
+
"# ========== π Launch ComfyUI ==========\n",
|
| 621 |
+
"%cd /content/ComfyUI\n",
|
| 622 |
+
"cprint(\"βοΈ Launching ComfyUI (CPU mode)...\", \"cyan\")\n",
|
| 623 |
+
"comfy = subprocess.Popen([\n",
|
| 624 |
+
" \"python3\", \"main.py\",\n",
|
| 625 |
+
"], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)\n",
|
| 626 |
+
"\n",
|
| 627 |
+
"# ========== π Wait for ComfyUI ==========\n",
|
| 628 |
+
"cprint(\"π» Waiting for ComfyUI on port 8188...\", \"yellow\")\n",
|
| 629 |
+
"while True:\n",
|
| 630 |
+
" try:\n",
|
| 631 |
+
" with socket.create_connection((\"127.0.0.1\", port), timeout=1):\n",
|
| 632 |
+
" break\n",
|
| 633 |
+
" except OSError:\n",
|
| 634 |
+
" time.sleep(1)\n",
|
| 635 |
+
"cprint(\"β
ComfyUI is ready to serve!\", \"green\")\n",
|
| 636 |
+
"\n",
|
| 637 |
+
"# ========== π Start Serveo Tunnel ==========\n",
|
| 638 |
+
"cprint(\"π Starting Serveo tunnel (no login)...\", \"cyan\")\n",
|
| 639 |
+
"serveo = subprocess.Popen([\n",
|
| 640 |
+
" \"ssh\", \"-o\", \"StrictHostKeyChecking=no\",\n",
|
| 641 |
+
" \"-R\", f\"80:localhost:{port}\", \"serveo.net\"\n",
|
| 642 |
+
"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
|
| 643 |
+
"\n",
|
| 644 |
+
"\n",
|
| 645 |
+
"# ========== π¨ Cyberpunk-style Output ==========\n",
|
| 646 |
+
"for line in serveo.stdout:\n",
|
| 647 |
+
" line = line.strip()\n",
|
| 648 |
+
" if \"Forwarding HTTP traffic\" in line and \"serveo.net\" in line:\n",
|
| 649 |
+
" url = line.split()[-1]\n",
|
| 650 |
+
" cprint(f\"π Your public URL: {url}\", \"blue\", attrs=[\"bold\", \"underline\"])\n",
|
| 651 |
+
" cprint(\"π¨ Keeping the tunnel and ComfyUI server running. Press Ctrl+C to stop.\", \"yellow\")\n",
|
| 652 |
+
" elif line.startswith(\"HTTP \") or line.startswith(\"POST \"):\n",
|
| 653 |
+
" # Skip printing HTTP requests\n",
|
| 654 |
+
" continue\n",
|
| 655 |
+
" elif \"Warning\" in line or \"channel\" in line:\n",
|
| 656 |
+
" continue\n",
|
| 657 |
+
" elif line != \"\":\n",
|
| 658 |
+
" cprint(line, \"magenta\")\n",
|
| 659 |
+
"\n",
|
| 660 |
+
"# ========== β³ Keep Colab Alive ==========\n",
|
| 661 |
+
"# Prevent Colab from disconnecting (infinite loop without sleep)\n",
|
| 662 |
+
"while True:\n",
|
| 663 |
+
" pass"
|
| 664 |
+
],
|
| 665 |
+
"metadata": {
|
| 666 |
+
"id": "HCwVzska4H-z"
|
| 667 |
+
},
|
| 668 |
+
"execution_count": null,
|
| 669 |
+
"outputs": []
|
| 670 |
+
},
|
| 671 |
+
{
|
| 672 |
+
"cell_type": "code",
|
| 673 |
+
"source": [
|
| 674 |
+
"#@title π¨ Start Bore Tunnel (ComfyUI) { display-mode: \"form\" }\n",
|
| 675 |
+
"import subprocess\n",
|
| 676 |
+
"import socket\n",
|
| 677 |
+
"import time\n",
|
| 678 |
+
"from termcolor import cprint\n",
|
| 679 |
+
"\n",
|
| 680 |
+
"port = 8188\n",
|
| 681 |
+
"\n",
|
| 682 |
+
"# Download & extract bore\n",
|
| 683 |
+
"cprint(\"β¬οΈ Downloading bore v0.6.0 (musl)...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 684 |
+
"subprocess.run([\n",
|
| 685 |
+
" \"wget\", \"-q\",\n",
|
| 686 |
+
" \"https://github.com/ekzhang/bore/releases/download/v0.6.0/bore-v0.6.0-x86_64-unknown-linux-musl.tar.gz\"], check=True)\n",
|
| 687 |
+
"subprocess.run([\"tar\", \"-xzf\", \"bore-v0.6.0-x86_64-unknown-linux-musl.tar.gz\"], check=True)\n",
|
| 688 |
+
"subprocess.run([\"chmod\", \"+x\", \"bore\"], check=True)\n",
|
| 689 |
+
"\n",
|
| 690 |
+
"# Change to ComfyUI dir (edit if yours differs)\n",
|
| 691 |
+
"%cd /content/ComfyUI\n",
|
| 692 |
+
"\n",
|
| 693 |
+
"# Launch ComfyUI\n",
|
| 694 |
+
"cprint(\"βοΈ Launching ComfyUI...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 695 |
+
"launch_cmd = [\n",
|
| 696 |
+
" \"python\", \"main.py\", # comment this for GPU mode\n",
|
| 697 |
+
" \"--port\", str(port), \"--listen\", \"127.0.0.1\"\n",
|
| 698 |
+
"]\n",
|
| 699 |
+
"subprocess.Popen(launch_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)\n",
|
| 700 |
+
"\n",
|
| 701 |
+
"# Wait for ComfyUI start\n",
|
| 702 |
+
"cprint(\"π Waiting for ComfyUI on port 8188...\", \"yellow\", attrs=[\"bold\"])\n",
|
| 703 |
+
"for _ in range(30):\n",
|
| 704 |
+
" try:\n",
|
| 705 |
+
" socket.create_connection((\"127.0.0.1\", port), timeout=2).close()\n",
|
| 706 |
+
" cprint(\"β
ComfyUI is live!\", \"green\", attrs=[\"bold\"])\n",
|
| 707 |
+
" break\n",
|
| 708 |
+
" except Exception:\n",
|
| 709 |
+
" time.sleep(1)\n",
|
| 710 |
+
"else:\n",
|
| 711 |
+
" cprint(\"β ComfyUI failed to start. Check logs.\", \"red\", attrs=[\"bold\"])\n",
|
| 712 |
+
" raise SystemExit\n",
|
| 713 |
+
"\n",
|
| 714 |
+
"# Run bore tunnel\n",
|
| 715 |
+
"cprint(\"π Starting bore tunnel...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 716 |
+
"bore_cmd = [\n",
|
| 717 |
+
" \"./bore\", \"local\", str(port), \"--to\", \"bore.pub\"\n",
|
| 718 |
+
"]\n",
|
| 719 |
+
"bore_proc = subprocess.Popen(bore_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
|
| 720 |
+
"\n",
|
| 721 |
+
"url = None\n",
|
| 722 |
+
"for _ in range(30):\n",
|
| 723 |
+
" line = bore_proc.stdout.readline()\n",
|
| 724 |
+
" if line:\n",
|
| 725 |
+
" print(line.strip())\n",
|
| 726 |
+
" if \"bore.pub\" in line:\n",
|
| 727 |
+
" url = line.strip().split()[-1]\n",
|
| 728 |
+
" break\n",
|
| 729 |
+
" time.sleep(1)\n",
|
| 730 |
+
"\n",
|
| 731 |
+
"if url:\n",
|
| 732 |
+
" cprint(f\"π Your public URL: {url}\", \"blue\", attrs=[\"bold\", \"underline\"])\n",
|
| 733 |
+
" cprint(\"π¨ Keeping the tunnel and ComfyUI server running. Press Ctrl+C to stop.\", \"yellow\")\n",
|
| 734 |
+
" try:\n",
|
| 735 |
+
" bore_proc.wait()\n",
|
| 736 |
+
" except KeyboardInterrupt:\n",
|
| 737 |
+
" cprint(\"π Tunnel stopped by user.\", \"red\")\n",
|
| 738 |
+
"else:\n",
|
| 739 |
+
" cprint(\"β Tunnel did not return a URL.\", \"red\")\n",
|
| 740 |
+
" bore_proc.kill()\n"
|
| 741 |
+
],
|
| 742 |
+
"metadata": {
|
| 743 |
+
"id": "OrRmn5z2mVQc"
|
| 744 |
+
},
|
| 745 |
+
"execution_count": null,
|
| 746 |
+
"outputs": []
|
| 747 |
+
},
|
| 748 |
+
{
|
| 749 |
+
"cell_type": "code",
|
| 750 |
+
"source": [
|
| 751 |
+
"#@title π¨ Start Pinggy Tunnel (60mins run only) { display-mode: \"form\" }\n",
|
| 752 |
+
"import subprocess\n",
|
| 753 |
+
"import socket\n",
|
| 754 |
+
"import time\n",
|
| 755 |
+
"from termcolor import cprint\n",
|
| 756 |
+
"\n",
|
| 757 |
+
"port = 8188\n",
|
| 758 |
+
"\n",
|
| 759 |
+
"# Change to ComfyUI directory (edit path if needed)\n",
|
| 760 |
+
"%cd /content/ComfyUI\n",
|
| 761 |
+
"\n",
|
| 762 |
+
"# Launch ComfyUI\n",
|
| 763 |
+
"cprint(\"βοΈ Launching ComfyUI...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 764 |
+
"launch_cmd = [\n",
|
| 765 |
+
" \"python\", \"main.py\",\n",
|
| 766 |
+
" \"--cpu\", # comment for GPU\n",
|
| 767 |
+
" \"--use-split-cross-attention\", \"--reserve-vram\", \"2048\",\n",
|
| 768 |
+
" \"--port\", str(port), \"--listen\", \"127.0.0.1\"\n",
|
| 769 |
+
"]\n",
|
| 770 |
+
"comfy_proc = subprocess.Popen(launch_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)\n",
|
| 771 |
+
"\n",
|
| 772 |
+
"# Wait for ComfyUI to start\n",
|
| 773 |
+
"cprint(\"π Waiting for ComfyUI on port 8188...\", \"yellow\", attrs=[\"bold\"])\n",
|
| 774 |
+
"for _ in range(30):\n",
|
| 775 |
+
" try:\n",
|
| 776 |
+
" socket.create_connection((\"127.0.0.1\", port), timeout=2).close()\n",
|
| 777 |
+
" cprint(\"β
ComfyUI is live!\", \"green\", attrs=[\"bold\"])\n",
|
| 778 |
+
" break\n",
|
| 779 |
+
" except Exception:\n",
|
| 780 |
+
" time.sleep(1)\n",
|
| 781 |
+
"else:\n",
|
| 782 |
+
" cprint(\"β ComfyUI failed to start. Check logs.\", \"red\", attrs=[\"bold\"])\n",
|
| 783 |
+
" raise SystemExit\n",
|
| 784 |
+
"\n",
|
| 785 |
+
"# Start pinggy SSH tunnel\n",
|
| 786 |
+
"cprint(\"π Starting Pinggy tunnel...\", \"cyan\", attrs=[\"bold\"])\n",
|
| 787 |
+
"# This SSH command requests a tunnel on a random subdomain, HTTPS by default.\n",
|
| 788 |
+
"pinggy_cmd = [\n",
|
| 789 |
+
" \"ssh\", \"-o\", \"StrictHostKeyChecking=no\", \"-o\", \"ServerAliveInterval=30\", \"-p\", \"443\",\n",
|
| 790 |
+
" f\"-R0:localhost:{port}\", \"p6rcyoV2Ng7@free.pinggy.io\"\n",
|
| 791 |
+
"\n",
|
| 792 |
+
"]\n",
|
| 793 |
+
"pinggy_proc = subprocess.Popen(pinggy_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
|
| 794 |
+
"\n",
|
| 795 |
+
"# Find and print the public Pinggy URL from the output\n",
|
| 796 |
+
"url = None\n",
|
| 797 |
+
"for _ in range(30):\n",
|
| 798 |
+
" line = pinggy_proc.stdout.readline()\n",
|
| 799 |
+
" if line:\n",
|
| 800 |
+
" print(line.strip())\n",
|
| 801 |
+
" # The Pinggy URL usually appears as \"Forwarding HTTPS traffic from https://....\"\n",
|
| 802 |
+
" if \"https://\" in line:\n",
|
| 803 |
+
" url_idx = line.find(\"https://\")\n",
|
| 804 |
+
" url = line[url_idx:].split()[0]\n",
|
| 805 |
+
" break\n",
|
| 806 |
+
" time.sleep(1)\n",
|
| 807 |
+
"\n",
|
| 808 |
+
"if url:\n",
|
| 809 |
+
" cprint(f\"π Your public URL: {url}\", \"blue\", attrs=[\"bold\", \"underline\"])\n",
|
| 810 |
+
" cprint(\"π¨ Tunnel and server are running. Press stop to end.\", \"yellow\")\n",
|
| 811 |
+
" try:\n",
|
| 812 |
+
" pinggy_proc.wait()\n",
|
| 813 |
+
" except KeyboardInterrupt:\n",
|
| 814 |
+
" cprint(\"π Tunnel stopped by user.\", \"red\")\n",
|
| 815 |
+
"else:\n",
|
| 816 |
+
" cprint(\"β Tunnel did not return a URL.\", \"red\")\n",
|
| 817 |
+
" cprint(\"Check pinggy status or try an alternative tunnel.\", \"yellow\")\n",
|
| 818 |
+
" pinggy_proc.kill()\n"
|
| 819 |
+
],
|
| 820 |
+
"metadata": {
|
| 821 |
+
"id": "x33rf3XWxSov"
|
| 822 |
+
},
|
| 823 |
+
"execution_count": null,
|
| 824 |
+
"outputs": []
|
| 825 |
+
}
|
| 826 |
+
]
|
| 827 |
+
}
|