切换图片画布抠图到 BiRefNet

新增图片画布去背景 BFF 配置与路由,服务端代理 BiRefNet 并持久化结果。

将手动去背景、角色图、图标 spritesheet、UI 素材提取和角色动作帧抠图切到 BiRefNet。

新增画布右上角任务侧栏并展示去背景任务耗时与状态。

同步图片画布技术文档和项目决策记录。

(cherry picked from commit 495fcc8801)
This commit is contained in:
2026-06-29 15:02:14 +08:00
parent f40a45e01b
commit 08f188e26e
16 changed files with 1056 additions and 277 deletions
@@ -8,6 +8,7 @@ const EDITOR_SHOWCASE_RESOURCE_API = '/api/editor/showcase/resources';
const EDITOR_PROJECT_RESOURCE_API_BASE = '/api/editor/project-resources';
const EDITOR_IMAGE_GENERATION_API = '/api/editor/images/generations';
const EDITOR_IMAGE_EDIT_API = '/api/editor/images/edits';
const EDITOR_BACKGROUND_REMOVAL_API = '/api/editor/images/background-removals';
const EDITOR_ICON_SPRITESHEET_GENERATION_API =
'/api/editor/icon-spritesheets/generations';
const EDITOR_UI_DESIGN_ASSET_EXTRACTION_API =
@@ -198,6 +199,10 @@ export type EditorImageEditInput = {
canvasCompletion?: EditorCanvasGenerationCompletionInput | null;
};
export type EditorBackgroundRemovalInput = {
sourceImageSrc: string;
};
export type EditorImageGenerationResult = {
imageSrc: string;
objectKey?: string | null;
@@ -216,6 +221,17 @@ export type EditorImageGenerationResult = {
queueState?: ExternalGenerationJobStatusRecord | null;
};
export type EditorBackgroundRemovalResult = {
imageSrc: string;
objectKey?: string | null;
assetObjectId?: string | null;
width: number;
height: number;
taskId?: string | null;
elapsedMs?: number;
provider?: string;
};
export type EditorIconSpritesheetIconResult = {
name: string;
imageSrc: string;
@@ -353,7 +369,6 @@ export type EditorVideoGenerationResult = {
resource?: EditorProjectResourceSnapshot | null;
asset?: EditorAssetSnapshot | null;
project?: EditorProjectSnapshot | null;
asset?: EditorAssetSnapshot | null;
queueState?: ExternalGenerationJobStatusRecord | null;
};
@@ -517,6 +532,7 @@ type EditorAssetResponse = {
};
type EditorImageGenerationResponse = EditorImageGenerationResult;
type EditorBackgroundRemovalResponse = EditorBackgroundRemovalResult;
type EditorIconSpritesheetGenerationResponse =
EditorIconSpritesheetGenerationResult;
type EditorVideoGenerationResponse = EditorVideoGenerationResult;
@@ -866,6 +882,22 @@ export async function editEditorImage(input: EditorImageEditInput) {
);
}
export async function removeEditorImageBackground(
input: EditorBackgroundRemovalInput,
) {
return requestJson<EditorBackgroundRemovalResponse>(
EDITOR_BACKGROUND_REMOVAL_API,
jsonRequest('POST', {
sourceImageSrc: input.sourceImageSrc,
}),
'去除背景失败',
{
timeoutMs: 1_200_000,
retry: EDITOR_REQUEST_RETRY_OPTIONS,
},
);
}
export async function generateEditorCharacterAnimation(
input: EditorCharacterAnimationGenerationInput,
) {