Media sd

From damionrashford/media-os · View interactive version

Media sd is an AI agent skill from the GitHub repository damionrashford/media-os. Open-source AI image generation via ComfyUI (GPL-3.0, node-based runner) with STRICTLY permissive-license models: FLUX.1 [schnell] (Apache 2.0, Black Forest Labs fastest high-quality 4-step distilled model), Kolors (Apache 2.0, Kuaishou photorealistic diffusion), Sana (Apache 2.0, NVIDIA efficient D

How to use this skill

Skill file

Media SD (open-source image generation)

Context: $ARGUMENTS

Quick start

When to use

Step 1 — Pick a model

| Model | License | VRAM (FP16) | Strength | Use when |

|-------|---------|-------------|----------|----------|

| FLUX.1 [schnell] | Apache 2.0 | 24GB (or 12GB NF4) | Highest quality at 4 steps | Default for most users; fastest quality per second |

| Kolors | Apache 2.0 | 16GB | Photorealism, Chinese prompts strong | Photoreal faces/products; multilingual |

| Sana | Apache 2.0 | 12GB (runs on consumer cards) | Efficient DiT, up to 4096px | Tight VRAM budget, high resolution |

| Lumina-Next | Apache 2.0 | 24GB | Strong prompt adherence at high-res | Complex multi-subject prompts |

| HunyuanDiT | Tencent License 2.0 | 16GB | Bilingual EN/CN | Commercial use under >100M MAU cap (see Gotchas) |

| PixArt-Sigma | Per-checkpoint (check) | 12–20GB | Efficient transformer | Research / specific checkpoints — verify license per variant |

Read references/models.md for resolution ranges, speed benchmarks, recommended samplers, and per-model prompt quirks.

Check what's installed locally:

uv run .claude/skills/media-sd/scripts/sd.py check

Step 2 — Install ComfyUI and pull weights

ComfyUI is the canonical runtime for these models. It's GPL-3.0 and self-hosted.

uv run .claude/skills/media-sd/scripts/sd.py comfy-install
# prints: git clone https://github.com/comfyanonymous/ComfyUI
#         cd ComfyUI && python -m venv .venv && source .venv/bin/activate
#         pip install -r requirements.txt
#         python main.py --listen 127.0.0.1 --port 8188

Pull weights (downloads are big — 5–24 GB — so the script requires --yes to confirm):

uv run .../sd.py download --model flux-schnell --yes
# → downloads into ./ComfyUI/models/unet|vae|clip by default
# override with --comfy-root /path/to/ComfyUI

Or use HuggingFace diffusers directly (pure Python, no ComfyUI needed):

uv run .../sd.py install flux-schnell
# pip install diffusers transformers accelerate torch

Read references/comfyui.md for node-graph basics, the standard FLUX-schnell workflow JSON, ControlNet + LoRA wiring, and common node names.

Step 3 — Generate

Option A: Diffusers pipeline (recommended for one-shot)

uv run .../sd.py generate \
    --model flux-schnell \
    --prompt "a photo of a capybara wearing a tiny wizard hat, studio lighting" \
    --out out.png \
    --width 1024 --height 1024 \
    --steps 4 --guidance 0.0 --seed 42

FLUX-schnell is distilled — --steps 4 + --guidance 0.0 is the correct setting; more steps or guidance >1 will DEGRADE output. Kolors / Sana / Lumina want 20–30 steps and --guidance 4–7.

Option B: img2img (seed from an existing image)

uv run .../sd.py img2img \
    --model flux-schnell \
    --init-image input.png \
    --prompt "convert to oil painting" \
    --strength 0.6 \
    --out out.png

--strength 0.0 keeps the input unchanged; 1.0 ignores it. Useful range: 0.3–0.75.

Option C: ComfyUI workflow JSON

# Start ComfyUI in the background (one-time)
cd ~/ComfyUI && python main.py --listen 127.0.0.1 --port 8188 &

# Run a saved workflow (exported from ComfyUI UI via "Save (API Format)")
uv run .../sd.py comfy-workflow \
    --workflow flux_schnell_default.json \
    --out out.png \
    --server http://127.0.0.1:8188

The script POSTs to /prompt, polls /history/<prompt_id>, then pulls the resulting PNG from /view.

Step 4 — Integrate with ffmpeg

After generating stills, typical hand-offs:

Gotchas

Examples

Example 1: 4-step FLUX-schnell portrait

uv run .../sd.py generate \
    --model flux-schnell \
    --prompt "cinematic portrait of an astronaut, 35mm film, shallow DOF" \
    --out astronaut.png --width 1024 --height 1024 --steps 4 --seed 7

Example 2: Photoreal product shot with Kolors

uv run .../sd.py generate \
    --model kolors \
    --prompt "a red leather messenger bag on a marble table, softbox lighting" \
    --out bag.png --steps 25 --guidance 5.0

Example 3: High-res landscape on a 12GB card (Sana)

uv run .../sd.py generate \
    --model sana --prompt "snow-capped mountain valley at sunrise" \
    --out valley.png --width 2048 --height 2048 --steps 20 --dtype float16

Example 4: Run an exported ComfyUI FLUX workflow

# ComfyUI running on 8188
uv run .../sd.py comfy-workflow \
    --workflow flux_schnell_api.json \
    --out render.png \
    --timeout 300

Example 5: img2img style transfer

uv run .../sd.py img2img \
    --model flux-schnell --init-image photo.jpg \
    --prompt "anime illustration, pastel palette" \
    --strength 0.55 --steps 4 --out stylized.png

Troubleshooting

Error: `ModuleNotFoundError: No module named 'diffusers'`

Cause: the diffusers stack isn't installed in the active Python.

Solution: pip install diffusers transformers accelerate torch or run uv run .../sd.py install flux-schnell which pins the right versions.

Error: `CUDA out of memory`

Cause: model + latent doesn't fit in VRAM.

Solution: add --dtype float16, lower --width/--height to 768, enable --cpu-offload, or switch to Sana which is designed for 12 GB cards.

Error: `ConnectionRefusedError: 127.0.0.1:8188`

Cause: ComfyUI server isn't running.

Solution: cd ~/ComfyUI && python main.py --listen 127.0.0.1 --port 8188. Or run scripts/sd.py comfy-install for the exact setup commands.

Error: `Repository not found` / `401 Unauthorized` from HuggingFace

Cause: the model's HF repo is gated and requires authentication.

Solution: accept the terms on the HF page, then export HF_TOKEN=<your_hf_token> before re-running download. Even Apache-licensed weights sometimes require click-through acceptance.

FLUX output is blurry / over-saturated

Cause: used --guidance > 0 or --steps != 4 with flux-schnell.

Solution: FLUX-schnell is a distilled model. Use exactly --steps 4 --guidance 0.0. For CFG-style guidance, switch to flux-dev (but that is NON-COMMERCIAL — we don't ship a preset for it).

ComfyUI workflow import fails: "cannot execute node KSampler"

Cause: the JSON is the UI-format export, not API-format.

Solution: in ComfyUI UI, Settings → "Enable Dev mode Options", then "Save (API Format)". Or load the UI JSON into ComfyUI then re-export via the API button.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.