Spaces:
Running
Running
Upload comfyui_colab.ipynb
Browse files- comfyui_colab.ipynb +433 -0
comfyui_colab.ipynb
ADDED
@@ -0,0 +1,433 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {
|
6 |
+
"id": "aaaaaaaaaa"
|
7 |
+
},
|
8 |
+
"source": [
|
9 |
+
"Git clone the repo and install the requirements. (ignore the pip errors about protobuf)"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": 1,
|
15 |
+
"metadata": {
|
16 |
+
"id": "bbbbbbbbbb"
|
17 |
+
},
|
18 |
+
"outputs": [
|
19 |
+
{
|
20 |
+
"name": "stdout",
|
21 |
+
"output_type": "stream",
|
22 |
+
"text": [
|
23 |
+
"[WinError 2] The system cannot find the file specified: 'ComfyUI'\n",
|
24 |
+
"e:\\ComfyUI_windows_portable\\ComfyUI\\notebooks\n"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"name": "stderr",
|
29 |
+
"output_type": "stream",
|
30 |
+
"text": [
|
31 |
+
"'[' is not recognized as an internal or external command,\n",
|
32 |
+
"operable program or batch file.\n"
|
33 |
+
]
|
34 |
+
},
|
35 |
+
{
|
36 |
+
"name": "stdout",
|
37 |
+
"output_type": "stream",
|
38 |
+
"text": [
|
39 |
+
"-= Updating ComfyUI =-\n"
|
40 |
+
]
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"name": "stderr",
|
44 |
+
"output_type": "stream",
|
45 |
+
"text": [
|
46 |
+
"From https://github.com/comfyanonymous/ComfyUI\n",
|
47 |
+
" * [new branch] annoate_get_input_info -> origin/annoate_get_input_info\n",
|
48 |
+
" * [new branch] huchenlei-patch-1 -> origin/huchenlei-patch-1\n",
|
49 |
+
" 75c1c757..2f7d8159 master -> origin/master\n",
|
50 |
+
" * [new branch] prepare-sampling-wrapper -> origin/prepare-sampling-wrapper\n",
|
51 |
+
" * [new branch] weight-zipper -> origin/weight-zipper\n",
|
52 |
+
" 4879b476..407a5a65 worksplit-multigpu -> origin/worksplit-multigpu\n",
|
53 |
+
" + bef5a067...d58ad2dd yo-lora-trainer -> origin/yo-lora-trainer (forced update)\n",
|
54 |
+
"You are not currently on a branch.\n",
|
55 |
+
"Please specify which branch you want to merge with.\n",
|
56 |
+
"See git-pull(1) for details.\n",
|
57 |
+
"\n",
|
58 |
+
" git pull <remote> <branch>\n",
|
59 |
+
"\n"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"name": "stdout",
|
64 |
+
"output_type": "stream",
|
65 |
+
"text": [
|
66 |
+
"-= Install dependencies =-\n"
|
67 |
+
]
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"name": "stderr",
|
71 |
+
"output_type": "stream",
|
72 |
+
"text": [
|
73 |
+
"\n",
|
74 |
+
"[notice] A new release of pip is available: 24.3.1 -> 25.0.1\n",
|
75 |
+
"[notice] To update, run: C:\\Users\\ADMIN\\AppData\\Local\\Programs\\Python\\Python312\\python.exe -m pip install --upgrade pip\n",
|
76 |
+
"ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'\n"
|
77 |
+
]
|
78 |
+
}
|
79 |
+
],
|
80 |
+
"source": [
|
81 |
+
"#@title Environment Setup\n",
|
82 |
+
"\n",
|
83 |
+
"\n",
|
84 |
+
"OPTIONS = {}\n",
|
85 |
+
"\n",
|
86 |
+
"USE_GOOGLE_DRIVE = False #@param {type:\"boolean\"}\n",
|
87 |
+
"UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n",
|
88 |
+
"WORKSPACE = 'ComfyUI'\n",
|
89 |
+
"OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n",
|
90 |
+
"OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n",
|
91 |
+
"\n",
|
92 |
+
"if OPTIONS['USE_GOOGLE_DRIVE']:\n",
|
93 |
+
" !echo \"Mounting Google Drive...\"\n",
|
94 |
+
" %cd /\n",
|
95 |
+
" \n",
|
96 |
+
" from google.colab import drive\n",
|
97 |
+
" drive.mount('/content/drive')\n",
|
98 |
+
"\n",
|
99 |
+
" WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n",
|
100 |
+
" %cd /content/drive/MyDrive\n",
|
101 |
+
"\n",
|
102 |
+
"![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI\n",
|
103 |
+
"%cd $WORKSPACE\n",
|
104 |
+
"\n",
|
105 |
+
"if OPTIONS['UPDATE_COMFY_UI']:\n",
|
106 |
+
" !echo -= Updating ComfyUI =-\n",
|
107 |
+
" !git pull\n",
|
108 |
+
"\n",
|
109 |
+
"!echo -= Install dependencies =-\n",
|
110 |
+
"!pip install xformers!=0.0.18 -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121 --extra-index-url https://download.pytorch.org/whl/cu118 --extra-index-url https://download.pytorch.org/whl/cu117"
|
111 |
+
]
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"cell_type": "markdown",
|
115 |
+
"metadata": {
|
116 |
+
"id": "cccccccccc"
|
117 |
+
},
|
118 |
+
"source": [
|
119 |
+
"Download some models/checkpoints/vae or custom comfyui nodes (uncomment the commands for the ones you want)"
|
120 |
+
]
|
121 |
+
},
|
122 |
+
{
|
123 |
+
"cell_type": "code",
|
124 |
+
"execution_count": 2,
|
125 |
+
"metadata": {
|
126 |
+
"id": "dddddddddd"
|
127 |
+
},
|
128 |
+
"outputs": [
|
129 |
+
{
|
130 |
+
"name": "stderr",
|
131 |
+
"output_type": "stream",
|
132 |
+
"text": [
|
133 |
+
"'wget' is not recognized as an internal or external command,\n",
|
134 |
+
"operable program or batch file.\n",
|
135 |
+
"'wget' is not recognized as an internal or external command,\n",
|
136 |
+
"operable program or batch file.\n"
|
137 |
+
]
|
138 |
+
}
|
139 |
+
],
|
140 |
+
"source": [
|
141 |
+
"# Checkpoints\n",
|
142 |
+
"\n",
|
143 |
+
"### SDXL\n",
|
144 |
+
"### I recommend these workflow examples: https://comfyanonymous.github.io/ComfyUI_examples/sdxl/\n",
|
145 |
+
"\n",
|
146 |
+
"#!wget -c https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors -P ./models/checkpoints/\n",
|
147 |
+
"#!wget -c https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors -P ./models/checkpoints/\n",
|
148 |
+
"\n",
|
149 |
+
"# SDXL ReVision\n",
|
150 |
+
"#!wget -c https://huggingface.co/comfyanonymous/clip_vision_g/resolve/main/clip_vision_g.safetensors -P ./models/clip_vision/\n",
|
151 |
+
"\n",
|
152 |
+
"# SD1.5\n",
|
153 |
+
"!wget -c https://huggingface.co/Comfy-Org/stable-diffusion-v1-5-archive/resolve/main/v1-5-pruned-emaonly-fp16.safetensors -P ./models/checkpoints/\n",
|
154 |
+
"\n",
|
155 |
+
"# SD2\n",
|
156 |
+
"#!wget -c https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.safetensors -P ./models/checkpoints/\n",
|
157 |
+
"#!wget -c https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.safetensors -P ./models/checkpoints/\n",
|
158 |
+
"\n",
|
159 |
+
"# Some SD1.5 anime style\n",
|
160 |
+
"#!wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_hard.safetensors -P ./models/checkpoints/\n",
|
161 |
+
"#!wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1_orangemixs.safetensors -P ./models/checkpoints/\n",
|
162 |
+
"#!wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A3_orangemixs.safetensors -P ./models/checkpoints/\n",
|
163 |
+
"#!wget -c https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp16-pruned.safetensors -P ./models/checkpoints/\n",
|
164 |
+
"\n",
|
165 |
+
"# Waifu Diffusion 1.5 (anime style SD2.x 768-v)\n",
|
166 |
+
"#!wget -c https://huggingface.co/waifu-diffusion/wd-1-5-beta3/resolve/main/wd-illusion-fp16.safetensors -P ./models/checkpoints/\n",
|
167 |
+
"\n",
|
168 |
+
"\n",
|
169 |
+
"# unCLIP models\n",
|
170 |
+
"#!wget -c https://huggingface.co/comfyanonymous/illuminatiDiffusionV1_v11_unCLIP/resolve/main/illuminatiDiffusionV1_v11-unclip-h-fp16.safetensors -P ./models/checkpoints/\n",
|
171 |
+
"#!wget -c https://huggingface.co/comfyanonymous/wd-1.5-beta2_unCLIP/resolve/main/wd-1-5-beta2-aesthetic-unclip-h-fp16.safetensors -P ./models/checkpoints/\n",
|
172 |
+
"\n",
|
173 |
+
"\n",
|
174 |
+
"# VAE\n",
|
175 |
+
"!wget -c https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -P ./models/vae/\n",
|
176 |
+
"#!wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -P ./models/vae/\n",
|
177 |
+
"#!wget -c https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt -P ./models/vae/\n",
|
178 |
+
"\n",
|
179 |
+
"\n",
|
180 |
+
"# Loras\n",
|
181 |
+
"#!wget -c https://civitai.com/api/download/models/10350 -O ./models/loras/theovercomer8sContrastFix_sd21768.safetensors #theovercomer8sContrastFix SD2.x 768-v\n",
|
182 |
+
"#!wget -c https://civitai.com/api/download/models/10638 -O ./models/loras/theovercomer8sContrastFix_sd15.safetensors #theovercomer8sContrastFix SD1.x\n",
|
183 |
+
"#!wget -c https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_offset_example-lora_1.0.safetensors -P ./models/loras/ #SDXL offset noise lora\n",
|
184 |
+
"\n",
|
185 |
+
"\n",
|
186 |
+
"# T2I-Adapter\n",
|
187 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth -P ./models/controlnet/\n",
|
188 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_seg_sd14v1.pth -P ./models/controlnet/\n",
|
189 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_sketch_sd14v1.pth -P ./models/controlnet/\n",
|
190 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_keypose_sd14v1.pth -P ./models/controlnet/\n",
|
191 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_openpose_sd14v1.pth -P ./models/controlnet/\n",
|
192 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_color_sd14v1.pth -P ./models/controlnet/\n",
|
193 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_canny_sd14v1.pth -P ./models/controlnet/\n",
|
194 |
+
"\n",
|
195 |
+
"# T2I Styles Model\n",
|
196 |
+
"#!wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_style_sd14v1.pth -P ./models/style_models/\n",
|
197 |
+
"\n",
|
198 |
+
"# CLIPVision model (needed for styles model)\n",
|
199 |
+
"#!wget -c https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin -O ./models/clip_vision/clip_vit14.bin\n",
|
200 |
+
"\n",
|
201 |
+
"\n",
|
202 |
+
"# ControlNet\n",
|
203 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors -P ./models/controlnet/\n",
|
204 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors -P ./models/controlnet/\n",
|
205 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors -P ./models/controlnet/\n",
|
206 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors -P ./models/controlnet/\n",
|
207 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors -P ./models/controlnet/\n",
|
208 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors -P ./models/controlnet/\n",
|
209 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors -P ./models/controlnet/\n",
|
210 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors -P ./models/controlnet/\n",
|
211 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors -P ./models/controlnet/\n",
|
212 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_scribble_fp16.safetensors -P ./models/controlnet/\n",
|
213 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_seg_fp16.safetensors -P ./models/controlnet/\n",
|
214 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_softedge_fp16.safetensors -P ./models/controlnet/\n",
|
215 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors -P ./models/controlnet/\n",
|
216 |
+
"#!wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11u_sd15_tile_fp16.safetensors -P ./models/controlnet/\n",
|
217 |
+
"\n",
|
218 |
+
"# ControlNet SDXL\n",
|
219 |
+
"#!wget -c https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank256/control-lora-canny-rank256.safetensors -P ./models/controlnet/\n",
|
220 |
+
"#!wget -c https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank256/control-lora-depth-rank256.safetensors -P ./models/controlnet/\n",
|
221 |
+
"#!wget -c https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank256/control-lora-recolor-rank256.safetensors -P ./models/controlnet/\n",
|
222 |
+
"#!wget -c https://huggingface.co/stabilityai/control-lora/resolve/main/control-LoRAs-rank256/control-lora-sketch-rank256.safetensors -P ./models/controlnet/\n",
|
223 |
+
"\n",
|
224 |
+
"# Controlnet Preprocessor nodes by Fannovel16\n",
|
225 |
+
"#!cd custom_nodes && git clone https://github.com/Fannovel16/comfy_controlnet_preprocessors; cd comfy_controlnet_preprocessors && python install.py\n",
|
226 |
+
"\n",
|
227 |
+
"\n",
|
228 |
+
"# GLIGEN\n",
|
229 |
+
"#!wget -c https://huggingface.co/comfyanonymous/GLIGEN_pruned_safetensors/resolve/main/gligen_sd14_textbox_pruned_fp16.safetensors -P ./models/gligen/\n",
|
230 |
+
"\n",
|
231 |
+
"\n",
|
232 |
+
"# ESRGAN upscale model\n",
|
233 |
+
"#!wget -c https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P ./models/upscale_models/\n",
|
234 |
+
"#!wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth -P ./models/upscale_models/\n",
|
235 |
+
"#!wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth -P ./models/upscale_models/\n",
|
236 |
+
"\n",
|
237 |
+
"\n"
|
238 |
+
]
|
239 |
+
},
|
240 |
+
{
|
241 |
+
"cell_type": "markdown",
|
242 |
+
"metadata": {
|
243 |
+
"id": "kkkkkkkkkkkkkkk"
|
244 |
+
},
|
245 |
+
"source": [
|
246 |
+
"### Run ComfyUI with cloudflared (Recommended Way)\n",
|
247 |
+
"\n",
|
248 |
+
"\n"
|
249 |
+
]
|
250 |
+
},
|
251 |
+
{
|
252 |
+
"cell_type": "code",
|
253 |
+
"execution_count": 3,
|
254 |
+
"metadata": {
|
255 |
+
"id": "jjjjjjjjjjjjjj"
|
256 |
+
},
|
257 |
+
"outputs": [
|
258 |
+
{
|
259 |
+
"name": "stderr",
|
260 |
+
"output_type": "stream",
|
261 |
+
"text": [
|
262 |
+
"'wget' is not recognized as an internal or external command,\n",
|
263 |
+
"operable program or batch file.\n",
|
264 |
+
"'dpkg' is not recognized as an internal or external command,\n",
|
265 |
+
"operable program or batch file.\n",
|
266 |
+
"python: can't open file 'e:\\\\ComfyUI_windows_portable\\\\ComfyUI\\\\notebooks\\\\main.py': [Errno 2] No such file or directory\n"
|
267 |
+
]
|
268 |
+
}
|
269 |
+
],
|
270 |
+
"source": [
|
271 |
+
"!wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb\n",
|
272 |
+
"!dpkg -i cloudflared-linux-amd64.deb\n",
|
273 |
+
"\n",
|
274 |
+
"import subprocess\n",
|
275 |
+
"import threading\n",
|
276 |
+
"import time\n",
|
277 |
+
"import socket\n",
|
278 |
+
"import urllib.request\n",
|
279 |
+
"\n",
|
280 |
+
"def iframe_thread(port):\n",
|
281 |
+
" while True:\n",
|
282 |
+
" time.sleep(0.5)\n",
|
283 |
+
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
284 |
+
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
285 |
+
" if result == 0:\n",
|
286 |
+
" break\n",
|
287 |
+
" sock.close()\n",
|
288 |
+
" print(\"\\nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\\n\")\n",
|
289 |
+
"\n",
|
290 |
+
" p = subprocess.Popen([\"cloudflared\", \"tunnel\", \"--url\", \"http://127.0.0.1:{}\".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
|
291 |
+
" for line in p.stderr:\n",
|
292 |
+
" l = line.decode()\n",
|
293 |
+
" if \"trycloudflare.com \" in l:\n",
|
294 |
+
" print(\"This is the URL to access ComfyUI:\", l[l.find(\"http\"):], end='')\n",
|
295 |
+
" #print(l, end='')\n",
|
296 |
+
"\n",
|
297 |
+
"\n",
|
298 |
+
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
|
299 |
+
"\n",
|
300 |
+
"!python main.py --dont-print-server"
|
301 |
+
]
|
302 |
+
},
|
303 |
+
{
|
304 |
+
"cell_type": "markdown",
|
305 |
+
"metadata": {
|
306 |
+
"id": "kkkkkkkkkkkkkk"
|
307 |
+
},
|
308 |
+
"source": [
|
309 |
+
"### Run ComfyUI with localtunnel\n",
|
310 |
+
"\n",
|
311 |
+
"\n"
|
312 |
+
]
|
313 |
+
},
|
314 |
+
{
|
315 |
+
"cell_type": "code",
|
316 |
+
"execution_count": 4,
|
317 |
+
"metadata": {
|
318 |
+
"id": "jjjjjjjjjjjjj"
|
319 |
+
},
|
320 |
+
"outputs": [
|
321 |
+
{
|
322 |
+
"name": "stderr",
|
323 |
+
"output_type": "stream",
|
324 |
+
"text": [
|
325 |
+
"'npm' is not recognized as an internal or external command,\n",
|
326 |
+
"operable program or batch file.\n",
|
327 |
+
"python: can't open file 'e:\\\\ComfyUI_windows_portable\\\\ComfyUI\\\\notebooks\\\\main.py': [Errno 2] No such file or directory\n"
|
328 |
+
]
|
329 |
+
}
|
330 |
+
],
|
331 |
+
"source": [
|
332 |
+
"!npm install -g localtunnel\n",
|
333 |
+
"\n",
|
334 |
+
"import threading\n",
|
335 |
+
"\n",
|
336 |
+
"def iframe_thread(port):\n",
|
337 |
+
" while True:\n",
|
338 |
+
" time.sleep(0.5)\n",
|
339 |
+
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
340 |
+
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
341 |
+
" if result == 0:\n",
|
342 |
+
" break\n",
|
343 |
+
" sock.close()\n",
|
344 |
+
" print(\"\\nComfyUI finished loading, trying to launch localtunnel (if it gets stuck here localtunnel is having issues)\\n\")\n",
|
345 |
+
"\n",
|
346 |
+
" print(\"The password/enpoint ip for localtunnel is:\", urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n",
|
347 |
+
" p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
|
348 |
+
" for line in p.stdout:\n",
|
349 |
+
" print(line.decode(), end='')\n",
|
350 |
+
"\n",
|
351 |
+
"\n",
|
352 |
+
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
|
353 |
+
"\n",
|
354 |
+
"!python main.py --dont-print-server"
|
355 |
+
]
|
356 |
+
},
|
357 |
+
{
|
358 |
+
"cell_type": "markdown",
|
359 |
+
"metadata": {
|
360 |
+
"id": "gggggggggg"
|
361 |
+
},
|
362 |
+
"source": [
|
363 |
+
"### Run ComfyUI with colab iframe (use only in case the previous way with localtunnel doesn't work)\n",
|
364 |
+
"\n",
|
365 |
+
"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",
|
366 |
+
"\n",
|
367 |
+
"If you want to open it in another window use the link.\n",
|
368 |
+
"\n",
|
369 |
+
"Note that some UI features like live image previews won't work because the colab iframe blocks websockets."
|
370 |
+
]
|
371 |
+
},
|
372 |
+
{
|
373 |
+
"cell_type": "code",
|
374 |
+
"execution_count": 5,
|
375 |
+
"metadata": {
|
376 |
+
"id": "hhhhhhhhhh"
|
377 |
+
},
|
378 |
+
"outputs": [
|
379 |
+
{
|
380 |
+
"name": "stderr",
|
381 |
+
"output_type": "stream",
|
382 |
+
"text": [
|
383 |
+
"python: can't open file 'e:\\\\ComfyUI_windows_portable\\\\ComfyUI\\\\notebooks\\\\main.py': [Errno 2] No such file or directory\n"
|
384 |
+
]
|
385 |
+
}
|
386 |
+
],
|
387 |
+
"source": [
|
388 |
+
"import threading\n",
|
389 |
+
"def iframe_thread(port):\n",
|
390 |
+
" while True:\n",
|
391 |
+
" time.sleep(0.5)\n",
|
392 |
+
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
393 |
+
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
394 |
+
" if result == 0:\n",
|
395 |
+
" break\n",
|
396 |
+
" sock.close()\n",
|
397 |
+
" from google.colab import output\n",
|
398 |
+
" output.serve_kernel_port_as_iframe(port, height=1024)\n",
|
399 |
+
" print(\"to open it in a window you can open this link here:\")\n",
|
400 |
+
" output.serve_kernel_port_as_window(port)\n",
|
401 |
+
"\n",
|
402 |
+
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
|
403 |
+
"\n",
|
404 |
+
"!python main.py --dont-print-server"
|
405 |
+
]
|
406 |
+
}
|
407 |
+
],
|
408 |
+
"metadata": {
|
409 |
+
"accelerator": "GPU",
|
410 |
+
"colab": {
|
411 |
+
"provenance": []
|
412 |
+
},
|
413 |
+
"gpuClass": "standard",
|
414 |
+
"kernelspec": {
|
415 |
+
"display_name": "Python 3",
|
416 |
+
"name": "python3"
|
417 |
+
},
|
418 |
+
"language_info": {
|
419 |
+
"codemirror_mode": {
|
420 |
+
"name": "ipython",
|
421 |
+
"version": 3
|
422 |
+
},
|
423 |
+
"file_extension": ".py",
|
424 |
+
"mimetype": "text/x-python",
|
425 |
+
"name": "python",
|
426 |
+
"nbconvert_exporter": "python",
|
427 |
+
"pygments_lexer": "ipython3",
|
428 |
+
"version": "3.12.9"
|
429 |
+
}
|
430 |
+
},
|
431 |
+
"nbformat": 4,
|
432 |
+
"nbformat_minor": 0
|
433 |
+
}
|