インストールコマンド

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 yacs segment_anything omegaconf
!pip install opencv-python==4.8.0.74

%cd /content
!git clone <https://github.com/comfyanonymous/ComfyUI>

%cd /content/ComfyUI/custom_nodes
!git clone <https://github.com/ltdrdata/ComfyUI-Manager.git>
!git clone <https://github.com/Fannovel16/comfyui_controlnet_aux>
!git clone <https://github.com/sipherxyz/comfyui-art-venture>

# ネガティブプロンプト
!git clone <https://huggingface.co/embed/negative> /content/ComfyUI/models/embeddings/negative
!wget -c  -P /content/ComfyUI/models/embeddings/negative/

%cd /content/ComfyUI
# 依存関係のインストール
!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://huggingface.co/RazzzHF/realismEngineSDXL/resolve/main/RealismEngineSDXL_V2.0_FP16_VAE.safetensors> -d /content/ComfyUI/models/checkpoints -o RealismEngineSDXL_V2.0_FP16_VAE.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/201346> -d /content/ComfyUI/models/checkpoints -o epicphotogasm_z.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/178711> -d /content/ComfyUI/models/checkpoints -o yayoimix.safetensors

#ControlNetのダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/hr16/ControlNet-HandRefiner-pruned/resolve/main/control_sd15_inpaint_depth_hand_fp16.safetensors> -d /content/ComfyUI/models/controlnet -o control_sd15_inpaint_depth_hand_fp16.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth.pth> -d /content/ComfyUI/models/controlnet -o control_v11f1p_sd15_depth.pth
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_canny_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_lineart_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_openpose_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_scribble_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_seg_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15_softedge_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors> -P /content/ComfyUI/models/controlnet/
!wget -c <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11u_sd15_tile_fp16.safetensors> -P /content/ComfyUI/models/controlnet/

# LoRAのダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_offset_example-lora_1.0.safetensors> -d /content/ComfyUI/models/loras -o sd_xl_offset_example-lora_1.0.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://sliders.baulab.info/weights/xl_sliders/fix_hands.pt> -d /content/ComfyUI/models/loras -o fix_hands.pt

# 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

利用ファイル

workflow.zip