feat: simplify subject reconstruction layer

This commit is contained in:
2026-05-19 20:39:15 +08:00
parent aabddef486
commit 15c6f4d2fc
6 changed files with 479 additions and 227 deletions

View File

@@ -532,7 +532,7 @@ class SubjectTemplateItem(BaseModel):
source_job_id: str = ""
source_frame_idx: int = -1
source_element_id: str = ""
subject_style: Literal["transparent_human", "source_actor"] = "transparent_human"
subject_style: Literal["transparent_human", "source_actor", "cartoon_subject"] = "transparent_human"
primary_image: str = ""
images: list[SubjectTemplateImage] = Field(default_factory=list)
created_at: float = 0.0
@@ -599,7 +599,7 @@ class AssetLibraryItem(BaseModel):
is_official: bool = False
prompt_brief: str = ""
prompt_brief_zh: str = ""
subject_style: Literal["transparent_human", "source_actor"] = "transparent_human"
subject_style: Literal["transparent_human", "source_actor", "cartoon_subject"] = "transparent_human"
product_type: str = ""
views: list[AssetLibraryImage] = Field(default_factory=list)
images: list[AssetLibraryImage] = Field(default_factory=list)
@@ -619,7 +619,7 @@ class AssetLibraryPatchReq(BaseModel):
source_job_id: str | None = None
prompt_brief: str | None = None
prompt_brief_zh: str | None = None
subject_style: Literal["transparent_human", "source_actor"] | None = None
subject_style: Literal["transparent_human", "source_actor", "cartoon_subject"] | None = None
product_type: str | None = None
asset_role: str | None = None
aspect_ratio: str | None = None
@@ -4788,7 +4788,7 @@ class GenerateSubjectAssetsReq(BaseModel):
views: list[str] | None = None
character_id: str = ""
subject_template_id: str = ""
subject_style: Literal["transparent_human", "source_actor"] = "transparent_human"
subject_style: Literal["transparent_human", "source_actor", "cartoon_subject"] = "transparent_human"
reconstruction_mode: Literal["same", "similar"] = "same"
subject_profile: SubjectProfilePreference | None = None
prompt: str = ""
@@ -5340,7 +5340,12 @@ def generate_subject_assets(job_id: str, idx: int, element_id: str, req: Generat
target = (el.name_en or el.name_zh).strip()
bg_phrase = "pure white" if req.background == "white" else "pure black"
similar_actor = req.subject_kind == "living" and req.subject_style == "source_actor" and req.reconstruction_mode == "similar"
kind_phrase = "human actor or living character" if req.subject_kind == "living" else "object or product-like subject"
cartoon_subject = req.subject_kind == "living" and req.subject_style == "cartoon_subject"
kind_phrase = (
"original stylized cartoon or illustrative living character"
if cartoon_subject else
"human actor or living character" if req.subject_kind == "living" else "object or product-like subject"
)
transparent_character_clause = (
TRANSPARENT_HUMAN_POSITIVE_PROMPT
+ " The generated living character must be a friendly transparent humanoid with transparent or translucent outer body and clean white skeleton visible inside the same body. "
@@ -5357,6 +5362,14 @@ def generate_subject_assets(job_id: str, idx: int, element_id: str, req: Generat
if similar_actor
else ""
)
cartoon_style_clause = (
"Generate an original stylized cartoon or illustrated advertising character, not a photoreal person and not a copied likeness. "
"Use the source brief only for broad role, pose logic, mood, body proportion category, neck-and-shoulder readability, and commercial energy. "
"Change the face, exact silhouette, clothing details, marks, logos, watermarks, captions, and any identifiable source-video features. "
"Keep one consistent cartoon design system, proportions, materials, color language, and character identity across all requested views. "
if cartoon_subject
else ""
)
identity_clause = (
"Create a similar but non-identical original subject: match the performance role, silhouette category, styling direction, camera-readability, and commercial mood, while changing exact identity and unique personal features. "
if req.reconstruction_mode == "similar"
@@ -5431,6 +5444,7 @@ def generate_subject_assets(job_id: str, idx: int, element_id: str, req: Generat
+ prompt_extra_clause
+ subject_profile_clause
+ actor_style_clause
+ cartoon_style_clause
+ framing_clause
+ f"Create a high-definition standalone asset on a solid {bg_phrase} background. "
"No extra objects, no props, no additional products, no background elements, no original scene fragments, no shadows from the original scene, no text, no watermark, no UI. "
@@ -6340,7 +6354,7 @@ class SaveSubjectTemplateReq(BaseModel):
frame_idx: int
element_id: str
asset_ids: list[str] = Field(default_factory=list)
subject_style: Literal["transparent_human", "source_actor"] = "transparent_human"
subject_style: Literal["transparent_human", "source_actor", "cartoon_subject"] = "transparent_human"
@app.get("/product-library/skg", response_model=list[ProductLibraryItem])