资讯动态

OpenMontage 中 FLUX 的 JSON 结构化提示词(JSON Structured Prompting)实战指南

发布时间:2026/9/10 0:24:43 来源:尧图企业网站定制
OpenMontage 中 FLUX 的 JSON 结构化提示词JSON Structured Prompting实战指南【免费下载链接】OpenMontageWorlds 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 项目内置的 JSON Structured Prompting 规则当生成 FLUX 图像需要同时编排多个主体、精确空间关系或进行可复现的生产化批量生成时如何用 JSON 结构替代自由散文式提示词。你将掌握 JSON 提示词的五段式基本骨架、单主体/多角色/产品三种典型场景的完整写法、JSON 到自然语言的扁平化转换方法、模板变量注入机制以及如何将这套结构接入 OpenMontage 的 FLUX 工具链flux_image.py与镜头提示词构建器shot_prompt_builder.py实现真正的程序化、可复用的图像生产流程。一、什么是 JSON 结构化提示词为什么需要它自由书写的自然语言提示词善于表达感觉但在以下场景中会迅速失控画面中有多个角色各自有独立外貌、位置与动作需要精确控制主体在画面中的空间位置前景、中景、背景同一批模板需要在生产流程中被反复替换变量复用需要由程序而非人自动生成提示词。规则文档 json-structured-prompting.md 给出的判断标准是只要涉及多元素、空间关系或生产自动化就用 JSON 结构化提示词。其核心价值在于把场景、主体、风格、技术参数、配色五类信息分门别类地组织起来让模型和程序都能精确读取每一个字段。这套规则在 OpenMontage 中属于flux-best-practices技能的一部分被图像生成工具直接声明为agent_skills见 flux_image.py 中的agent_skills [flux-best-practices, bfl-api]即 AI Agent 调用 FLUX 生图时会自动加载该提示词规范作为行为准则。二、基本结构五段式 JSON 骨架规则文档给出的最简骨架如下{ scene: { setting: description of environment, time: time of day/period, mood: atmospheric quality }, subjects: [ { type: person/object/animal, description: detailed description, position: location in frame, action: what theyre doing } ], style: { medium: photography/painting/illustration, technique: specific style details, reference: artist or style reference }, technical: { camera: camera and lens, lighting: lighting setup, composition: framing details }, colors: [#hex1, #hex2] }各字段的职责划分遵循关注点分离原则顶层键职责典型取值scene环境、时段、氛围cozy home office、late afternoon、focusedsubjects主体数组可多角色person、product、animalstyle媒介、技法、参考风格photography、classical realismtechnical相机、镜头、灯光、构图Sony A7III with 50mm f/1.8colors精确配色可对象级#1A1A2E、#E94560这种分区与 OpenMontage 镜头提示词构建器 shot_prompt_builder.py 的build_shot_prompt分层逻辑高度同构它同样把 prompt 拆成场景镜头语言Layer 1、风格上下文Layer 2、主体描述Layer 3等层次再拼接可见先结构化、后拼装是 OpenMontage 图像管线的一贯思路。三、三个典型场景的完整范例3.1 单主体场景生活化人物{ scene: { setting: cozy home office with bookshelves, time: late afternoon, mood: focused, peaceful }, subjects: [ { type: person, description: woman in her 30s, dark curly hair in loose bun, wearing casual cream sweater, position: seated at desk, center frame, action: typing on laptop, slight smile of concentration } ], style: { medium: photography, technique: lifestyle editorial, reference: kinfolk magazine aesthetic }, technical: { camera: Sony A7III with 50mm f/1.8, lighting: soft natural window light from left, composition: medium shot, rule of thirds } }要点description描述外观position锁定画面位置action规定动态——三者分离后任何一项的调整都不影响其他项。3.2 多角色场景给角色加 ID当多个角色同框且有交互关系时必须为每个主体分配id供构图与描述相互引用{ scene: { setting: Victorian-era drawing room with ornate wallpaper and antique furniture, time: evening, candlelit, mood: tense, mysterious }, subjects: [ { id: detective, type: person, description: tall man in his 50s, sharp features, grey at temples, wearing brown tweed suit, position: standing center-left, facing right, action: examining a letter with magnifying glass, intense focus }, { id: lady, type: person, description: elegant woman in her 40s, auburn hair in Victorian updo, emerald green evening dress, position: seated on chaise lounge, right side, action: watching the detective with concealed anxiety, hands clasped }, { id: butler, type: person, description: elderly man in formal butler attire, stoic expression, position: background, near doorway, action: standing at attention, observing } ], style: { medium: oil painting, technique: classical realism with dramatic lighting, reference: Victorian narrative painting, John Singer Sargent }, technical: { lighting: warm candlelight as key, cool moonlight through window as fill, composition: triangular arrangement of figures, detective at apex } }注意technical.composition直接引用detectivedetective at apex这正是 Best Practices 中Use IDs for References的应用。3.3 产品场景对象级配色产品拍摄往往需要严格限定每个部件的颜色此时colors采用对象 → 色值的映射{ scene: { setting: minimalist product photography studio, mood: clean, premium, aspirational }, subjects: [ { type: product, description: sleek wireless earbuds in charging case, position: center, slightly angled, details: matte finish, subtle branding } ], style: { medium: commercial photography, technique: high-end product shot, reference: Apple product photography }, technical: { camera: Phase One with 120mm macro, lighting: large softbox overhead, subtle fill from below, composition: centered, hero product shot }, colors: { product: #1A1A2E, accent: #E94560, background: #FFFFFF } }这里的对象级配色与技能中另一条规则 hex-color-prompting.md 完全兼容——后者同样强调为每个对象明确指定色值、避免颜色互相渗透二者组合使用可实现品牌级色彩还原。四、JSON 到自然语言的转换Flatten for ExecutionJSON 只是中间表示最终送入 FLUX 模型的是扁平化后的自然语言。规则文档给出了标准转换范例原始 JSON{ subjects: [ { type: person, description: elderly craftsman with weathered hands, position: seated at workbench, action: carefully carving wood } ], scene: { setting: traditional workshop, time: morning }, technical: { lighting: natural window light from right } }转换为提示词An elderly craftsman with weathered hands seated at his workbench in a traditional workshop, carefully carving wood with focused precision. Morning natural light streams through the window from the right, illuminating the wood shavings and tools scattered across the worn surface.转换原则把subjects[].description与action组合成主语动作句scene.setting与time转为环境从句technical.lighting展开为光线细节描写。这与build_shot_prompt的分层拼装思路一致——结构化信息最终被展开为一句连贯的散文式 prompt见 shot_prompt_builder.py因为 FLUX 对自然语言散文的遵循度最高详见 SKILL.md 的 Critical Rules。五、模板变量生产流水线的核心规则文档展示了用 JSON 承载模板变量的方法{ template: product_hero, variables: { product_name: {{PRODUCT_NAME}}, product_color: {{PRODUCT_COLOR}}, brand_primary: {{BRAND_HEX_1}}, brand_secondary: {{BRAND_HEX_2}}, background_style: {{BG_STYLE}} }, prompt_template: Professional product photography of {{PRODUCT_NAME}} in {{PRODUCT_COLOR}}, brand colors {{BRAND_HEX_1}} and {{BRAND_HEX_2}} accents, {{BG_STYLE}} background, commercial quality }variables声明占位符prompt_template定义模板文本。生产流程只需替换变量即可批量生成同构产品图这正是规则中Version Templates模板版本化与Reproducible, template-based prompts的落地方式。在 OpenMontage 中类似的批量提示词构建已有工程化实现build_batch_prompts遍历场景计划为每个视觉场景调用build_shot_prompt生成{scene_id, prompt}字典并自动跳过transition等非视觉场景见 shot_prompt_builder.py——把 JSON 模板变量机制接入此类批量管线即可实现场景级批量生成。六、空间关系分层与焦点规则文档用composition对象显式声明空间层次{ composition: { layout: triangular, focal_point: center-left intersection, depth_layers: [ { layer: foreground, elements: [flowers in vase], focus: soft blur }, { layer: midground, elements: [main subject], focus: sharp }, { layer: background, elements: [window, garden view], focus: soft blur } ] } }layout定义整体构图如三角构图focal_point指明视觉焦点depth_layers按前景/中景/背景分别声明元素与景深控制。这种显式分层能有效避免多主体场景中谁在前谁在后的歧义——OpenMontage 的shot_language同样支持 wide/medium_wide 等景别定义见 shot_prompt_builder.py二者可互相参考。七、在 OpenMontage 中实际调用 FLUX规则文档给出提示词规范OpenMontage 提供执行通道。最直接的入口是 flux_image.py通过环境变量FAL_KEY或FAL_AI_API_KEY提供 fal.ai 密钥flux_image.py默认模型flux-pro/v1.1可选flux/dev与flux-pro默认分辨率 1024×1024flux_image.py支持seed复现determinism Determinism.SEEDED、num_inference_steps、guidance_scale等参数提交后自动下载图片写入output_path并返回prompt、seed、model、耗时与成本估算等元数据flux_image.py。调用前将上述 JSON 结构扁平化为 prompt 字符串传入即可。此外统一入口 image_gen.py 的_generate_flux也实现了 FLUX 通道固定调用fal-ai/flux/dev见 image_gen.py可按provider: flux走多提供商统一路由。八、与其他规则的组合JSON 结构化提示词不是孤立的它与flux-best-practices技能中的多条规则协同与 Hex 配色组合colors字段可直接引用 hex-color-prompting.md 的调色板写法如primary: #6C5CE7 (electric purple)实现对象级精确配色与模型选择组合若subjects较多或需 I2I 编辑参考 model-selection-guide.md 选择 FLUX.2 [max]/[pro]支持更多参考图仅快速预览可选 [klein]与文本排版组合若画面含文字subjects[].description中需按 typography-text.md 用引号包裹精确文本与正面描述组合FLUX 不支持负向提示词JSON 中所有不要 X都必须改写为要 Y参考 negative-prompt-alternatives.md。九、最佳实践清单规则文档总结的六条核心实践Use IDs for References—— 主体交互时务必分配idSeparate Concerns—— 场景、主体、风格、技术参数保持独立分区Be Consistent—— 全文统一术语同一对象前后用词一致Include All Details—— 不要假设模型脑补把所有细节写明Flatten for Execution—— 送入模型前必须扁平化为自然语言散文Version Templates—— 对模板做版本管理保证可复现性。补充一点来自技能整体的约束FLUX 对提示词前半部分优先级更高因此扁平化时主体与动作应前置光线与氛围后置详见 core-principles.md 的 front-load 原则同时 FLUX 不支持负向提示词JSON 中只描述期望内容。十、总结JSON 结构化提示词的生产化价值JSON 结构化提示词的本质是给图像生成建立一层机器可读的中间表示多主体用数组与id建模空间用depth_layers建模配色用对象级色值建模复用用模板变量建模最终统一扁平化为自然语言执行。这一模式在 OpenMontage 中已有完整落地——flux-best-practices 提供规范flux_image.py 与 image_gen.py 提供执行通道shot_prompt_builder.py 提供批量拼装能力。将 JSON 结构接入批处理循环后即可在一条生产流水线上稳定产出风格统一、构图精确、品牌色可控的图像资产。【免费下载链接】OpenMontageWorlds 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),仅供参考

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价