Skip to content

Instantly share code, notes, and snippets.

@safa-dayo
Created July 22, 2025 23:25
Show Gist options
  • Save safa-dayo/dace33c2c9f539e76d124e0466270a5c to your computer and use it in GitHub Desktop.
Save safa-dayo/dace33c2c9f539e76d124e0466270a5c to your computer and use it in GitHub Desktop.
Wan 2.1 Fusion XをGoogle Colabで試すためのColabノートブック
#@title Wan 2.1 Fusion X
### setup ComfyUI ###
from pathlib import Path
OPTIONS = {}
USE_GOOGLE_DRIVE = False #@param {type:"boolean"}
UPDATE_COMFY_UI = True #@param {type:"boolean"}
USE_COMFYUI_MANAGER = True #@param {type:"boolean"}
INSTALL_CUSTOM_NODES_DEPENDENCIES = True #@param {type:"boolean"}
OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE
OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI
OPTIONS['USE_COMFYUI_MANAGER'] = USE_COMFYUI_MANAGER
OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES'] = INSTALL_CUSTOM_NODES_DEPENDENCIES
current_dir = !pwd
WORKSPACE = f"{current_dir[0]}/ComfyUI"
if OPTIONS['USE_GOOGLE_DRIVE']:
!echo "Mounting Google Drive..."
%cd /
from google.colab import drive
drive.mount('/content/drive')
WORKSPACE = "/content/drive/MyDrive/ComfyUI"
%cd /content/drive/MyDrive
![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI
%cd $WORKSPACE
if OPTIONS['UPDATE_COMFY_UI']:
!echo -= Updating ComfyUI =-
# Correction of the issue of permissions being deleted on Google Drive.
![ -f ".ci/nightly/update_windows/update_comfyui_and_python_dependencies.bat" ] && chmod 755 .ci/nightly/update_windows/update_comfyui_and_python_dependencies.bat
![ -f ".ci/nightly/windows_base_files/run_nvidia_gpu.bat" ] && chmod 755 .ci/nightly/windows_base_files/run_nvidia_gpu.bat
![ -f ".ci/update_windows/update_comfyui_and_python_dependencies.bat" ] && chmod 755 .ci/update_windows/update_comfyui_and_python_dependencies.bat
![ -f ".ci/update_windows_cu118/update_comfyui_and_python_dependencies.bat" ] && chmod 755 .ci/update_windows_cu118/update_comfyui_and_python_dependencies.bat
![ -f ".ci/update_windows/update.py" ] && chmod 755 .ci/update_windows/update.py
![ -f ".ci/update_windows/update_comfyui.bat" ] && chmod 755 .ci/update_windows/update_comfyui.bat
![ -f ".ci/update_windows/README_VERY_IMPORTANT.txt" ] && chmod 755 .ci/update_windows/README_VERY_IMPORTANT.txt
![ -f ".ci/update_windows/run_cpu.bat" ] && chmod 755 .ci/update_windows/run_cpu.bat
![ -f ".ci/update_windows/run_nvidia_gpu.bat" ] && chmod 755 .ci/update_windows/run_nvidia_gpu.bat
!git pull
!echo -= Install dependencies =-
!pip3 install accelerate
!pip3 install einops transformers>=4.28.1 safetensors>=0.4.2 aiohttp pyyaml Pillow scipy tqdm psutil tokenizers>=0.13.3
!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
!pip3 install torchsde
!pip3 install kornia>=0.7.1 spandrel soundfile sentencepiece
if OPTIONS['USE_COMFYUI_MANAGER']:
%cd custom_nodes
# Correction of the issue of permissions being deleted on Google Drive.
![ -f "ComfyUI-Manager/check.sh" ] && chmod 755 ComfyUI-Manager/check.sh
![ -f "ComfyUI-Manager/scan.sh" ] && chmod 755 ComfyUI-Manager/scan.sh
![ -f "ComfyUI-Manager/node_db/dev/scan.sh" ] && chmod 755 ComfyUI-Manager/node_db/dev/scan.sh
![ -f "ComfyUI-Manager/scripts/install-comfyui-venv-linux.sh" ] && chmod 755 ComfyUI-Manager/scripts/install-comfyui-venv-linux.sh
![ -f "ComfyUI-Manager/scripts/install-comfyui-venv-win.bat" ] && chmod 755 ComfyUI-Manager/scripts/install-comfyui-venv-win.bat
![ ! -d ComfyUI-Manager ] && echo -= Initial setup ComfyUI-Manager =- && git clone https://github.com/ltdrdata/ComfyUI-Manager
%cd ComfyUI-Manager
!git pull
%cd $WORKSPACE
if OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES']:
!echo -= Install custom nodes dependencies =-
!pip install GitPython
!python custom_nodes/ComfyUI-Manager/cm-cli.py restore-dependencies
# ModuleNotFoundError: No module named 'av'がでるため、あらかじめavをインストール
!pip install av
#@markdown ---
#@markdown **ダウンロードするモデルにチェックを入れて実行してください**
#@markdown ### Text-to-Video
# 14B / 標準
use_T2V_Master_14B = False #@param {type:"boolean"}
#@markdown ### Text-to-Video - Phantom
#@markdown ### (注意:こちらは現状のコードでは動きません)
# Phantom
use_T2V_Phantom_14B = False #@param {type:"boolean"}
#@markdown ### Image-to-Video
# 720p
use_I2V_720p_14B = False #@param {type:"boolean"}
# 480p
use_I2V_480p_14B = False #@param {type:"boolean"}
import os, subprocess, pathlib, textwrap, shlex, sys
from pathlib import Path
%cd $WORKSPACE
HF="https://huggingface.co/vrgamedevgirl84/Wan14BT2VFusioniX/resolve/main"
REPACK="https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/split_files/diffusion_models"
MODELS = []
if use_T2V_Master_14B:
MODELS.append((f"{HF}/WanT2V_MasterModel.safetensors", "models/diffusion_models"))
if use_T2V_Phantom_14B:
MODELS.append((f"{HF}/Wan14BT2VFusioniX_Phantom_fp16.safetensors", "models/diffusion_models"))
# sageattentionが必要になるのでインストール
!pip install --no-cache-dir "triton>=3.1.0" "sageattention>=1.0.6"
if use_I2V_720p_14B:
MODELS.append((f"{HF}/Wan14Bi2vFusioniX_fp16.safetensors", "models/diffusion_models"))
if use_I2V_480p_14B:
MODELS.append((f"{REPACK}/wan2.1_i2v_480p_14B_bf16.safetensors", "models/diffusion_models"))
# Fusion X LoRAの追加
if use_T2V_Master_14B or use_T2V_Phantom_14B:
MODELS.append((f"{HF}/FusionX_LoRa/Wan2.1_T2V_14B_FusionX_LoRA.safetensors",
"models/loras"))
if use_I2V_720p_14B or use_I2V_480p_14B:
MODELS.append((f"{HF}/FusionX_LoRa/Wan2.1_I2V_14B_FusionX_LoRA.safetensors",
"models/loras"))
COMMON = [
# --- text-encoder -------------------------------------------------
("https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/"
"split_files/text_encoders/umt5_xxl_fp16.safetensors",
"models/text_encoders"),
# --- CLIP-Vision --------------------------------------------------
("https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/"
"split_files/clip_vision/clip_vision_h.safetensors",
"models/clip_vision"),
# VAE
("https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/resolve/main/"
"split_files/vae/wan_2.1_vae.safetensors",
"models/vae"),
# LoRA
("https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/"
"Wan21_CausVid_14B_T2V_lora_rank32_v2.safetensors",
"models/loras"),
("https://huggingface.co/alibaba-pai/Wan2.1-Fun-Reward-LoRAs/resolve/main/"
"Wan2.1-Fun-14B-InP-MPS.safetensors",
"models/loras"),
("https://huggingface.co/Kijai/WanVideo_comfy/resolve/main/"
"Wan21_AccVid_I2V_480P_14B_lora_rank32_fp16.safetensors",
"models/loras"),
("https://huggingface.co/vrgamedevgirl84/Wan14BT2VFusioniX/resolve/main/"
"OtherLoRa's/Wan14B_RealismBoost.safetensors",
"models/loras"),
("https://huggingface.co/vrgamedevgirl84/Wan14BT2VFusioniX/resolve/main/"
"OtherLoRa's/DetailEnhancerV1.safetensors",
"models/loras"),
]
MODELS.extend(COMMON)
# ---- ダウンロード ----
for url, subdir in MODELS:
dest = Path(WORKSPACE) / subdir
dest.mkdir(parents=True, exist_ok=True)
fname = url.split("/")[-1]
print(f"⬇︎ {fname}")
!wget -q -c {shlex.quote(url)} -O {shlex.quote(str(dest/fname))}
print("\n✅ Model download complete\n")
# ========== カスタムノード導入 ==========
%cd $WORKSPACE/custom_nodes
NODES = {
"ComfyUI-WanVideoWrapper": "https://github.com/kijai/ComfyUI-WanVideoWrapper.git",
"ComfyUI-VideoHelperSuite": "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git",
"ComfyUI-KJNodes": "https://github.com/kijai/ComfyUI-KJNodes.git",
"comfyui_controlnet_aux": "https://github.com/Fannovel16/comfyui_controlnet_aux.git",
"ComfyUI_essentials": "https://github.com/cubiq/ComfyUI_essentials.git", # 任意
}
for name, repo in NODES.items():
if not pathlib.Path(name).exists():
!git clone -q {repo} {name}
else:
!git -C {name} pull -q
# requirements.txt があればインストール
if pathlib.Path(name,"requirements.txt").exists():
!pip install -q -r {name}/requirements.txt
%cd $WORKSPACE
print("✅ Custom nodes ready\n")
# ---- cloudflared ----
!wget -P ~ 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
import urllib.request
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", "http://127.0.0.1:{}".format(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()
!python main.py --dont-print-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment