Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Use it to explore visual ideas, refine assets, and make short films. Projects st
- **Work with AI**: Describe what you want to create, reference canvas assets, and ask the assistant to save text or generate content with your configured models.
- **Canvas and reference assets**: Upload files, connect nodes, or use `@` to add references. Organize assets in one place and review generation history.
- **Media editing**: Crop, adjust colors, and work with layers and clips. AI tools such as image extension, erasing, and background removal depend on the connected models' capabilities.
- **Image presets**: Select an image, choose Character three-view, Face three-view, Product three-view, Storyboard, or Multi-camera from **Presets**, then click **Generate** in the single-row panel. Three-view presets produce one reference sheet each; Storyboard and Multi-camera produce four separate images each, using landscape layouts and retaining a connection to the source.
- **Image presets**: Select an image, choose Character three-view, Character four-view, Face three-view, Product three-view, Storyboard, or Multi-camera from **Presets**, then click **Generate**. Character four-view adds a frontal close-up to the right of the full-body front, side, and rear views. Enable **Face emphasis** to ask the model to frame the front and side views from the chin down, keeping the full rear view and frontal close-up. The view presets each produce one reference sheet; Storyboard and Multi-camera each produce four separate images connected to the source.
- **Timeline editing**: Arrange assets, adjust start and end points, speed, and volume, then preview and render an MP4. You can also export JSON, FCPXML, and asset bundles.
- **Local projects, your choice of models**: The canvas saves automatically to your machine. Configure multiple models for a service and switch between them as needed.

Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OpenDirector 是一个在本地运行、通过浏览器使用的 AI 视频创作
- **与 AI 协作**:描述创作要求,引用画布素材,让助手保存文本并调用已配置的模型生成内容。
- **画布与参考素材**:上传文件、连接节点或用 `@` 添加参考,集中整理素材并查看生成历史。
- **媒体编辑**:裁剪、调色、处理图层和片段;扩图、消除、抠图等 AI 工具按已接入模型的能力提供。
- **图像预设**:选中图片后,从「预设」直接选择人物三视图、面部三视图、产品三视图、分镜或多机位,在单行功能栏点击「生成」。三视图各输出一张参考板;分镜和多机位各输出四张独立图片,使用适合布局的横版画幅并关联原图。
- **图像预设**:选中图片后,从「预设」选择人物三视图、人物四视图、面部三视图、产品三视图、连续分镜图或多机位,再点「生成」。人物四视图在正面、侧面和背面全身图的右侧加入正脸特写;勾选「脸部强调」后,会提示模型只拍摄正面和侧面从下巴到鞋底的部分,保留完整的背面全身和正脸特写。三视图和四视图各输出一张参考板;连续分镜图和多机位各输出四张独立图片,并关联原图。
- **时间线编排**:安排素材顺序、起止点、速度和音量,预览并合成 MP4,也可导出 JSON、FCPXML 和素材包。
- **本地项目,自选模型**:画布自动保存到本机,同一服务可配置多个模型,按用途切换。

Expand Down
21 changes: 20 additions & 1 deletion packages/core/src/opendirector/application/tool_image_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ class ImagePreset:
'全部自然站立、双臂放松,同一高度与地面基线,完整呈现头顶到鞋底,不裁头、不切脚、不遮挡、不重叠。'
'若原图仅有半身,依据可见服装合理补全下半身,补全部分在三个视角保持一致。'
'保持参考图画风,纯净浅灰背景、均匀柔光、弱透视,无剧情场景、文字、标签、水印、分割线或额外视图。',)),
'four-view': ImagePreset('人物四视图', (
'根据参考图生成一张同一人物的横版四视图设定板。'
'从左到右依次为正面全身、右侧90度全身、背面全身、正脸特写,四个视图并排分开。'
'前三格自然站立,头顶到鞋底完整,同一比例与地面基线;最右格只展示正面头肩,清楚呈现正脸。'
'各视图保持同一人物、发型、服装和配饰。若参考图只展示半身,合理补全下半身并保持一致。'
'保持参考图画风、浅灰背景、均匀柔光,无文字、分割线、水印或额外视图。',), (3456, 1152)),
'face-three-view': ImagePreset('面部三视图', (
'以参考图人物的面部为唯一身份依据,生成同一人物的面部三视图参考板。'
'3:1超宽横版画面均分为三个等宽区域,从左至右严格排列:正面、左侧90度、右侧90度。'
Expand Down Expand Up @@ -210,10 +216,23 @@ class ImagePreset:
'把机位升高到主体上方,高角度俯拍')),
}

FOUR_VIEW_FACE_EMPHASIS = (
'根据参考图生成同一人物的横版四格设定板,四张独立取景的照片从左到右并排。'
'第一格为正面、第二格为右侧90度。两格都降低取景范围,画框上缘正好切在下巴下沿,'
'脖子从顶边进入画面,从颈部一直拍到鞋底;下巴以上完全在画框外。'
'前两格顶边紧贴颈部,不在颈部上方留空;保持平直透视,不仰拍,不用面罩。'
'第三格拍完整的背面全身,从头顶到鞋底。第四格拍清晰的正脸头肩特写,保留参考人物的完整五官。'
'保持同一人物、体型、发型、服装、配饰和参考图画风。若参考图只展示半身,合理补全下半身并保持一致。'
'浅灰背景、均匀柔光,无文字、分割线、水印或额外视图。'
)

async def image_presets(ctx: ToolContext):
image = _source_image(ctx)
preset = PRESETS[ctx.choice('preset', PRESETS)]
key = ctx.choice('preset', PRESETS)
preset = PRESETS[key]
title, prompts = preset.title, preset.prompts
if key == 'four-view' and ctx.parameters.get('faceEmphasis') is True:
prompts = (FOUR_VIEW_FACE_EMPHASIS,)
outputs = []
for index, instruction in enumerate(prompts, 1):
await ctx.progress(f'正在生成{title}({index}/{len(prompts)})')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def _select(key, label, options, default=None, required=True):
ToolSpec('panorama', ('image',), _needs('image.edit'), panorama,
(_select('resolution', '清晰度', [('2K', '2K'), ('4K', '4K')], '2K'),)),
ToolSpec('image-presets', ('image',), _needs('image.edit'), image_presets,
(_select('preset', '预设', [(key, value.title) for key, value in PRESETS.items()], 'three-view'),)),
(_select('preset', '预设', [(key, value.title) for key, value in PRESETS.items()], 'three-view'),
{'key': 'faceEmphasis', 'label': '脸部强调', 'type': 'boolean', 'required': False})),
ToolSpec('multi-size', ('image',), _needs('image.edit'), multi_size),
ToolSpec('product-replacement', ('image',), _needs('image.edit'), product_replacement),
ToolSpec('dynamic-poster', ('image',), _needs('video.first_frame'), dynamic_poster),
Expand Down
15 changes: 15 additions & 0 deletions src/canvas/NodeTaskPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export function NodeTaskPanel({
? t("tools.nodeTask.presetNote")
: (toolReasonText(capability?.reason, t) ?? t("tools.nodeTask.notConnected")));
const models = capability?.models?.["image.edit"] ?? [];
const faceEmphasis = parameters.preset === "four-view"
? capability?.fields?.find((field) => field.key === "faceEmphasis")
: undefined;
return (
<section
className="cw-node-task-panel cw-preset-task-panel"
Expand Down Expand Up @@ -149,6 +152,18 @@ export function NodeTaskPanel({
))}
</select>
)}
{faceEmphasis && (
<label className="cw-preset-task-checkbox">
<input
type="checkbox"
checked={parameters.faceEmphasis === true}
onChange={(event) =>
change(faceEmphasis.key, event.target.checked)
}
/>
{translateToolText(locale, faceEmphasis.label)}
</label>
)}
<span className="cw-preset-task-note" role="status">
{note}
</span>
Expand Down
18 changes: 15 additions & 3 deletions src/canvas/node-task-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,26 @@
font-size: 11px;
border-radius: 7px;
}
.cw-preset-task-checkbox {
display: inline-flex;
flex-shrink: 0;
align-items: center;
gap: 4px;
white-space: nowrap;
font-size: 11px;
cursor: pointer;
}
.cw-preset-task-checkbox input {
margin: 0;
accent-color: #af93df;
}
.cw-preset-task-note {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--cw-control-muted, #9299a9);
font-size: 11px;
line-height: 15px;
white-space: normal;
}
.cw-preset-task-row > .cw-node-task-primary {
flex-shrink: 0;
Expand Down
2 changes: 2 additions & 0 deletions src/canvas/toolCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ export function createCanvasToolTask(
selection?: ToolSelection,
): CanvasToolTask {
let parameters = { ...values };
if (tool === "image-presets" && values.preset !== "four-view")
delete parameters.faceEmphasis;
if (tool === "multi-size") {
const preset = multiSizePresets.find(
(size) => size.ratio === values.aspectRatio,
Expand Down
2 changes: 2 additions & 0 deletions src/canvas/toolText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const EN: Record<string, string> = {
"背景声(近似)": "Background (approximate)",
"三视图": "Three-view",
"人物三视图": "Character three-view",
"人物四视图": "Character four-view",
"脸部强调": "Face emphasis",
"面部三视图": "Face three-view",
"产品三视图": "Product three-view",
"连续分镜图": "Storyboard sequence",
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/workspace/WorkspaceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
...selectionPresentation.placement?.composer,
width:
activeAction.tool === "image-presets"
? Math.min(440, selectionPresentation.composerWidth)
? Math.min(470, selectionPresentation.composerWidth)
: selectionPresentation.composerWidth,
maxHeight: selectionPresentation.composerMaxHeight,
transform: selectionPresentation.composerTransform,
Expand Down
25 changes: 24 additions & 1 deletion tests/test_tool_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def test_catalog_reports_availability_by_capability(project):
assert {'image.edit', 'video.first_frame', 'audio.speech', 'text.chat'} <= set(configured['capabilities'])
assert any(field['key'] == 'preset' and field['options'] for field in tools['image-presets']['fields'])
preset_field = next(field for field in tools['image-presets']['fields'] if field['key'] == 'preset')
assert [option['label'] for option in preset_field['options']] == ['人物三视图', '面部三视图', '产品三视图', '连续分镜图', '多机位']
assert [option['label'] for option in preset_field['options']] == ['人物三视图', '人物四视图', '面部三视图', '产品三视图', '连续分镜图', '多机位']
emphasis = next(field for field in tools['image-presets']['fields'] if field['key'] == 'faceEmphasis')
assert emphasis['type'] == 'boolean' and emphasis['required'] is False


def test_outpaint_keeps_original_pixels_and_returns_requested_size(project):
Expand Down Expand Up @@ -281,6 +283,7 @@ def test_presets_return_one_output_per_shot_and_local_hd_needs_no_model(project)

@pytest.mark.parametrize('preset,count,size', [
('three-view', 1, (2048, 1152)),
('four-view', 1, (3456, 1152)),
('face-three-view', 1, (3456, 1152)),
('product-three-view', 1, (2048, 1152)),
('storyboard', 4, (2048, 1152)),
Expand Down Expand Up @@ -311,6 +314,26 @@ def test_image_presets_reframe_portrait_reference_and_register_each_result(proje
assert '朝向相反、左右镜像对称'.encode() in calls[0]
elif preset == 'product-three-view':
assert '近正交投影'.encode() in calls[0]
elif preset == 'four-view':
assert '正面全身、右侧90度全身、背面全身、正脸特写'.encode() in calls[0]
assert '下巴以上完全在画框外'.encode() not in calls[0]


@pytest.mark.parametrize('preset,crops_front_and_side', [('four-view', True), ('three-view', False)])
def test_face_emphasis_only_affects_the_four_view_preset(project, preset, crops_front_and_side):
store, project_id, session = project
configs = configure(store, ZIMAGE)
source = upload(store, project_id, session, 'portrait.png', png((64, 96)))
calls = []
task = run(store, configs, httpx.MockTransport(images_server(calls)), project_id, session,
{'tool': 'image-presets', 'sourceAssetIds': [source],
'parameters': {'preset': preset, 'faceEmphasis': True}})
assert task['status'] == 'succeeded', task.get('error')
assert len(task['outputs']) == len(calls) == 1
assert ('下巴以上完全在画框外'.encode() in calls[0]) == crops_front_and_side
if crops_front_and_side:
assert '第三格拍完整的背面全身'.encode() in calls[0]
assert '第四格拍清晰的正脸头肩特写'.encode() in calls[0]


def test_submission_rejects_tools_without_a_capable_model(project):
Expand Down
17 changes: 17 additions & 0 deletions tests/toolCatalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ test("dynamic options and unknown task protocols cannot be guessed into a valid
);
});

test("face emphasis only accompanies the four-view preset", () => {
assert.deepEqual(
createCanvasToolTask("image-presets", [source.nodeId], {
preset: "four-view",
faceEmphasis: true,
}).parameters,
{ preset: "four-view", faceEmphasis: true },
);
assert.deepEqual(
createCanvasToolTask("image-presets", [source.nodeId], {
preset: "three-view",
faceEmphasis: true,
}).parameters,
{ preset: "three-view" },
);
});

test("observed marketing presets derive exact pixels while custom dimensions remain explicit", () => {
const confirmed = { available: true, parametersConfirmed: true };
for (const [aspectRatio, outputWidth, outputHeight] of [
Expand Down
Loading