fix: lock subject packs and upscale assets

This commit is contained in:
2026-05-20 09:52:03 +08:00
parent 75666f151f
commit 2366662d33
3 changed files with 36 additions and 8 deletions

View File

@@ -1995,8 +1995,8 @@ def _normalize_asset_image(
bbox = mask.getbbox()
if bbox:
left, top, right, bottom = bbox
pad_x = round((right - left) * 0.06)
pad_y = round((bottom - top) * 0.06)
pad_x = round((right - left) * 0.04)
pad_y = round((bottom - top) * 0.03)
img = img.crop((
max(0, left - pad_x),
max(0, top - pad_y),
@@ -2004,8 +2004,13 @@ def _normalize_asset_image(
min(img.height, bottom + pad_y),
))
max_w = max(1, round(target_w * 0.92))
max_h = max(1, round(target_h * 0.94))
img.thumbnail((max_w, max_h), Image.Resampling.LANCZOS)
max_h = max(1, round(target_h * 0.96))
if img.width and img.height:
scale = min(max_w / img.width, max_h / img.height)
if scale > 0:
next_size = (max(1, round(img.width * scale)), max(1, round(img.height * scale)))
if next_size != img.size:
img = img.resize(next_size, Image.Resampling.LANCZOS)
else:
img.thumbnail((target_w, target_h), Image.Resampling.LANCZOS)
canvas = Image.new("RGB", (target_w, target_h), bg)
@@ -5817,6 +5822,16 @@ def _generate_subject_assets_sync(job_id: str, idx: int, element_id: str, req: G
"Do not change clothing between views; do not switch from sportswear to casualwear, dress, coat, hoodie, uniform, or underwear unless the user explicitly requests that single outfit for the whole pack. "
"If the reference outfit is useful, inherit its broad wardrobe category and color family, but redraw it as a new non-identical clean commercial outfit. "
)
pack_bible_clause = (
"PACK BIBLE - this exact bible applies to every view in this generated set. "
"Subject bible: one newly designed commercial wellness-ad subject; inherit only broad non-identifying casting traits from the source such as gender presentation, regional/ethnic appearance category, skin-tone family, age range, body-proportion category, hair-length family, posture energy, and neck/shoulder readability. "
"Do not copy the source person's biometric identity, exact face, exact hairstyle, marks, tattoos, captions, logos, or watermarks. "
"Keep the same new face design, same head shape, same hair color and hair silhouette, same skin tone, same body proportions, same height impression, and same character age across front, side, three-quarter, and back views. "
"Wardrobe bible: if the user direction names a specific outfit, use that one outfit uniformly across every view. Otherwise use one clean SKG wellness-ad activewear outfit for the entire pack: fitted short-sleeve performance top with a visible neck/collarbone area, slim athletic pants, and low-profile sneakers. "
"Lock the exact top color, bottom color, shoe color, neckline shape, sleeve/strap structure, seams, trim, fabric finish, fit, and accessories before rendering the first view, then repeat those same clothing decisions in every other view. "
"Never add or remove a jacket, blazer, hoodie, coat, dress, skirt, scarf, hat, bag, jewelry, logo, stripe pattern, or extra layer in only one view. "
"Back and side views must show the same garment wrapping around the same body, not a redesigned outfit. "
)
neck_product_clause = (
"This subject pack is for SKG neck-and-shoulder wearable massage device videos. "
"Make the neck, collarbone, shoulder line, upper back, side neck, and shoulder slope clear and product-ready. "
@@ -5855,7 +5870,7 @@ def _generate_subject_assets_sync(job_id: str, idx: int, element_id: str, req: G
"For this close-up view, intentionally crop as an upper-body asset from head/neck to chest or upper back; the neck, shoulders, collarbone or upper spine area must be large, clear, and useful for placing a neck-and-shoulder massage device. "
"Do not force full-body framing for close-ups. "
if closeup_view and req.subject_kind == "living"
else "The subject must be complete, centered, full body or full object, head-to-feet visible when applicable, not cropped by the canvas. Make the subject large and readable: it should occupy about 85-95% of the image height with only small margins. "
else "The subject must be complete, centered, full body or full object, head-to-feet visible when applicable, not cropped by the canvas. Make the subject large and readable: it should occupy about 88-94% of the image height, with the head close to the top margin and feet close to the bottom margin. No tiny character, no miniature person, no distant full-body figure, no large empty white margins. "
)
reference_strategy_clause = (
"Text-only generation mode: no source image is attached to this image request. Use only the written source/video/template briefs below as creative constraints. "
@@ -5874,6 +5889,7 @@ def _generate_subject_assets_sync(job_id: str, idx: int, element_id: str, req: G
+ identity_clause
+ identity_lock_clause
+ wardrobe_lock_clause
+ pack_bible_clause
+ neck_product_clause
+ canvas_clause
+ prompt_extra_clause