Communitygithub.com

拼贴场景生成

规划并生成超现实照片拼贴视频的场景图像——为每个场景决定使用哪个图像模型,根据风格圣经和脚本编写提示词,在价格确认后通过 Atlas Cloud(Seedream 等)或 Higgsfield(GPT Image、Seedream、Nano Banana 等)生成图像,并将每个场景分割成干净的背景和每个运动元素的一个透明图层(Seedream 图层分解、背景移除加局部抠图或色键抠图),以便后续动画制作。当需要生成拼贴场景/画面/图像,或将其分割成图层时使用,也可作为拼贴视频工作流的第 4 步。

拼贴场景生成 是什么?

Collage Scenes 是一个 AI 技能,用于为超现实照片拼贴视频自动规划、生成和分割场景图像。它根据 `style/style.json` 和 `script/script.json` 为每个剧本行创建一个场景,决定是生成图像还是使用用户提供的图像,选择适合的 AI 图像模型(如 Atlas Cloud 上的 Seedream 或 Higgsfield 上的 GPT Image),并按照风格指南编写提示词。生成并经过用户确认后,该技能将每个场景分割成一层干净的背景和多个透明图层(每个运动元素一个),通过 Atlas 的图层分解、Higgsfield 的背景移除加局部抠图,或纯本地的抠图工具来实现。最终输出独立的背景和前景元素,可供后续动画化,其 `layers.json` 和 `manifest.js` 文件记录了每个片段的位置和名称。拼贴场景需要用户批准费用估算和视觉一致性检查,因此非常适合需要精确控制成本和质量的专业拼贴视频工作流。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

拼贴场景:规划 → 生成 → 分割图层

输入: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 上分解)。

每个场景选择:

  • source: 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 上的模型:使用 action: "recommend"、type: "image"、input: "image" 和查询(如 "来自风格参考图像的复古照片拼贴,9:16")执行 models_explore;然后对候选项执行 action: "get" 以获取其宽高比、参数和 medias 角色。默认 gpt_image_2_6(Higgsfield 的通用模型,擅长遵循参考);如果 Seedream 模型被列出且用户偏好它时使用。不要使用专门的 Higgsfield 路由(Soul、Marketing Studio、influencers):它们会改变外观。
  • 分割: 默认使用 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。将返回的媒体 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)。超时时,不要盲目重新提交:首先检查作业 ID。
  4. 将每个结果下载到 scenes/<id>.png(curl -L -o scenes/01.png "<result url>";如果不是 PNG,使用 ffmpeg 转换),并在 scenes.json 中为每个场景保留 Higgsfield 作业 ID("job_id"):编辑和背景移除直接使用它。
  5. 与 Atlas 上相同的联系行和审批流程(上述步骤 4)。对于偏离的场景,仅重新生成该场景;为保持连续性,将一个良好场景的作业 ID 作为额外参考传递。

3 · 分割成图层

图层分解(Atlas)。 使用 {"image": "asset://<asset_id>"} 调用分割模型(在步骤 2 中已报价;使用上传时的资产 ID,以便输入在确认前不会过期)。返回的内容(已测试):仅文件:…_base.jpeg(干净的背景)和 …_layer_1.png … _layer_N.png,每个文件裁剪到其元素,通常以其自身比例重新渲染,没有名称、顺序或位置。轮询 atlas_get_prediction:outputs 在几秒钟内保持为空,同时文件复制到 Atlas 存储(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 使用任何背景移除器(例如 Atlas 上的 midjourney/v8.2/remove-background)生成的完整尺寸 alpha 蒙版。

背景移除 + 抠图(Higgsfield)。 Higgsfield 没有图层分解;其背景移除器逐元素给出相同结果:

  1. 使用场景的 job_id(或其上传的媒体 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.

相关技能