インストールコマンド

!apt -y install -qq aria2
!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
!pip install torchsde controlnet-aux==0.0.7 onnxruntime-gpu insightface segment_anything watchdog omegaconf piexif

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

%cd /content/ComfyUI
!pip install -r requirements.txt

# ComfyUI Managerのインストール
%cd /content/ComfyUI/custom_nodes
!git clone <https://github.com/ltdrdata/ComfyUI-Manager.git>
!git clone <https://github.com/melMass/comfy_mtb>

# ---------------- ComfyUI_IPAdapter_plusの設定開始 ---------------------
%cd /content/ComfyUI/custom_nodes
!git clone <https://github.com/cubiq/ComfyUI_IPAdapter_plus.git>

# ip-adapter(clip_vision) : $WORKSPACE/models/clip_vision 
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/image_encoder/model.safetensors> -d /content/ComfyUI/models/clip_vision -o ipadapter_model_sd15.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/sdxl_models/image_encoder/model.safetensors> -d /content/ComfyUI/models/clip_vision -o ipadapter_model_sdxl.safetensors

# ip-adapter(main) : $WORKSPACE/models/ipadapter
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/models/ip-adapter_sd15.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter_sd15.safetensors
!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.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter_sd15_light.safetensors
!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.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter-plus_sd15.safetensors
!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.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter-plus-face_sd15.safetensors
!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.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter-full-face_sd15.safetensors
!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.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter_sd15_vit-G.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/sdxl_models/ip-adapter_sdxl.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter_sdxl.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/sdxl_models/ip-adapter_sdxl_vit-h.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter_sdxl_vit-h.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/sdxl_models/ip-adapter-plus_sdxl_vit-h.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter-plus_sdxl_vit-h.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter/resolve/main/sdxl_models/ip-adapter-plus-face_sdxl_vit-h.safetensors> -d /content/ComfyUI/models/ipadapter -o ip-adapter-plus-face_sdxl_vit-h.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid_sd15.bin> -d /content/ComfyUI/models/ipadapter -o ip-adapter-faceid_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid-plus_sd15.bin> -d /content/ComfyUI/models/ipadapter -o ip-adapter-faceid-plus_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid-plusv2_sd15.bin> -d /content/ComfyUI/models/ipadapter -o ip-adapter-faceid-plusv2_sd15.bin
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid_sdxl.bin> -d /content/ComfyUI/models/ipadapter -o ip-adapter-faceid_sdxl.bin

# ip-adapter(loras) : $WORKSPACE/models/loras
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid_sd15_lora.safetensors> -d /content/ComfyUI/models/loras -o ip-adapter-faceid_sd15_lora.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid-plus_sd15_lora.safetensors> -d /content/ComfyUI/models/loras -o ip-adapter-faceid-plus_sd15_lora.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid-plusv2_sd15_lora.safetensors> -d /content/ComfyUI/models/loras -o ip-adapter-faceid-plusv2_sd15_lora.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/h94/IP-Adapter-FaceID/resolve/main/ip-adapter-faceid_sdxl_lora.safetensors> -d /content/ComfyUI/models/loras -o ip-adapter-faceid_sdxl_lora.safetensors
# ---------------- ComfyUI_IPAdapter_plusの設定終了 ---------------------

# ---------------- facerestore_cfの設定開始 ---------------------
%cd /content/ComfyUI/custom_nodes
!git clone <https://github.com/mav-rik/facerestore_cf>
!pip install -r /content/ComfyUI/custom_nodes/facerestore_cf/requirements.txt

# onxxファイル : $WORKSPACE/models/insightface 
!wget <https://archive.creativaier.com/comfyui/scripts/setup_script>
!mv setup_script setup_script.py
!chmod +x setup_script.py 
!python setup_script.py
!rm -rf  setup_script.py

# facerestore_models : $WORKSPACE/models/facerestore_models
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth> -d /content/ComfyUI/models/facerestore_models -o GFPGANv1.4.pth
# ---------------- facerestore_cfの設定終了 ---------------------

!wget <https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb>
!dpkg -i cloudflared-linux-amd64.deb

import subprocess
import threading
import time
import socket

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='')

%cd /content/ComfyUI

# Checkpointをダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors> -d /content/ComfyUI/models/checkpoints -o v1-5-pruned-emaonly.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/177164> -d /content/ComfyUI/models/checkpoints  -o braBeautifulRealistic_v70.safetensors

# VAEをダウンロード
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors> -d /content/ComfyUI/models/vae -o vae-ft-mse-840000-ema-pruned.safetensors

# Negative Promptをダウンロード
!git clone <https://huggingface.co/embed/negative> /content/ComfyUI/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 -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 -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 -o verybadimagenegative_v1.3.pt

# Upscaleのモデルをダウンロード
!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

%cd /content/ComfyUI

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

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

利用ファイル

materials.zip