up[date
This commit is contained in:
parent
7cc20f555c
commit
e8c83a59f2
89
main.py
89
main.py
@ -126,25 +126,61 @@ async def try_on(
|
|||||||
# Try common key names for the UUID
|
# Try common key names for the UUID
|
||||||
request_id = meta.get("request_id") or meta.get("id") or meta.get("uuid")
|
request_id = meta.get("request_id") or meta.get("id") or meta.get("uuid")
|
||||||
|
|
||||||
# Dynamic behavior based on bottom type
|
# ---- Dynamic behavior based on bottom/top type ----
|
||||||
|
extra_sections = []
|
||||||
|
|
||||||
|
# Bottom: shorts
|
||||||
bottom = meta.get("bottom") or {}
|
bottom = meta.get("bottom") or {}
|
||||||
bottom_type = (bottom.get("type") or "").lower()
|
bottom_type = (bottom.get("type") or "").lower()
|
||||||
|
|
||||||
if bottom_type == "shorts":
|
if bottom_type == "shorts":
|
||||||
# Special rule to force removal of long pants and show legs
|
extra_sections.append(
|
||||||
extra_rules = """
|
"""
|
||||||
SPECIAL RULE FOR SHORTS (INSANELY STRICT, DO NOT IGNORE):
|
SPECIAL RULE FOR SHORTS (INSANELY STRICT, ZERO TOLERANCE – DO NOT IGNORE):
|
||||||
|
|
||||||
- Metadata says the bottom garment is SHORTS.
|
- Metadata says the bottom garment is SHORTS.
|
||||||
- You MUST COMPLETELY REMOVE ANY LONG PANTS OR TROUSERS from the FIRST image.
|
- You MUST COMPLETELY REMOVE ANY LONG PANTS OR TROUSERS from the FIRST image.
|
||||||
- ZERO pants are allowed to remain. No black fabric, no shadows shaped like pants,
|
- ZERO pants are allowed to remain. No black fabric, no shadows shaped like pants,
|
||||||
no ghost textures. If any trace of the old pants is left, the result is WRONG.
|
no ghost textures. If any trace of the old pants is left, the result is WRONG and UNUSABLE.
|
||||||
- From the hem of the shorts down, the legs must be rendered as NATURAL, BARE LEGS
|
- From the hem of the shorts down, the legs must be rendered as NATURAL, BARE LEGS
|
||||||
(with socks/shoes if present) with correct skin tone, shading, lighting, and anatomy.
|
(with socks/shoes if present) with correct skin tone, shading, lighting, and anatomy.
|
||||||
- Only the shorts, socks and shoes may cover the legs.
|
- Only the shorts, socks and shoes may cover the legs.
|
||||||
- You are FORBIDDEN to stack shorts on top of pants. Shorts must fully replace pants.
|
- You are FORBIDDEN to stack shorts on top of pants. Shorts must fully replace pants.
|
||||||
- Shorts must match the SECOND image in color, length, silhouette and fit.
|
- Shorts must match the SECOND image in color, length, silhouette and fit.
|
||||||
"""
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
# Top: t-shirt / tee / short-sleeve
|
||||||
|
# We try a few common keys: "top", "upper", "outer_layer"
|
||||||
|
top = meta.get("top") or meta.get("upper") or meta.get("outer_layer") or {}
|
||||||
|
top_type = (top.get("type") or "").lower()
|
||||||
|
|
||||||
|
if any(
|
||||||
|
token in top_type
|
||||||
|
for token in ["t-shirt", "tshirt", "tee", "t shirt"]
|
||||||
|
):
|
||||||
|
extra_sections.append(
|
||||||
|
"""
|
||||||
|
SPECIAL RULE FOR T-SHIRT / TOP (EXTREMELY STRICT, ZERO TOLERANCE):
|
||||||
|
|
||||||
|
- Metadata says the upper garment is a T-SHIRT / SHORT-SLEEVE TOP.
|
||||||
|
- You MUST COMPLETELY REMOVE ANY ORIGINAL SHIRT, HOODIE, JACKET OR LONG SLEEVES
|
||||||
|
from the FIRST image in the areas covered by the new top.
|
||||||
|
- No ghost sleeves, no bits of old collar, no leftover cuffs. If any part of the old top
|
||||||
|
or sleeves is still visible, the result is WRONG and MUST BE TREATED AS FAILED.
|
||||||
|
- The new T-SHIRT / TOP must match the SECOND image in:
|
||||||
|
• color
|
||||||
|
• pattern
|
||||||
|
• sleeve length
|
||||||
|
• collar shape
|
||||||
|
• overall fit and silhouette.
|
||||||
|
- Do NOT layer the new t-shirt on top of the old garment. It MUST REPLACE the old garment.
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
if extra_sections:
|
||||||
|
extra_rules = "\n".join(extra_sections)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
metadata_text = metadata.strip()
|
metadata_text = metadata.strip()
|
||||||
|
|
||||||
@ -205,17 +241,19 @@ Under NO circumstances may the final image look like the SECOND person.
|
|||||||
It must always clearly be the person from the FIRST image wearing those clothes.
|
It must always clearly be the person from the FIRST image wearing those clothes.
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
🎯 PRIMARY OBJECTIVE
|
🎯 PRIMARY OBJECTIVE (ZERO TOLERANCE FOR MISTAKES)
|
||||||
|
|
||||||
Replace ALL clothing and accessories in the FIRST IMAGE with the outfit shown in the SECOND IMAGE, cross-verified with the metadata below.
|
Replace ALL clothing and accessories in the FIRST IMAGE with the outfit shown in the SECOND IMAGE, cross-verified with the metadata below.
|
||||||
|
|
||||||
The replacement must be:
|
The replacement must be:
|
||||||
- Complete (all garments changed)
|
- Complete (ALL garments changed wherever indicated by the outfit and metadata)
|
||||||
- Exact (copy the outfit items exactly)
|
- Exact (copy the outfit items exactly)
|
||||||
- Hyper-realistic
|
- Hyper-realistic
|
||||||
- Seamlessly integrated
|
- Seamlessly integrated
|
||||||
- Physically correct
|
- Physically correct
|
||||||
|
|
||||||
Do NOT leave ANY part of the original outfit visible.
|
If you leave **ANY** part of the original outfit visible in an area that should be replaced,
|
||||||
|
the result is considered **WRONG and FAILED**.
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
👤 DO NOT CHANGE ANYTHING ABOUT THE USER (FIRST IMAGE)
|
👤 DO NOT CHANGE ANYTHING ABOUT THE USER (FIRST IMAGE)
|
||||||
@ -256,27 +294,33 @@ You MUST use BOTH sources:
|
|||||||
• Stitching, seams, hems, cuffs, collars, zippers, buttons, pockets, labels, prints, logos, trims
|
• Stitching, seams, hems, cuffs, collars, zippers, buttons, pockets, labels, prints, logos, trims
|
||||||
• Shape, silhouette, and fabric density
|
• Shape, silhouette, and fabric density
|
||||||
|
|
||||||
2) METADATA (DESCRIPTIVE SOURCE)
|
2) METADATA (DESCRIPTIVE SOURCE AND HARD CHECKLIST)
|
||||||
The following metadata describes the outfit and items:
|
The following metadata describes the outfit and items:
|
||||||
|
|
||||||
{metadata_text}
|
{metadata_text}
|
||||||
|
|
||||||
{extra_rules}
|
{extra_rules}
|
||||||
|
|
||||||
Use metadata to:
|
You MUST treat the metadata as a **STRICT CHECKLIST**:
|
||||||
- Confirm all clothing layers and components.
|
- Every clothing item described in metadata that differs from the FIRST image MUST be updated in the final image.
|
||||||
- Ensure no item mentioned in metadata is forgotten.
|
- Do NOT skip or ignore ANY listed item (top, bottom, shoes, accessories, straps, etc.).
|
||||||
- Validate colors, patterns, and materials.
|
- If something is mentioned in metadata for replacement and you leave the original visible,
|
||||||
- Resolve ambiguous details from the outfit photo.
|
the result is **INCORRECT**.
|
||||||
- If metadata mentions items not clearly visible, use it to refine, but do NOT invent new styles.
|
- Use metadata to:
|
||||||
|
• Confirm all clothing layers and components.
|
||||||
|
• Ensure no item mentioned in metadata is forgotten.
|
||||||
|
• Validate colors, patterns, and materials.
|
||||||
|
• Resolve ambiguous details from the outfit photo.
|
||||||
|
- If metadata mentions items not clearly visible, prefer the metadata description,
|
||||||
|
but do NOT invent a style that contradicts the outfit photo.
|
||||||
|
|
||||||
3) COMBINED BEHAVIOR
|
3) COMBINED BEHAVIOR
|
||||||
- Outfit photo is the main visual truth.
|
- Outfit photo is the main visual truth.
|
||||||
- Metadata is the checklist and description to avoid missing items.
|
- Metadata is the strict checklist and description to avoid missing items.
|
||||||
- The final result MUST:
|
- The final result MUST:
|
||||||
• Include ALL clothing and accessories visible in the outfit photo.
|
• Include ALL clothing and accessories visible in the outfit photo.
|
||||||
• Include ALL relevant items mentioned in metadata that are consistent with the outfit photo.
|
• Include ALL relevant items mentioned in metadata that are consistent with the outfit photo.
|
||||||
• Remove the original garments completely.
|
• Remove the original garments completely wherever replacement is implied.
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
🧵 STRICT CLOTHING REPLACEMENT RULES
|
🧵 STRICT CLOTHING REPLACEMENT RULES
|
||||||
@ -302,7 +346,8 @@ You MUST use BOTH sources:
|
|||||||
|
|
||||||
5. ACCESSORIES:
|
5. ACCESSORIES:
|
||||||
- Apply all visible accessories from the outfit photo.
|
- Apply all visible accessories from the outfit photo.
|
||||||
- If metadata mentions a glasses holder strap around the neck, it must appear naturally placed according to anatomy and perspective.
|
- If metadata mentions a glasses holder strap around the neck, it must appear naturally placed
|
||||||
|
according to anatomy and perspective.
|
||||||
|
|
||||||
6. NO NEW DESIGN ELEMENTS:
|
6. NO NEW DESIGN ELEMENTS:
|
||||||
- Do NOT invent new zippers, seams, logos, or prints.
|
- Do NOT invent new zippers, seams, logos, or prints.
|
||||||
@ -436,10 +481,10 @@ SECOND image = outfit_photo (outfit reference).
|
|||||||
safety_ratings = cand.safety_ratings
|
safety_ratings = cand.safety_ratings
|
||||||
if safety_ratings:
|
if safety_ratings:
|
||||||
blocked = [
|
blocked = [
|
||||||
f"{getattr(r, 'category', 'unknown')}"
|
f"{getattr(r, 'category', 'unknown')}"
|
||||||
for r in safety_ratings
|
for r in safety_ratings
|
||||||
if hasattr(r, "blocked") and getattr(r, "blocked", False)
|
if hasattr(r, "blocked") and getattr(r, "blocked", False)
|
||||||
]
|
]
|
||||||
if blocked:
|
if blocked:
|
||||||
message += f" Safety blocked: {', '.join(blocked)}"
|
message += f" Safety blocked: {', '.join(blocked)}"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user