diff --git a/notebooks/comfyui_colab.ipynb b/notebooks/comfyui_colab.ipynb index 85624180..4762c03c 100644 --- a/notebooks/comfyui_colab.ipynb +++ b/notebooks/comfyui_colab.ipynb @@ -63,7 +63,7 @@ { "cell_type": "markdown", "source": [ - "Launch a http server to see the output pics:" + "Optional: Launch a http server to see the output pics (you can also download them by browsing to the output directory with colab):" ], "metadata": { "id": "eeeeeeeeee" @@ -94,10 +94,22 @@ { "cell_type": "code", "source": [ - "from google.colab import output\n", - "print(\"open this next link instead once the software prints: To see the GUI go to\")\n", - "output.serve_kernel_port_as_window(8188)\n", - "!sed -i 's/127.0.0.1/0.0.0.0/g' main.py\n", + "import threading\n", + "import time\n", + "import socket\n", + "def iframe_thread(port):\n", + " while True:\n", + " time.sleep(0.5)\n", + " sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n", + " result = sock.connect_ex(('127.0.0.1', port))\n", + " if result == 0:\n", + " break\n", + " sock.close()\n", + " from google.colab import output\n", + " x = output.serve_kernel_port_as_window(port)\n", + " x = output.serve_kernel_port_as_iframe(port, height=1024)\n", + "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n", + "\n", "!python main.py" ], "metadata": {