OpenMontage 图像生成实战指南:FLUX 分辨率规范、视觉一致性与三段落提示词工程
【免费下载链接】OpenMontageWorld's first open-source, agentic video production system. 12 production pipelines, 100+ tools, 700+ agent skill and production-knowledge files. Turn your AI coding assistant into a full video production studio.项目地址: https://gitcode.com/GitHub_Trending/op/OpenMontage
本文是 OpenMontage 项目中面向 Agent 与人工创作者的图像生成使用指南,聚焦于视频流水线(Pipeline)中静态素材的生产:如何在 FLUX.2 系列模型上按 16 的倍数规划分辨率、如何在 8~12 张画面之间维持角色与风格的视觉一致性,以及如何把 playbook 的风格约束蒸馏为逐场景可变的提示词。读完本文,你将掌握一套可直接落地的"英雄图(hero)+ 参考图迭代(I2I)+ 分阶段批量生成"工作流,并能在资产阶段用image_selector工具把它接进 OpenMontage 的实际流水线。
快速参考卡
以下要点来自skills/creative/image-gen-usage.md,是全文的浓缩:
FLUX RESOLUTION: 1920x1088 (16:9) | 1088x1920 (9:16) — must be multiples of 16 MAX TOTAL: 4 megapixels (width x height) CONSISTENCY: Use hero image as input_image for subsequent frames STYLE SYSTEM: Derive from subject + audience + tone, then adapt per scene BATCH STRATEGY: Hero at max quality → iterate with klein → final pass with pro一句话概括整套方法论:先定分辨率与风格系统,再产出最高质量的英雄图作为锚点,最后用参考图 + 短提示词批量迭代出每一帧。
视频帧分辨率:16 的倍数与 4MP 上限
FLUX 系列对图像尺寸有硬性约束:所有宽高都必须是 16 的倍数,且宽 x 高总和不得超过 4 百万像素(4MP)。违反任一约束都会导致生成失败或非预期裁切。OpenMontage 建议的目标分辨率对照如下:
| 目标平台 | FLUX 分辨率 | 成本(FLUX.2 pro) |
|---|---|---|
| YouTube 16:9 | 1920x1088 | $0.03/张 |
| YouTube 4K | 3840x2160 | 需 pro/max 档 |
| TikTok/Reels 9:16 | 1088x1920 | $0.03/张 |
| 方形 1:1 | 1024x1024 | $0.03/张 |
| 缩略图 | 1280x720 | $0.03/张 |
注意1920x1088而不是1920x1080:1080 不是 16 的倍数,1088 才是。同样地,1088x1920是竖屏的对应值。OpenMontage 的 FLUX 接入层(tools/graphics/flux_image.py)在向 fal.ai 发起请求时直接透传width/height,因此尺寸约束需要调用方(Agent)自行保证——这也是把该表作为硬性参考的原因。
维护视觉一致性:让多张图属于同一支视频
最大的挑战在于让 8~12 张生成的图片看起来像同一支视频里的画面。OpenMontage 给出三层递进策略。
策略一:共享视觉系统(始终使用)
先为整个项目定义一个共享视觉系统,再逐场景适配。需要捕获项目的:
- 主导情绪与质感(dominant mood and texture);
- 调色方向(palette direction);
- 光照偏向(lighting bias);
- 渲染媒介(rendering medium);
- 角色 / 环境一致性锚点(consistency anchors)。
关键在于:playbook 中的image_prompt_prefix只是素材来源(source material),绝不能逐字粘贴进每个提示词,而要把它蒸馏成更短的、适合场景的锚点(anchor)。
策略二:英雄参考图(推荐)
- 以最高质量生成一张"英雄图"(
FLUX.2 [max],$0.07/张); - 把它作为
input_image用于后续所有帧:
Frame 1: T2I with detailed prompt → hero.png Frame 2: I2I with hero.png + "Same style, camera pans right to show..." Frame 3: I2I with hero.png + "Same style, zoomed in on..."FLUX.2 支持最多 4 张参考图(klein 档)或 8 张参考图(pro/max/flex 档),可以按编号引用:"The character from image 1 in the environment from image 2."。这一机制在 OpenMontage 的提示词构建器中被显式支持——lib/shot_prompt_builder.py的build_shot_prompt会把hero_moment标记带入批量结果,供下游决定哪一帧需要最高规格。
策略三:种子锁定(seed locking)
在提示词相近的多次生成中使用同一个seed参数,可得到相近的构图。但它对提示词改动很敏感,应作为补充手段而非主策略。OpenMontage 的 FLUX 工具实现了Determinism.SEEDED,并把seed纳入幂等键(idempotency_key_fields = ["prompt", "width", "height", "seed", "model"],见 tools/graphics/flux_image.py),说明同一 seed + 同一提示词会稳定复现。
提示词构建:三段落上下文法
不要把 playbook 的image_prompt_prefix原样复制进每个提示词——这正是所有场景看起来千篇一律的原因。应改为从三个上下文层次逐帧构建提示词。
第一层:场景专属风格方向(来自 shot_language + texture_keywords)
用场景的shot_language字段设置镜头与光照:
[SHOT SIZE from shot_language.shot_size, e.g., "medium close-up"]. [LIGHTING from shot_language.lighting_key, e.g., "golden hour warm light"]. [DEPTH from shot_language.depth_of_field, e.g., "shallow depth of field with bokeh"]. [TEXTURE from scene.texture_keywords, e.g., "film grain, warm tones"].若场景没有 shot_language,则回退到下方的兜底模板。
第二层:Playbook 一致性锚点(适配而非照抄)
提取 playbook 视觉语言的精髓。例如:
- playbook 写 "Clean, minimal illustration with soft shadows, muted color palette" → 适配为 "muted color palette, soft shadows";
- playbook 写 "Bold flat motion graphics, vibrant gradients" → 适配为 "vibrant flat style"。
锚点让场景视觉上连贯,却不至于完全相同。
第三层:场景描述
写清场景实际内容,用具体细节替换泛化词汇:
BAD:"A person using a computer in a modern office"GOOD:"Software developer in a dimly lit home office, blue monitor glow reflecting off glasses, desk cluttered with energy drinks and sticky notes"
完整提示词示例(含 shot_language)
Medium close-up, golden hour warm lighting, shallow depth of field. Muted earth tones, soft shadows. Beekeeper in white protective gear lifting a frame dripping with honey, late afternoon sun catching golden droplets, lavender field blurred in the background. Film grain, warm amber tones. 16:9 aspect ratio.兜底模板(无 shot_language 时)
[ADAPTED STYLE ANCHOR from playbook — 5-10 words, not the full prefix]. [SCENE DESCRIPTION: specific subject, action, environment]. [LIGHTING: golden hour / overcast / studio softbox / dramatic side-light]. [COMPOSITION: wide shot / medium shot / close-up / overhead / isometric]. [CAMERA: Shot on [camera] with [lens] at [aperture]] (for photorealistic only). 16:9 aspect ratio.风格专属提示词模式
| 风格 | 提示词模式 |
|---|---|
| 扁平插画 | "Flat vector illustration, bold colors, clean edges, no gradients, white background" |
| 等距(Isometric) | "Isometric 3D illustration, 30-degree angle, clean geometric shapes, soft shadows" |
| 照片写实 | "Photorealistic, shot on Canon EOS R5 with 85mm f/1.4, shallow depth of field" |
| 图表风 | "Technical diagram, labeled components, clean lines, minimal color, white background" |
| 水彩 | "Soft watercolor illustration, muted tones, visible brush strokes, paper texture" |
用 lib/shot_prompt_builder.py 编程化构建
OpenMontage 把三段落法自动化进了 lib/shot_prompt_builder.py。其核心build_shot_prompt(scene, style_context)将结构化 shot_language 翻译为面向图像/视频生成提供方优化的自然语言提示词:
from lib.shot_prompt_builder import build_shot_prompt prompt = build_shot_prompt(scene, style_context=playbook_data)从源码结构看,它基于专业的电影摄影提示词研究采用 5 层框架:
- Camera(镜头与景深):
lens_mm与depth_of_field映射为 "85mm lens, shallow depth of field with bokeh"; - Movement(景别与运镜):
shot_size与camera_movement枚举映射为自然语言(如medium_close→ "medium close-up from chest up",dolly_in→ "slow dolly in toward subject"); - Subject(主体描述 + 纹理关键词):场景
description与texture_keywords; - Lighting(布光与色温):
lighting_key(golden_hour / neon / rim_lit 等 11 种)与color_temperature(cool / neutral / warm / mixed); - Style(风格层):从
style_context.visual_language.aesthetic或mood提取,明确标注"NOT verbatim prefix"。
配套的build_batch_prompts(scenes, style_context)会遍历场景计划中的所有视觉场景,自动跳过transition类型,并返回带scene_id、prompt、hero_moment标记的结果列表——这正是"按场景计划逐帧出图"的程序化入口。
批量生成策略:英雄图 → klein 迭代 → pro 定稿
| 阶段 | 模型 | 单张成本 | 用途 |
|---|---|---|---|
| 1. 风格指南 | FLUX.2 [max] | $0.07 | 一张英雄图,最高质量 |
| 2. 分镜迭代 | FLUX.2 [klein] 9B | $0.015 | 规划期快速出变体 |
| 3. 最终帧 | FLUX.2 [pro] | $0.03 | 以英雄图为参考重出定稿 |
速率限制:最多 24 个并发请求,需据此编排流水线。
8 图 explainer 的预算示例:$0.07(英雄图)+ $0.12(8 张 klein 迭代)+ $0.24(8 张 pro 定稿)≈$0.43。
这一分阶段策略与 OpenMontage 的成本治理机制呼应:image_selector提供estimate_cost(),image_gen也按 provider 给出单张估算(如 FLUX 约 $0.03),Agent 可以在生成前做预算检查。
常见坑与规避
- 图中的文字—— AI 图像生成器处理文字不可靠,永远不要在提示词里要求文字;文字应在合成阶段(compose)作为覆盖层添加;
- 手与手指—— 模型仍易出错,避免要求精细手部姿态的提示词;
- 角色不一致—— 没有参考图时,同一角色每次都会长得不一样,务必使用英雄参考图策略;
- 过度提示(over-prompting)—— 冗长复杂的提示词结果不可预测,控制在 2~3 句话;
- 过度统一提示—— 把完全相同的风格短语塞进每个提示词会让场景千篇一律。保持视觉系统一致,但让每个场景表达自己的主体、镜头与情绪节拍。
在 OpenMontage 中落地:资产阶段的 image_selector
OpenMontage 的 tools/graphics/image_selector.py 是能力级的图像选择器,负责在生成与图库提供商之间路由。它自动从注册表发现所有capability="image_generation"的工具(如flux_image、openai_image、recraft_image、local_diffusion、pexels_image、pixabay_image等),新增提供商只需在tools/graphics/下新建工具文件,无需改动选择器本身。其输入 schema 覆盖了本文讨论的关键参数:prompt、negative_prompt、width/height、seed、generation_mode(generate/edit)、参考图(image_url(s)/image_path(s)/image_list/element_list)以及preferred_provider/allowed_providers路由控制。
在资产阶段使用image_selector时的八步检查清单:
- 先设计视觉系统:从提案或自定义 playbook 中提炼情绪、调色、纹理、动势;
- 先生成英雄图:以最高质量产出,作为其余所有图的参考;
- 视频帧使用
1920x1088(满足 FLUX 16 倍数要求); - 绝不在图中要文字:文字放到 compose 阶段叠加;
- 预算检查:生成前估算总图像成本,超预算则切换到本地 diffusers(对应
local_diffusion提供商); - 规划期用 klein 迭代,定稿用 pro;
- 提示词保持 2~3 句:场景专属镜头/光照 + 适配后的视觉锚点 + 具体主体;
- 对齐场景计划:每张图对应脚本中的具体场景。
Playbook 中的源头:asset_generation 配置
上述方法论的数据源头在 playbook schema 的asset_generation块(schemas/styles/playbook.schema.json),其中image_prompt_prefix与consistency_anchors为必填项,另有image_negative_prompt、diagram_style、scene_type、multi_image_per_scene、images_per_scene、image_variation_guidance等进阶字段。真实示例见 styles/flat-motion-graphics.yaml:
asset_generation: image_prompt_prefix: "flat vector illustration, bold colors, dark background, geometric shapes, " image_negative_prompt: "photorealistic, watercolor, vintage, muted colors, white background" diagram_style: "neon outlines on dark background, rounded rectangles, glowing connections" consistency_anchors: - "Purple (#7C3AED) as primary accent throughout" - "Dark slate (#0F172A) backgrounds in all scenes" - "Bold, geometric illustration style" - "Neon/bright accent pops for emphasis"image_prompt_prefix是"风格系统的原材料",而consistency_anchors才是应该被蒸馏进每个提示词第二层的短锚点。Playbook 生成器(lib/playbook_generator.py)在自动生成 playbook 时也会产出类似结构(image_prompt_prefix: f"{mood} {tone} style"与对应的consistency_anchors),与本文的"适配而非照抄"原则保持一致。下游的 scene-director 技能(skills/pipelines/explainer/scene-director.md)同样强调:asset_generation.image_prompt_prefix应蒸馏为短视觉锚点,不要逐字粘贴进所有提示词。
总结
OpenMontage 的图像生成方法论可以浓缩为三条主线:分辨率纪律(16 的倍数、4MP 上限、1920x1088横屏与1088x1920竖屏)、一致性工程(共享视觉系统 + 英雄参考图 + 种子锁定补充)、提示词分层(场景镜头/光照 → 适配后锚点 → 具体场景描述)。配合lib/shot_prompt_builder.py的自动化构建与image_selector的提供商路由,Agent 可以在 2~3 句话的提示词约束下,以约 $0.43 的预算产出一支 8 图 explainer 的全部视觉素材,并保证每张图都"属于同一支视频"。
【免费下载链接】OpenMontageWorld's first open-source, agentic video production system. 12 production pipelines, 100+ tools, 700+ agent skill and production-knowledge files. Turn your AI coding assistant into a full video production studio.项目地址: https://gitcode.com/GitHub_Trending/op/OpenMontage
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考