Communitygithub.com

colab-media-pipeline

Use when generating batch images or videos on Google Colab GPUs via the colab CLI, setting up a fixed-engine + tasks.json media pipeline, or handling Colab A100 503 unavailability and L4 fallback.

O que é colab-media-pipeline?

colab-media-pipeline is a Claude Code agent skill that use when generating batch images or videos on Google Colab GPUs via the colab CLI, setting up a fixed-engine + tasks.json media pipeline, or handling Colab A100 503 unavailability and L4 fallback.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/LiPL2017/agent-colab-studio/tree/HEAD/skills/colab-media-pipeline

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

Colab Media Pipeline

Overview

Separate frozen rendering engines (render_images.py, render_videos.py) from dynamic storyboard inputs (tasks.json), and drive Colab through the bundled scripts/run_colab.py orchestrator.

Core rule: Once a project's engine scripts are frozen, agents ONLY edit tasks.json. Never rewrite model loading, quantization, aspect ratio, or style suffixes per run.

Agent-Driven Intake & Confirmation Checkpoints

The user should not need to memorize commands, flags, or setup order. Drive the workflow proactively:

  1. Auto-check project state first: Inspect <project-dir> for render_images.py, render_videos.py, requirements.txt, tasks.json, and run colab sessions.
  2. Confirm missing prerequisites before acting (ask concisely in one message, never guess):
    • Engine missing or MODEL_ID still REPLACE_WITH_YOUR_*: Ask which image/video model, aspect ratio, and visual style to lock, then copy ./templates/ and freeze after a 1-shot smoke test.
    • Gated model needs HF_TOKEN (e.g., black-forest-labs/FLUX.1-*) and HF_TOKEN is not set in the local environment: remind the user that colab CLI cannot read Colab Web UI Secrets — they must either accept the Hugging Face repo terms and provide a local Read HF_TOKEN (auto-forwarded by run_colab.py or passed via --env HF_TOKEN=..., never hardcoded), or switch to an ungated public model (e.g., SG161222/RealVisXL_V5.0) before provisioning a VM.
    • Stray active Colab session found in colab sessions: Ask whether to stop or reuse it before starting a new VM.
    • Before spending Compute Units (CU): Confirm the shot count, mode (images / videos), and GPU choice (l4 default vs a100 burst) if the user hasn't already specified them.
  3. Execute end-to-end once confirmed: Generate/update tasks.json, run scripts/run_colab.py, verify outputs/ + .meta.json, and confirm colab sessions is clean.

Project Layout

<project-dir>/
├── render_images.py       # FROZEN: text-to-image engine (aspect ratio, steps, style suffix, L4/A100 VRAM)
├── render_image_edit.py   # FROZEN: reference image edit / subject-swap engine (single-image & dual-ref)
├── render_videos.py       # FROZEN: I2V model, fps, duration, VAE tiling, L4/A100 VRAM profile
├── requirements.txt       # FROZEN: extra packages installed via `colab install -r`
├── tasks.json             # DYNAMIC: the ONLY file agents edit per storyboard run
└── outputs/               # Pulled results (.png / .mp4) + .meta.json (seed & prompt log)

Starter templates live in ./templates/ (render_images.py, render_image_edit.py, render_videos.py, tasks.example.json, requirements.example.txt). Match the template to the task type:

  • Text-to-image: render_images.py
  • Reference image edit / person swap / character consistency: render_image_edit.py (invoke with --mode images --script render_image_edit.py)
  • Image-to-video / reference video: render_videos.py (or custom --script render_v2v.py)

Standard Execution Flow

  1. Inspect active sessions first: Run colab sessions. Stop any forgotten idle session (colab stop -s <name>) before provisioning a new GPU.
  2. Edit ONLY tasks.json: Write scene-specific id and prompt (plus optional seed, overwrite, or local reference paths: image, ref_image, ref_images list, start_frame, end_frame, video, ref_video, ref_videos list, audio). run_colab.py automatically uploads any referenced local files to /content/<relative-path>. Do not repeat global style suffixes, aspect ratios, or negative prompts already locked in the engine.
  3. Run via the orchestrator (./scripts/run_colab.py):
    # Default: L4 (24GB) — fast, reliable, rarely 503s
    python <skill-dir>/scripts/run_colab.py --project-dir . --mode images --gpu l4
    
    # Burst: A100 (40GB, never --high-mem) with 503 retry + automatic L4 fallback
    python <skill-dir>/scripts/run_colab.py --project-dir . --mode images --gpu a100 --retries 6 --retry-interval 25
    
    # Reference image edit / subject swap (auto-uploads image / ref_image / ref_images)
    python <skill-dir>/scripts/run_colab.py --project-dir . --mode images --script render_image_edit.py --gpu l4
    
    # Video / reference-driven pass (auto-uploads referenced local images/videos; use --script for custom engines like render_v2v.py)
    python <skill-dir>/scripts/run_colab.py --project-dir . --mode videos --gpu l4
    
    # Pass secrets safely without writing to disk
    python <skill-dir>/scripts/run_colab.py --project-dir . --mode images --env HF_TOKEN=...
    
    Use --dry-run to preview exact commands. Use --keep / --reuse-session only when iterating rapidly in the same session, and always run colab stop -s <name> when done.
  4. Verify locally: Confirm expected files and .meta.json exist in outputs/ with non-zero size, and confirm colab sessions shows no stray running VM.

GPU Strategy (L4 Default, A100 Burst)

  • Default to --gpu l4 (24GB): Provisions in seconds and rarely hits 503. Engines auto-detect VRAM (< 35GB) and enable quantization + CPU offload.
  • A100 bursts use standard 40GB (--gpu A100 without --high-mem): 80GB high-RAM pools 503 far more often. Retry every 20–30s (5–8 attempts) on 503 Service Unavailable, then fall back to L4.
  • Never fall back to T4 for modern FLUX/Wan pipelines (OOM risk), and never request --high-mem on A100 in automated runs.

Colab CLI Gotchas (Hard Rules)

TrapRequired Behavior
colab exec default timeout is 30sAlways pass --timeout 0 for installs/model loads/rendering (run_colab.py enforces this).
colab list does not existUse colab sessions.
colab stop <name> failsAlways pass -s <name> (colab stop -s <name>).
colab auth / colab drivemount / colab replNever call from an agent — they require an interactive TTY and hang.
Colab Web UI Secrets (HF_TOKEN)Not accessible from colab CLI (Secrets can only be fetched when running from the Colab UI). Pass via local HF_TOKEN env var or --env HF_TOKEN=....
colab upload / colab downloadAlways pass both local and remote /content/... paths.
Running -f engine.py in Jupyter kernelDo not upload engine.py manually (exec -f streams it). Engine scripts read env vars (PIPELINE_TASKS, PIPELINE_OUTPUT_DIR), not argparse on kernel sys.argv.
Session left running after errorAlways wrap execution in try/finally: colab stop -s <name> (handled by run_colab.py).

Red Flags — STOP and Fix

  • Editing render_images.py or render_videos.py to change a prompt or "quick-fix" a storyboard run.
  • Running colab exec -f ... without --timeout 0.
  • Putting 16:9, anamorphic lens, or negative_prompt into every tasks.json entry when the engine locks style.
  • Leaving a Colab session running after a failed command.

Habilidades Relacionadas