Communitygithub.com

collage-scenes

規劃並生成超現實拼貼影片的場景影像——為每個場景決定使用哪個影像模型,根據風格指南和腳本撰寫提示詞,在 Atlas Cloud 或 Higgsfield 上生成並獲取價格確認,然後將每個場景拆分為乾淨的背景和每個動態元素的透明圖層,準備進行動畫製作。

collage-scenes 是什麼?

collage-scenes 是一個 AI 代理技能,用於自動化拼貼風格影片的場景生成與圖層拆分流程。它從 `style/style.json` 和 `script/script.json` 讀取輸入,為腳本中的每一行規劃一個場景,並決定使用 Atlas Cloud(支援 Seedream、GPT Image 等模型)或 Higgsfield 作為生成提供者。該技能會先取得每張圖片的報價並等待使用者確認,然後才實際生成影像。生成後,它會使用 Seedream 的圖層分解功能、背景移除工具或本地自訂的 `cutout.mjs` 腳本,將每個場景拆分為一個乾淨的背景圖層和多個獨立的透明前景圖層,並透過 `layers-import.mjs` 和 `layers-check.mjs` 腳本自動校正圖層的位置與縮放比例。此技能適用於 Claude Code、Cursor 等支援工具呼叫的 AI 代理,可作為拼貼影片製作流程的第四步。使用者應先安裝相依套件 (`npm i puppeteer-core`),並確保擁有對應 API 的存取權限。

相容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/annderson8/collage-studio/tree/HEAD/skills/collage-scenes

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Collage Scenes:規劃 → 生成 → 拆分為圖層

輸入:style/style.json(+ style/refs/)、script/script.json。使用者已有的影像可取代任何生成的場景。 輸出至 <project>/scenes/:scenes.json、01.png…、layers/<id>/ 和 manifest.json/js(格式請參閱 collage-reel/references/project-format.md)。腳本位於此技能的 scripts/ 資料夾中;請在專案根目錄執行 npm i puppeteer-core 後再執行它們。

1 · 規劃 → scenes.json

一個場景對應一行腳本(01 = 第 0 行)。每個場景的格式如下:

{ "id": "01", "line": 0, "source": "generate", "provider": "atlas", "model": "bytedance/seedream-v5.0-pro/edit",
  "prompt": "<style.prompt> + 這行的轉折點 + 連續性裝置 + 構圖說明",
  "pieces": ["紅色圓形", "男人", "線軸頭", "紙帶"], "moment": "線軸頭在說『圖靈』時落下;紙帶滑入",
  "split": "bytedance/seedream-v5.0-flash/layer-decomposition" }   // 每個場景依圖層數量收費 $0.16–0.29(已測試)

提供者。 取決於哪些連接器活躍:atlas(工具 atlas_*)或 higgsfield(工具 generate_image、models_explore…)。兩者都連線:詢問使用者要用哪一個(他們有額度或方案的),並在整個專案中維持一致,以保持外觀統一。只有一個連線:直接使用。拆分階段可以使用與生成階段不同的提供者(例如在 Higgsfield 生成,在 Atlas 分解)。

為每個場景選擇:

  • 來源:generate、user(使用者提供的影像,複製到 scenes/<id>.png),或 edit(從先前場景衍生以保持連續性,例如相同的紙張和紅色圓形,加上新物體)。
  • Atlas 上的模型(檢查哪些活躍:atlas_list_models type=Image,並用 atlas_get_model_info 取得參數):
    • 預設 bytedance/seedream-v5.0-pro/edit,並將風格參考作為輸入影像(可保持外觀);
    • 若需嚴格匹配:bytedance/seedream-v5.0-lite/edit-sequential 或 bytedance/seedream-v4.7/edit-sequential(一次請求最多 15 張連貫影像);
    • 影像內有清晰文字(少見:字幕由程式繪製):openai/gpt-image-2.5-sunburst/edit;
    • 如果某個模型缺失或無法接受輸入,則使用 Atlas Cloud 預設順序中的下一個(GPT Image 2.5 Sunburst,然後 Nano Banana,再來 GPT Image 2)。
  • Higgsfield 上的模型:使用 models_explore,參數為 action: "recommend"、type: "image"、input: "image" 以及類似「從風格參考影像創作復古拼貼照片,9:16」的查詢;然後對選取的模型執行 action: "get" 以取得其長寬比、參數和 medias 角色。預設為 gpt_image_2_6(Higgsfield 的通用模型,擅長遵循參考);若 Seedream 模型有列出且使用者偏好,則使用它。請勿使用 Higgsfield 的特殊路徑(Soul、Marketing Studio、網紅):它們會改變外觀。
  • 拆分:預設為 bytedance/seedream-v5.0-flash/layer-decomposition(Atlas);擁擠場景使用 …-pro/layer-decomposition;remove-background(Higgsfield 或 Atlas 背景移除 → 當無圖層分解時使用 cutout.mjs --mask);local 則僅使用 cutout.mjs(免費,最適用於純色背景)。

尺寸:影片的長寬比(9:16 → 模型最接近的縱向尺寸,允許時 ≥ 1080×1920)。Seedream 5.0 Pro 僅接受其預設尺寸:9:16 為 "size": "1584*2816"(1440*2560 會被拒絕);請使用 atlas_get_model_info 讀取清單。請要求 "output_format": "png"。

提示詞規則

  • 從 style.prompt 開始,然後是轉折點,再來是構圖:「英雄在畫面中央,前方有一個巨大的紅色圓形,周圍有小的紅色形狀,頂部 15% 是單純的方格紙」。
  • 要求清楚分離的物件,彼此之間有間距以及它們後方是純色背景。這有助於圖層保持乾淨。
  • 影像中不要有文字。每個場景中使用相同的連續性裝置。
  • 保持畫面上方 15% 為純色背景:字幕會放在那裡。如果背景色與字幕顏色相同的大形狀(例如紅色字幕下方的紅色圓形)會使字幕無法閱讀。
  • 完整範本與技巧:請參閱 references/scene-prompts.md。

2 · 報價、確認、生成

在 Atlas Cloud 上

  1. 參考影像:使用 atlas_get_upload_url 上傳 style/refs/* 一次(一個 URL 可服務多個檔案),或使用 atlas_search_assets + atlas_use_assets 重複使用資料庫資產。
  2. 對每一個生成與拆分呼叫進行報價(不要設定 confirmed),並顯示一個表格:場景、模型、價格以及總計。在新訊息中等待使用者確認。 如果使用者更改了任何內容,使用 atlas_cancel_quote(原因 replaced)撤回舊報價。 報價有效期為 1 小時(confirmation_valid_seconds)。在展示已核准的場景時才對拆分進行報價,不要提前。如果確認返回 expired(未收取任何費用),則重新報價並再次詢問:新報價需要自己的確認。拆分依據其返回的圖層數量計費,因此報價是上限(已測試:報價 $0.306,實際收費 $0.16–0.29)。
  3. 提交已確認的呼叫,輪詢 atlas_get_prediction,將每個影像下載至 scenes/<id>.png。
  4. 在拆分之前,將所有場景顯示為一排:
    ffmpeg -y -loglevel error $(for f in scenes/[0-9]*.png; do echo -i $f; done) -filter_complex "$(n=$(ls scenes/[0-9]*.png | wc -l); for i in $(seq 0 $((n-1))); do printf "[$i]scale=240:-1[v$i];"; done; for i in $(seq 0 $((n-1))); do printf "[v$i]"; done; echo "hstack=inputs=$n")" scenes/row.png
    
    檢查外觀是否一致、轉折點在縮圖尺寸下是否可辨識、物件是否可分離、且沒有文字。僅重新生成失敗的場景(再次報價)。顯示該排影像並等待核准:拆分和動畫製作都基於這些影像。

在 Higgsfield 上

  1. 參考影像:對每個 style/refs/*(及任何使用者影像)使用 media_upload,參數為 files: [...],然後使用 curl 將每個檔案 PUT 到其 upload_url,最後執行 media_confirm。將返回的 media id 保存在 scenes/scenes.json 中("refs": [...]),以便後續場景無需重新上傳即可重複使用。
  2. 價格:對每個場景使用 estimate_image_cost(參數與將要發送的相同:模型、提示詞、aspect_ratio 9:16、以及模型為參考影像列出的角色 medias)。顯示一個表格(場景、模型、點數)及總計;在新訊息中等待使用者確認。如果某個呼叫回覆 unlim_choice(免費試用生成 vs 點數),則將該問題交給使用者;永遠不要替他們選擇。
  3. 生成:使用 generate_image_batch,每個場景一個項目(一次呼叫整個集合可保持外觀一致),然後 jobs_wait 直到完成。遵循工具自身關於目標資料夾/專案的規則(get_preferences)。逾時時,不要盲目重新提交:先檢查 job id。
  4. 將每個結果下載至 scenes/<id>.png(curl -L -o scenes/01.png "<result url>";如果不是 PNG 格式,使用 ffmpeg 轉換),並在 scenes.json 中保留每個場景的 Higgsfield job id("job_id"):編輯和背景移除會直接使用它。
  5. 與 Atlas 相同的一排影像檢查與核准(上述步驟 4)。對於偏離的場景,僅重新生成那一個;為保持連續性,將一個好場景的 job id 作為額外參考傳遞。

3 · 拆分為圖層

圖層分解(Atlas)。 使用 {"image": "asset://<asset_id>"}(已在步驟 2 中報價;使用上傳時的 asset id,以免輸入在確認前過期)呼叫拆分模型。返回的內容(已測試):僅包含檔案:…_base.jpeg(乾淨的背景)和 …_layer_1.png … _layer_N.png,每個都裁切到其物件範圍,通常以其自身比例重新渲染,沒有名稱、順序或位置。輪詢 atlas_get_prediction:當檔案複製到 Atlas 儲存體時,outputs 會保持空白數秒(transfer_pending);再次輪詢,或使用 temporary_outputs(有效 24 小時)。下載至 scenes/layers/<id>/,命名為 base.jpeg 和 layer_1.png …(保留編號)。

然後將這些圖層顯示為一排,並編寫 scenes/layers/<id>/layers.json 來命名要動畫化的物件並跳過不需要的(嵌入影像的文字、雜點、重複項):

{ "layers": [ { "file": "layer_1.png", "name": "circle" }, { "file": "layer_5.png", "name": "turing" },
              { "file": "layer_9.png", "skip": true } ] }
node "<skill dir>/scripts/layers-import.mjs" scenes/layers/<id>      # 每個場景約 20 秒;DEBUG=1 可顯示重疊決策

它會透過將每個圖層與 scenes/<id>.png 比對來找到其縮放與位置,計算出重疊時哪個圖層在前,進行修剪,並將所有內容註冊到 scenes/manifest.js。檢查輸出:err 低於 ~25 表示匹配良好;⚠ weak match 需要檢查(或在 layers.json 中加入 "bbox": [x, y, w, h])。然後檢查重建結果:

node "<skill dir>/scripts/layers-check.mjs"      # → 每個場景的 scenes/layers/<id>/check.png + scenes/check.png

每張檢查圖是原始影像與背景加上每個圖層在其匯入位置的並排對比,並附有每個圖層的標籤框。遺失、縮小或錯置的物件一目了然;可透過 layers.json 中的 bbox 或 skip 修正,然後重新匯入該場景。

  • 扁平形狀(例如純紅色圓盤)和部分隱藏在其他物件後方的物件皆可處理:比對器會檢查物件外部邊緣的像素是否不共享其顏色,對其前方的任何內容設定成本上限,並在近似匹配中保留最大的。
  • 小型裝飾(方形、三角形)經常被放大 3–5 倍返回;它們會被限制在畫面的 0.03% 以下(--min-area)。
  • 細線條圖(幾何圖形、弧線)是常見的 weak match:線條細且稀疏。如果某個位置錯誤,將其 skip;背景通常會保留一個模糊的副本。已知限制:背景有時會保留前景元素(例如角色腳前的岩石);一個 z 順序無法表達這種情況,且在動態中很少可見。

本地裁切(免費)。 適用於純色背景,或當沒有 Atlas 時:

node "<skill dir>/scripts/cutout.mjs" scenes/01.png --name circle --box 190,560,720,720 [--tol 34] [--mask m.png]
node "<skill dir>/scripts/cutout.mjs" scenes/01.png --plate

透過檢視影像來找到邊框;--mask 可接受來自任何背景移除工具的完整尺寸 Alpha 遮罩(例如 Atlas 上的 midjourney/v8.2/remove-background)。

背景移除 + 裁切(Higgsfield)。 Higgsfield 沒有圖層分解;其背景移除工具會逐個物件給出相同結果:

  1. 使用場景的 job_id(或其已上傳的 media id)和 media_type: "image" 執行 remove_background;jobs_wait,下載至 scenes/layers/<id>/nobg.png。它必須具有場景的尺寸:如果沒有,則執行 ffmpeg -y -i nobg.png -vf scale=<W>:<H> nobg.png。
  2. 每個物件一個裁切,每個都有自己的邊框和共享的遮罩:node "<skill dir>/scripts/cutout.mjs" scenes/01.png --name machine --box 300,1150,500,560 --mask scenes/layers/01/nobg.png。
  3. 背景移除器會將地面條帶和大型扁平形狀視為背景(巨大圓形、地面條帶):使用色鍵裁切(不使用 --mask),或生成一個隔離版本(「單純白色背景上的 [太陽]」,以場景為參考)並移除其背景。
  4. cutout.mjs scenes/01.png --plate 會重建所有已裁切物件後方的背景。為了獲得完美的背景,可生成一個:「沒有 [物件] 的相同影像」,以場景為參考。

4 · 檢查與展示

檢視每個場景的物件與背景(scenes/layers/<id>/*.png 的一排檢視):物件完整、無光暈、背景在物件原本位置乾淨。被跳過的圖層會從影片中消失(背景中沒有它們),因此只有雜點可以被跳過:如果一個可見物件被遺漏,降低 --min-area 並重新執行匯入。向使用者展示每個場景的一排影像以及總計(場景數、物件數、花費的金額或點數、每個提供者)。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

collage-animate

Animates a surreal photo-collage video entirely in code — every piece of every scene enters on twos (drop, pop, rise, swing), idles with a hand-made boil, torn-paper wipes between scenes, word-by-word captions synced to the voiceover, synthesized paper sounds — and renders a share-ready MP4 with the installed Chrome and ffmpeg. No AI video model. Use when someone has collage scenes/layers (and usually a voiceover) and asks to animate them, "animate these in code piece by piece", or as step 5 of collage-reel.

collage-reel

End-to-end producer for surreal photo-collage videos (reels, shorts, explainers). From a style reference and a topic it runs the whole pipeline — style, script, ElevenLabs voiceover, scene images split into layers, and a code-animated MP4 with word-by-word captions and paper sounds — stopping for the user's approval before each paid step. Use when someone asks for a whole collage video/reel/explainer from an idea ("make a reel about X in this style", "/collage-reel"), or wants to resume one.

collage-script

Writes the script for a short surreal photo-collage video (reel, short, explainer) — a scroll-stopping hook, one spoken line per scene, each paired with an impossible visual twist and one animated moment, facts verified — as script.md + script.json + script.txt ready for voice and scene generation. Use when someone asks for a script/guion for a collage video or explainer, or as step 2 of collage-reel.

collage-style

Reads 1–3 reference images (or video frames) and writes a reusable style bible for surreal photo-collage videos — palette with roles, textures, caption typography, motion rhythm, sound, continuity device and an image-generation prompt fragment — as style.md + style.json + style.js. Use when someone shares a style reference for a collage video, asks "take the style from this image", or as step 1 of collage-reel.

相關技能