comfyui_colab.ipynb 5.05 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 -r requirements.txt\n",
comfyanonymous's avatar
comfyanonymous committed
39
40
        "!pip install xformers\n",
        "!sed -i 's/v1-inference.yaml/v1-inference_fp16.yaml/g' webshit/index.html"
comfyanonymous's avatar
comfyanonymous committed
41
42
43
44
45
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
46
        "Download some models/checkpoints/vae (uncomment the ones you want)"
comfyanonymous's avatar
comfyanonymous committed
47
48
49
50
51
52
53
54
55
      ],
      "metadata": {
        "id": "cccccccccc"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -P ./models/checkpoints/\n",
56
        "!wget https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -P ./models/vae/\n",
comfyanonymous's avatar
comfyanonymous committed
57
58
59
        "#!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",
comfyanonymous's avatar
Fix.  
comfyanonymous committed
60
        "#!wget https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -P ./models/vae/"
comfyanonymous's avatar
comfyanonymous committed
61
62
63
64
65
66
67
68
69
70
      ],
      "metadata": {
        "id": "dddddddddd"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
71
        "### Run ComfyUI with localtunnel\n",
72
        "\n",
comfyanonymous's avatar
comfyanonymous committed
73
        "If you have issues with the previous way, you can try this way. It will also work on non colab.\n",
74
        "\n",
comfyanonymous's avatar
comfyanonymous committed
75
76
        "use the **fp16** model configs for more speed\n",
        "\n"
comfyanonymous's avatar
comfyanonymous committed
77
78
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
79
        "id": "kkkkkkkkkkkkkk"
comfyanonymous's avatar
comfyanonymous committed
80
81
82
83
84
      }
    },
    {
      "cell_type": "code",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
85
86
87
        "!npm install -g localtunnel\n",
        "\n",
        "import subprocess\n",
88
89
90
91
92
93
94
95
96
97
98
        "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
99
100
101
102
        "  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
103
        "\n",
104
105
        "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
        "\n",
comfyanonymous's avatar
comfyanonymous committed
106
        "!python main.py --highvram --dont-print-server"
comfyanonymous's avatar
comfyanonymous committed
107
108
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
109
        "id": "jjjjjjjjjjjjj"
comfyanonymous's avatar
comfyanonymous committed
110
111
112
      },
      "execution_count": null,
      "outputs": []
113
114
115
116
    },
    {
      "cell_type": "markdown",
      "source": [
comfyanonymous's avatar
comfyanonymous committed
117
118
        "### Run ComfyUI with colab iframe (in case localtunnel doesn't work)\n",
        "use the **fp16** model configs for more speed\n",
119
        "\n",
comfyanonymous's avatar
comfyanonymous committed
120
        "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",
121
        "\n",
comfyanonymous's avatar
comfyanonymous committed
122
        "If you want to open it in another window use the link.\n"
123
124
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
125
        "id": "gggggggggg"
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
      }
    },
    {
      "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
142
143
144
145
        "  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",
146
147
148
        "\n",
        "threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
        "\n",
comfyanonymous's avatar
comfyanonymous committed
149
        "!python main.py --highvram --dont-print-server"
150
151
      ],
      "metadata": {
comfyanonymous's avatar
comfyanonymous committed
152
        "id": "hhhhhhhhhh"
153
154
155
      },
      "execution_count": null,
      "outputs": []
comfyanonymous's avatar
comfyanonymous committed
156
157
158
    }
  ]
}