インストールコマンド

from pathlib import Path
import subprocess
import threading
import time
import socket

!pip install -q torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2+cu118 torchtext==0.15.2 torchdata==0.6.1 --extra-index-url <https://download.pytorch.org/whl/cu118> -U
!pip install -q xformers==0.0.20 triton==2.0.0 gradio_client==0.2.7 -U
!apt -y install -qq aria2
!pip install controlnet-aux==0.0.7 onnxruntime-gpu insightface segment_anything watchdog omegaconf piexif

# 定数と設定
WORKSPACE = '/content/ComfyUI'
UPDATE_COMFY_UI = True

# ComfyUIのセットアップと更新
if not Path(WORKSPACE).exists():
  %cd /content
  print("-= Initial setup ComfyUI =-")
  !git clone <https://github.com/comfyanonymous/ComfyUI>
else:
  %cd $WORKSPACE
  print("-= Updating ComfyUI =-")
  !git pull

%cd $WORKSPACE/custom_nodes
!git clone <https://github.com/ltdrdata/ComfyUI-Manager.git>
!git clone <https://github.com/rgthree/rgthree-comfy>
!git clone <https://github.com/sipherxyz/comfyui-art-venture>
!git clone <https://github.com/pythongosssss/ComfyUI-Custom-Scripts>
!git clone <https://github.com/shadowcz007/comfyui-mixlab-nodes>
!git clone <https://github.com/wallish77/wlsh_nodes>
!git clone <https://github.com/ltdrdata/ComfyUI-Impact-Pack>
!git clone <https://github.com/WASasquatch/was-node-suite-comfyui>
!git clone <https://github.com/Fannovel16/comfyui_controlnet_aux.git>
!git clone <https://github.com/ssitu/ComfyUI_UltimateSDUpscale> --recursive
!git clone <https://github.com/cubiq/ComfyUI_IPAdapter_plus.git>

# For comfyui-mixlab-nodes (need clipseq.py in custome_nodes)
!wget <https://raw.githubusercontent.com/biegert/ComfyUI-CLIPSeg/main/custom_nodes/clipseg.py>

# For Upscaling Model
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth> -d /content/ComfyUI/models/upscale_models -o 4x-UltraSharp.pth

# ネガティブプロンプト
!git clone <https://huggingface.co/embed/negative> $WORKSPACE/models/embeddings/negative
!wget -c  -P $WORKSPACE/models/embeddings/negative/
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/77169> -d /content/ComfyUI/models/embeddings/negative -o BadDream.pt
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/77173> -d /content/ComfyUI/models/embeddings/negative -o UnrealisticDream.pt
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/25820> -d /content/ComfyUI/models/embeddings/negative -o verybadimagenegative_v1.3.pt

# For ComfyUI_IPAdapter_plus
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-full-face_sd15.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter-full-face_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-plus-face_sd15.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter-plus-face_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter-plus_sd15.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter-plus_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15_light.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter_sd15_light.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15_vit-G.bin> -d /content/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus/models -o ip-adapter_sd15_vit-G.bin

# For comfyui-mixlab-nodes
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/CIDAS/clipseg-rd64-refined/resolve/main/pytorch_model.bin> -d /content/ComfyUI/models/clipseg -o clipseg-rd64-refined.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://openaipublic.azureedge.net/diff-vae/c9cebd3132dd9c42936d803e33424145a748843c8f716c0814838bdc8a2fe7cb/decoder.pt> -o -d /content/ComfyUI/models/vae decoder.pt

%cd $WORKSPACE
# 依存関係のインストール
print("-= Install dependencies =-")
!pip install xformers!=0.0.18 -r requirements.txt --extra-index-url <https://download.pytorch.org/whl/cu118> --extra-index-url <https://download.pytorch.org/whl/cu118>

# VAEのダウンロード
!wget -c <https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors> -P ./models/vae/

#checkpointをダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/142334> -d $WORKSPACE/models/checkpoints -o Dolphinmix_v10.safetensors

#ControlNetのダウンロード
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_scribble_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_seg_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_softedge_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors> -P ./models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11u_sd15_tile_fp16.safetensors> -P ./models/controlnet/

!wget -c <https://huggingface.co/ioclab/control_v1u_sd15_illumination_webui/resolve/main/illumination20000.safetensors> -P ./models/controlnet/

# LoRAのダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/latent-consistency/lcm-lora-sdv1-5/resolve/main/pytorch_lora_weights.safetensors> -d /content/ComfyUI/models/loras -o lcm-lora-sdv1-5_lora_weights.safetensors

# cloudflaredのダウンロードとインストール
!wget <https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb>
!dpkg -i cloudflared-linux-amd64.deb

def iframe_thread(port):
    while True:
        time.sleep(0.5)
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = sock.connect_ex(('127.0.0.1', port))
        if result == 0:
            break
        sock.close()

    print("\\nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\\n")
    p = subprocess.Popen(["cloudflared", "tunnel", "--url", f"<http://127.0.0.1>:{port}"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    for line in p.stderr:
        l = line.decode()
        if "trycloudflare.com " in l:
            print("This is the URL to access ComfyUI:", l[l.find("http"):], end='')

# スレッドの開始
threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()

# ComfyUIの実行
!python main.py --dont-print-server

利用ファイル

materials.zip