インストールコマンド
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>
# sdxl_prompt_styler(MilehighStyler)をインストール
!git clone <https://github.com/twri/sdxl_prompt_styler.git>
# ▼ ComfyUI-Impact-Packのインストール手順の参考URL:
# <https://github.com/ltdrdata/ComfyUI-Impact-Pack?tab=readme-ov-file#installation>
!git clone <https://github.com/ltdrdata/ComfyUI-Impact-Pack.git>
%cd $WORKSPACE/custom_nodes/ComfyUI-Impact-Pack
!git submodule update --init --recursive
%cd $WORKSPACE/custom_nodes
!git clone <https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes>
!git clone <https://github.com/jags111/efficiency-nodes-comfyui>
# 日本語フォントを設定
# 1. ZIPファイルをtmpフォルダーにダウンロード
!mkdir -p /tmp
!wget -O /tmp/ipag00303.zip "<https://moji.or.jp/wp-content/ipafont/IPAfont/ipag00303.zip>"
# 2. ファイルを解凍
!unzip /tmp/ipag00303.zip -d /tmp
# 3. ipag.ttfファイルのみを指定のフォルダーに配置
!mkdir -p /content/ComfyUI/custom_nodes/ComfyUI_Comfyroll_CustomNodes/fonts
!mv /tmp/ipag00303/ipag.ttf /content/ComfyUI/custom_nodes/ComfyUI_Comfyroll_CustomNodes/fonts/
# 4. tmpファイルを削除
!rm -rf /tmp/ipag00303
!rm /tmp/ipag00303.zip
# アニメーションファイルの設定
# 1. ZIPファイルをtmpフォルダーにダウンロード
!mkdir -p /tmp
!wget -O /tmp/sdxlMileHighPromptStylerNowWith25_comfyoldMILEHIGH.zip "<https://civitai.com/api/download/models/130795>"
# 2. ファイルを解凍
!unzip /tmp/sdxlMileHighPromptStylerNowWith25_comfyoldMILEHIGH.zip -d /tmp
# 3. sdxl_styles.jsonファイルを指定のフォルダーに配置
!mv /tmp/sdxl_styles.json /content/ComfyUI/custom_nodes/sdxl_prompt_styler/sdxl_styles_animation.json
# 4. tmpファイルを削除
!rm -rf /tmp/sdxlMileHighPromptStylerNowWith25_comfyoldMILEHIGH
!rm /tmp/sdxlMileHighPromptStylerNowWith25_comfyoldMILEHIGH.zip
# ネガティブプロンプト
!git clone <https://huggingface.co/embed/negative> $WORKSPACE/models/embeddings/negative
!wget -c -P $WORKSPACE/models/embeddings/negative/
%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/182077> -d $WORKSPACE/models/checkpoints -o starlightXLAnimated_v3.safetensors
!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M <https://civitai.com/api/download/models/211388> -d $WORKSPACE/models/checkpoints -o cinevisionxlBySocalguitaristEasily_releaseV150Bakedvae.safetensors
# 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
利用ファイル
workflow.zip