comfyui_colab.ipynb 7.7 KB
Newer Older
comfyanonymous's avatar
comfyanonymous committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU",
    "gpuClass": "standard"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
22
        "Git clone the repo and install the requirements. (ignore the pip errors about protobuf)"
comfyanonymous's avatar
comfyanonymous committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      ],
      "metadata": {
        "id": "aaaaaaaaaa"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "bbbbbbbbbb"
      },
      "outputs": [],
      "source": [
        "!git clone https://github.com/comfyanonymous/ComfyUI\n",
        "%cd ComfyUI\n",
38
        "!pip install xformers -r requirements.txt\n",
comfyanonymous's avatar
comfyanonymous committed
39
        "!sed -i 's/v1-inference.yaml/v1-inference_fp16.yaml/g' webshit/index.html"
comfyanonymous's avatar
comfyanonymous committed
40
41
42
43
44
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
45
        "Download some models/checkpoints/vae or custom comfyui nodes (uncomment the commands for the ones you want)"
comfyanonymous's avatar
comfyanonymous committed
46
47
48
49
50
51
52
53
      ],
      "metadata": {
        "id": "cccccccccc"
      }
    },
    {
      "cell_type": "code",
      "source": [
54
55
56
        "# Checkpoints\n",
        "\n",
        "# SD1.5\n",
comfyanonymous's avatar
comfyanonymous committed
57
        "!wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -P ./models/checkpoints/\n",
58
59
60
61
62
        "\n",
        "# SD2\n",
        "#!wget https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.safetensors -P ./models/checkpoints/\n",
        "#!wget https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.safetensors -P ./models/checkpoints/\n",
        "\n",
63
        "# Some SD1.5 anime style\n",
comfyanonymous's avatar
comfyanonymous committed
64
65
66
        "#!wget https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_hard.safetensors -P ./models/checkpoints/\n",
        "#!wget https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1.safetensors -P ./models/checkpoints/\n",
        "#!wget https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A3.safetensors -P ./models/checkpoints/\n",
67
68
        "#!wget https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp16-pruned.safetensors -P ./models/checkpoints/\n",
        "\n",
69
70
71
        "# Waifu Diffusion 1.5 (anime style SD2.x 768-v)\n",
        "#!wget https://huggingface.co/waifu-diffusion/wd-1-5-beta2/resolve/main/checkpoints/wd-1-5-beta2-fp16.safetensors -P ./models/checkpoints/\n",
        "\n",
72
73
74
75
76
77
        "\n",
        "# VAE\n",
        "!wget https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -P ./models/vae/\n",
        "#!wget https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -P ./models/vae/\n",
        "\n",
        "\n",
78
79
80
81
82
        "# Loras\n",
        "#!wget --content-disposition https://civitai.com/api/download/models/10350 -P ./models/loras/ #theovercomer8sContrastFix SD2.x 768-v\n",
        "#!wget --content-disposition https://civitai.com/api/download/models/10638 -P ./models/loras/ #theovercomer8sContrastFix SD1.x\n",
        "\n",
        "\n",
83
84
85
86
87
88
89
90
91
92
        "# T2I-Adapter\n",
        "#!wget https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth -P ./models/t2i_adapter/\n",
        "#!wget https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_seg_sd14v1.pth -P ./models/t2i_adapter/\n",
        "#!wget https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_sketch_sd14v1.pth -P ./models/t2i_adapter/\n",
        "#!wget https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_keypose_sd14v1.pth -P ./models/t2i_adapter/\n",
        "\n",
        "\n",
        "# ControlNet\n",
        "#!wget https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors -P ./models/controlnet/\n",
        "#!wget https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors -P ./models/controlnet/\n",
93
94
95
96
97
98
        "#!wget https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors -P ./models/controlnet/\n",
        "\n",
        "\n",
        "# Controlnet Preprocessor nodes by Fannovel16\n",
        "#!cd custom_nodes && git clone https://github.com/Fannovel16/comfy_controlnet_preprocessors; cd comfy_controlnet_preprocessors && python install.py\n",
        "\n"
comfyanonymous's avatar
comfyanonymous committed
99
100
101
102
103
104
105
106
107
108
      ],
      "metadata": {
        "id": "dddddddddd"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
109
        "### Run ComfyUI with localtunnel\n",
110
        "\n",
comfyanonymous's avatar
comfyanonymous committed
111
112
        "use the **fp16** model configs for more speed\n",
        "\n"
comfyanonymous's avatar
comfyanonymous committed
113
114
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
115
        "id": "kkkkkkkkkkkkkk"
comfyanonymous's avatar
comfyanonymous committed
116
117
118
119
120
      }
    },
    {
      "cell_type": "code",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
121
122
123
        "!npm install -g localtunnel\n",
        "\n",
        "import subprocess\n",
124
125
126
127
128
129
130
131
132
133
134
        "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",
comfyanonymous's avatar
comfyanonymous committed
135
        "  print(\"\\nComfyUI finished loading, trying to launch localtunnel (if it gets stuck here localtunnel is having issues)\")\n",
comfyanonymous's avatar
comfyanonymous committed
136
137
138
139
        "  p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
        "  for line in p.stdout:\n",
        "    print(line.decode(), end='')\n",
        "\n",
comfyanonymous's avatar
comfyanonymous committed
140
        "\n",
141
142
        "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
        "\n",
143
        "!python main.py --dont-print-server"
comfyanonymous's avatar
comfyanonymous committed
144
145
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
146
        "id": "jjjjjjjjjjjjj"
comfyanonymous's avatar
comfyanonymous committed
147
148
149
      },
      "execution_count": null,
      "outputs": []
150
151
152
153
    },
    {
      "cell_type": "markdown",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
154
155
        "### Run ComfyUI with colab iframe (in case localtunnel doesn't work)\n",
        "use the **fp16** model configs for more speed\n",
156
        "\n",
comfyanonymous's avatar
comfyanonymous committed
157
        "You should see the ui appear in an iframe. If you get a 403 error, it's your firefox settings or an extension that's messing things up.\n",
158
        "\n",
comfyanonymous's avatar
comfyanonymous committed
159
160
161
        "If you want to open it in another window use the link.\n",
        "\n",
        "Note that some UI features like live image previews won't work because the colab iframe blocks websockets."
162
163
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
164
        "id": "gggggggggg"
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
      }
    },
    {
      "cell_type": "code",
      "source": [
        "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",
comfyanonymous's avatar
comfyanonymous committed
181
182
183
184
        "  from google.colab import output\n",
        "  output.serve_kernel_port_as_iframe(port, height=1024)\n",
        "  print(\"to open it in a window you can open this link here:\")\n",
        "  output.serve_kernel_port_as_window(port)\n",
185
186
187
        "\n",
        "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
        "\n",
188
        "!python main.py --dont-print-server"
189
190
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
191
        "id": "hhhhhhhhhh"
192
193
194
      },
      "execution_count": null,
      "outputs": []
comfyanonymous's avatar
comfyanonymous committed
195
196
197
    }
  ]
}