feat: add Wan 2.2 Image-to-Video ComfyUI Kaggle setup and workflows
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Install ComfyUI and dependencies"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Install ComfyUI and dependencies\n",
|
||||
"!pip install -q torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118\n",
|
||||
"!pip install -q huggingface_hub\n",
|
||||
"!mkdir -p /kaggle/tmp\n",
|
||||
"!git clone https://github.com/comfyanonymous/ComfyUI.git /kaggle/tmp/ComfyUI\n",
|
||||
"%cd /kaggle/tmp/ComfyUI\n",
|
||||
"!pip install -q -r requirements.txt\n",
|
||||
"\n",
|
||||
"# Install ComfyUI-Manager\n",
|
||||
"!git clone https://github.com/ltdrdata/ComfyUI-Manager.git custom_nodes/ComfyUI-Manager\n",
|
||||
"\n",
|
||||
"# Install ComfyUI-KJNodes (helper nodes used in the official LTX-2.3 GGUF workflow)\n",
|
||||
"!git clone https://github.com/kijai/ComfyUI-KJNodes.git custom_nodes/ComfyUI-KJNodes\n",
|
||||
"!pip install -q -r custom_nodes/ComfyUI-KJNodes/requirements.txt\n",
|
||||
"\n",
|
||||
"# Install the missing GGUF loader custom node\n",
|
||||
"!git clone https://github.com/city96/ComfyUI-GGUF.git custom_nodes/ComfyUI-GGUF\n",
|
||||
"%cd /kaggle/tmp/ComfyUI/custom_nodes/ComfyUI-GGUF\n",
|
||||
"\n",
|
||||
"# 1. Install required python libraries for GGUF parsing\n",
|
||||
"!pip install -q -r requirements.txt\n",
|
||||
"!pip install -q gguf sentencepiece\n",
|
||||
"\n",
|
||||
"print(\"\\nGGUF library dependencies successfully patched!\")\n",
|
||||
"!git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git custom_nodes/ComfyUI-VideoHelperSuite\n",
|
||||
"# 1. Move into the video helper suite directory\n",
|
||||
"%cd /kaggle/tmp/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite\n",
|
||||
"\n",
|
||||
"# 2. Force install the required system and video manipulation libraries\n",
|
||||
"!pip install -q -r requirements.txt\n",
|
||||
"!pip install -q decord av simplejson imageio-ffmpeg\n",
|
||||
"\n",
|
||||
"# Install cloudflared to expose the URL publicly\n",
|
||||
"!wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O cloudflared\n",
|
||||
"!chmod +x cloudflared\n",
|
||||
"\n",
|
||||
"%cd /kaggle/tmp/ComfyUI\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Error observed:** `[Errno 2] No such file or directory: '/kaggle/tmp/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite'` \u2014 the `%cd` into that directory failed right after cloning it (likely a timing/path issue), so the following `pip install -r requirements.txt` and extra installs may have run in the wrong directory."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Download models"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%cd /kaggle/tmp/ComfyUI\n",
|
||||
"\n",
|
||||
"# 3. Create the required directory for clip_vision models\n",
|
||||
"!mkdir -p models/clip_vision\n",
|
||||
"# Create standard target directories\n",
|
||||
"!mkdir -p models/unet\n",
|
||||
"!mkdir -p models/text_encoders\n",
|
||||
"!mkdir -p models/vae\n",
|
||||
"!mkdir -p models/clip_vision\n",
|
||||
"\n",
|
||||
"# Use huggingface_hub to fetch your chosen model paths\n",
|
||||
"from huggingface_hub import hf_hub_download\n",
|
||||
"\n",
|
||||
"print(\"Downloading clip_vision_h.safetensors from the correct repository...\")\n",
|
||||
"hf_hub_download(\n",
|
||||
" repo_id=\"Comfy-Org/Wan_2.1_ComfyUI_repackaged\",\n",
|
||||
" filename=\"split_files/clip_vision/clip_vision_h.safetensors\",\n",
|
||||
" local_dir=\"models/clip_vision\",\n",
|
||||
" local_dir_use_symlinks=False\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"Downloading the Image-to-Video (I2V) GGUF file...\")\n",
|
||||
"hf_hub_download(\n",
|
||||
" repo_id=\"befox/WAN2.2-14B-Rapid-AllInOne-GGUF\",\n",
|
||||
" filename=\"v10/wan2.2-i2v-rapid-aio-v10-Q4_K.gguf\",\n",
|
||||
" local_dir=\"models/unet\",\n",
|
||||
" local_dir_use_symlinks=False\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"Downloading Wan 2.1 VAE...\")\n",
|
||||
"hf_hub_download(\n",
|
||||
" repo_id=\"Comfy-Org/Wan_2.2_ComfyUI_Repackaged\",\n",
|
||||
" filename=\"split_files/vae/wan_2.1_vae.safetensors\",\n",
|
||||
" local_dir=\"models/vae\",\n",
|
||||
" local_dir_use_symlinks=False\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"Downloading Text Encoder...\")\n",
|
||||
"hf_hub_download(\n",
|
||||
" repo_id=\"Comfy-Org/Wan_2.1_ComfyUI_repackaged\",\n",
|
||||
" filename=\"split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors\",\n",
|
||||
" local_dir=\"models/text_encoders\",\n",
|
||||
" local_dir_use_symlinks=False\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"All set! Files successfully downloaded to /kaggle/tmp/ComfyUI/models/.\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"*(Output confirmed all four files downloaded successfully, with a deprecation warning about `local_dir_use_symlinks` \u2014 harmless, just remove that argument since it's ignored in current `huggingface_hub`.)*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!find /kaggle/tmp/ComfyUI/models/unet \\\n",
|
||||
" /kaggle/tmp/ComfyUI/models/text_encoders \\\n",
|
||||
" /kaggle/tmp/ComfyUI/models/vae \\\n",
|
||||
" /kaggle/tmp/ComfyUI/models/clip_vision \\\n",
|
||||
" -type f -printf '%p\\t%k KB\\n'\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** confirms the four model files are present with expected sizes (unet ~10.6M KB, text_encoder ~6.6M KB, vae ~248K KB, clip_vision ~1.2M KB), plus leftover placeholder/cache files."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!ps -fp 247\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** empty \u2014 PID 247 doesn't exist (stale reference, harmless)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!curl -I http://127.0.0.1:8182\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** `curl: (7) Failed to connect to 127.0.0.1 port 8182 after 0 ms: Connection refused` \u2014 ComfyUI server not yet running at this point."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Create tunnel and get URL"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!ps aux | grep '[m]ain.py'\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** `root 238 33.6 0.3 133508 113412 ? S 06:12 0:02 python3 main.py --listen 0.0.0.0 --port 8182 --enable-manager` \u2014 confirms ComfyUI's `main.py` IS running on port 8182."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!curl -I http://127.0.0.1:8182\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** still `Connection refused` \u2014 this is the core problem. The process is running (per `ps aux`) but not accepting connections on 8182 yet (could be still initializing/loading models, or bound to a different interface)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!ss -ltnp | grep 8182\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Output:** empty \u2014 no output was captured/shown for this cell, so it's unclear if anything is actually listening on 8182."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import subprocess\n",
|
||||
"\n",
|
||||
"tunnel = subprocess.Popen(\n",
|
||||
" [\"/kaggle/tmp/cloudflared\", \"tunnel\", \"--url\", \"http://localhost:8182\"],\n",
|
||||
" stdout=subprocess.PIPE,\n",
|
||||
" stderr=subprocess.STDOUT\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"print(\"Waiting for URL... (may take 15-20 seconds)\")\n",
|
||||
"for line in iter(tunnel.stdout.readline, b\"\"):\n",
|
||||
" line = line.decode().strip()\n",
|
||||
" print(line)\n",
|
||||
" if \"https://\" in line and \"trycloudflare.com\" in line:\n",
|
||||
" for word in line.split():\n",
|
||||
" if word.startswith(\"https://\") and \"trycloudflare.com\" in word:\n",
|
||||
" print(\"\\n\\u2705 Your ComfyUI URL:\", word)\n",
|
||||
" break\n",
|
||||
" break\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Core issue to investigate:** `main.py` shows as running in `ps aux`, but `curl` to `127.0.0.1:8182` keeps refusing the connection \u2014 so the tunnel step never gets a live server to connect to. Check whether ComfyUI is still loading the (large) GGUF model, whether it crashed silently after the `ps` snapshot, or whether it's listening on a different port/interface than expected."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.12.13",
|
||||
"mimetype": "text/x-python",
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"pygments_lexer": "ipython3",
|
||||
"nbconvert_exporter": "python",
|
||||
"file_extension": ".py"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,242 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b2c580f4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Wan 2.2 (TI2V-5B) — Test Notebook (Kaggle)\n",
|
||||
"\n",
|
||||
"This notebook assumes you have **already installed dependencies and attached your dataset** on Kaggle.\n",
|
||||
"It only covers **testing** the model: loading it, running a text-to-video generation, and an image-to-video generation.\n",
|
||||
"\n",
|
||||
"**Before running:** in the right-hand panel, make sure your dataset is attached and Accelerator is set to **GPU (T4 x2 or P100)**."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aa60ba24",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 1. Check GPU"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "da64aff1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!nvidia-smi"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "af741a96",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 2. Set your paths\n",
|
||||
"\n",
|
||||
"Edit the variables below to match where your model files live.\n",
|
||||
"- If you uploaded the Wan 2.2 model as a Kaggle **Dataset**, it will be mounted under `/kaggle/input/<your-dataset-name>/`.\n",
|
||||
"- If you haven't pre-downloaded the weights and want to pull them directly from Hugging Face instead, leave `LOCAL_MODEL_PATH` as `None` and the notebook will fall back to downloading `Wan-AI/Wan2.2-TI2V-5B-Diffusers` automatically."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "569b64e8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# --- EDIT THIS ---\n",
|
||||
"# Set to the folder path of your attached Kaggle dataset if you pre-downloaded the model,\n",
|
||||
"# e.g. \"/kaggle/input/wan22-ti2v-5b/Wan2.2-TI2V-5B-Diffusers\"\n",
|
||||
"# Leave as None to auto-download from Hugging Face instead.\n",
|
||||
"LOCAL_MODEL_PATH = None\n",
|
||||
"\n",
|
||||
"# Where to save generated test videos\n",
|
||||
"OUTPUT_DIR = \"/kaggle/working/outputs\"\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"os.makedirs(OUTPUT_DIR, exist_ok=True)\n",
|
||||
"\n",
|
||||
"# Quick sanity check of what's available under /kaggle/input\n",
|
||||
"for root, dirs, files in os.walk(\"/kaggle/input\"):\n",
|
||||
" print(root)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "818966ea",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 3. Imports"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "25cbb788",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"from diffusers import WanPipeline\n",
|
||||
"from diffusers.utils import export_to_video, load_image\n",
|
||||
"from IPython.display import Video, display\n",
|
||||
"\n",
|
||||
"print(\"Torch version:\", torch.__version__)\n",
|
||||
"print(\"CUDA available:\", torch.cuda.is_available())\n",
|
||||
"if torch.cuda.is_available():\n",
|
||||
" print(\"GPU:\", torch.cuda.get_device_name(0))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7ae9448b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 4. Load the Wan 2.2 model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2fa2c921",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model_source = LOCAL_MODEL_PATH if LOCAL_MODEL_PATH else \"Wan-AI/Wan2.2-TI2V-5B-Diffusers\"\n",
|
||||
"print(\"Loading model from:\", model_source)\n",
|
||||
"\n",
|
||||
"pipe = WanPipeline.from_pretrained(\n",
|
||||
" model_source,\n",
|
||||
" torch_dtype=torch.bfloat16\n",
|
||||
")\n",
|
||||
"pipe.to(\"cuda\")\n",
|
||||
"\n",
|
||||
"# Keeps VRAM usage safe on Kaggle's T4/P100 GPUs\n",
|
||||
"pipe.enable_model_cpu_offload()\n",
|
||||
"\n",
|
||||
"print(\"Model loaded successfully.\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ebabef47",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 5. Test — Text-to-Video\n",
|
||||
"\n",
|
||||
"Edit `prompt` below to whatever you want to test."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0ab5a843",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prompt = \"A golden retriever running on a beach at sunset, cinematic lighting\"\n",
|
||||
"\n",
|
||||
"t2v_output = pipe(\n",
|
||||
" prompt=prompt,\n",
|
||||
" num_frames=49,\n",
|
||||
" guidance_scale=5.0\n",
|
||||
").frames[0]\n",
|
||||
"\n",
|
||||
"t2v_path = os.path.join(OUTPUT_DIR, \"test_t2v_output.mp4\")\n",
|
||||
"export_to_video(t2v_output, t2v_path, fps=24)\n",
|
||||
"print(\"Saved:\", t2v_path)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "290a6a8f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"display(Video(t2v_path, embed=True))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e6490183",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 6. Test — Image-to-Video\n",
|
||||
"\n",
|
||||
"Set `input_image_path` to an image in your attached dataset, or use a URL."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d4c48abb",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# --- EDIT THIS ---\n",
|
||||
"# Local path to an image from your dataset, e.g. \"/kaggle/input/my-images/sample.jpg\"\n",
|
||||
"# Or leave as a URL to test with a sample image instead.\n",
|
||||
"input_image_path = \"https://images.unsplash.com/photo-1519681393784-d120267933ba\"\n",
|
||||
"\n",
|
||||
"input_image = load_image(input_image_path)\n",
|
||||
"\n",
|
||||
"i2v_prompt = \"the scene comes to life with gentle, natural motion\"\n",
|
||||
"\n",
|
||||
"i2v_output = pipe(\n",
|
||||
" image=input_image,\n",
|
||||
" prompt=i2v_prompt,\n",
|
||||
" num_frames=49,\n",
|
||||
" guidance_scale=5.0\n",
|
||||
").frames[0]\n",
|
||||
"\n",
|
||||
"i2v_path = os.path.join(OUTPUT_DIR, \"test_i2v_output.mp4\")\n",
|
||||
"export_to_video(i2v_output, i2v_path, fps=24)\n",
|
||||
"print(\"Saved:\", i2v_path)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7f19884f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"display(Video(i2v_path, embed=True))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "04f8b687",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 7. Notes\n",
|
||||
"\n",
|
||||
"- Both test videos are saved in `/kaggle/working/outputs/` — you can download them from the notebook's **Output** panel after the run finishes (Kaggle auto-saves everything in `/kaggle/working/` for you to download as an artifact).\n",
|
||||
"- If you hit a CUDA out-of-memory error, lower `num_frames` from 49 to 25, or reduce `guidance_scale`.\n",
|
||||
"- Kaggle free GPU sessions have a **~9-12 hour limit** and **30 hours/week** quota — keep that in mind if you plan to chain this into a longer fine-tuning session later.\n",
|
||||
"- This notebook only *tests* the base model. Fine-tuning (LoRA) requires a separate training script and dataset preprocessing step, not covered here."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user