feat: 添加新的模型,删除后端数据库
This commit is contained in:
+47
-50
@@ -17,47 +17,28 @@ import re
|
||||
|
||||
STYLE_SETS: dict[int, dict] = {
|
||||
1: {
|
||||
"name": "高级质感大片",
|
||||
"tone": "高端电商大片质感,柔和的方向性棚拍光,背景带细腻的浅渐变,材质纹理清晰可见,"
|
||||
"色彩层次高级克制,商业画册级品质,构图干净、留白充足",
|
||||
"name": "北欧极简",
|
||||
"tone": "北欧极简风:浅灰或米白背景,柔和漫射光,低饱和色调,画面留白充足,构图克制干净",
|
||||
"bg": "",
|
||||
},
|
||||
2: {
|
||||
"name": "清新生活场景",
|
||||
"tone": "明亮通透的生活场景摄影,自然窗光,柔和的低饱和居家环境,浅景深虚化,"
|
||||
"真实自然的氛围感,绿植与暖色织物点缀,温馨有人气",
|
||||
"name": "清新明亮",
|
||||
"tone": "清新明亮风:明亮的白色到浅蓝渐变背景,高调光线,色彩明快通透,整体轻盈干净",
|
||||
"bg": "",
|
||||
},
|
||||
3: {
|
||||
"name": "极简白底规范",
|
||||
"tone": "极简棚拍风格,纯净无缝的浅色背景,柔和均匀的无影布光,以商品为中心的严谨构图,"
|
||||
"安静的高级感,画面只保留轻微的自然接触投影",
|
||||
"name": "高级感深色",
|
||||
"tone": "高级质感风:深灰或炭黑背景,戏剧性侧光打光,突出商品材质与光泽,沉稳高级",
|
||||
"bg": "",
|
||||
},
|
||||
4: {
|
||||
"name": "炫彩促销风",
|
||||
"tone": "高能量促销风格,高饱和度色块背景搭配动感几何图形,强对比,节日大促海报氛围,"
|
||||
"构图抢眼、视觉冲击力强",
|
||||
"name": "暖调生活",
|
||||
"tone": "温暖生活风:暖米色背景,暖色灯光氛围,温馨的家居质感,亲和力强",
|
||||
"bg": "",
|
||||
},
|
||||
5: {
|
||||
"name": "暗调轻奢",
|
||||
"tone": "暗调轻奢质感,深炭灰色背景,轮廓光勾勒商品边缘,材质细节丰富,带轻微雾感,"
|
||||
"如美术馆展陈般的呈现",
|
||||
"bg": "",
|
||||
},
|
||||
6: {
|
||||
"name": "俄式风情",
|
||||
"tone": "俄式风情电商大片,浓郁温暖的色调,红与金的传统配色点缀,冬日节庆氛围,"
|
||||
"深色木质与毛毡织物背景,如暖炉烛光般的柔和光晕,厚重扎实的质感,"
|
||||
"带一丝巴洛克式的华丽细节,适合俄语区市场",
|
||||
"bg": "",
|
||||
},
|
||||
7: {
|
||||
"name": "北欧极简",
|
||||
"tone": "北欧极简风格,白色与浅灰的原木空间,大量自然漫射光,干净利落的线条,"
|
||||
"浅色木质背景点缀少量绿植,克制的中性配色,画面通透轻盈,"
|
||||
"舒适宁静的氛围",
|
||||
"name": "纯净棚拍",
|
||||
"tone": "标准电商棚拍:纯色浅背景,均匀的正面柔光,无杂物干扰,商品居中突出",
|
||||
"bg": "",
|
||||
},
|
||||
}
|
||||
@@ -121,33 +102,49 @@ DEFAULT_NEGATIVE_INTENT = (
|
||||
# "主体参考"),风格词会被字面执行到商品上。按 OpenAI 官方提示词指南的编辑模式:
|
||||
# 按序号说明输入图、PRESERVE/MAY CHANGE 分列、首尾重申不变量、文案逐字渲染。
|
||||
|
||||
GPT_EDITS_CONTRACT = (
|
||||
"INPUT IMAGES: Image 1 (and Image 2 if present) are reference photos of ONE product "
|
||||
"from different angles. Use them ONLY as the source of the product's true appearance.\n"
|
||||
"PRESERVE (frozen, never change): the product itself — silhouette, proportions, colors, "
|
||||
"print/pattern (keep stripes / logos / labels exactly), materials, texture, stitching, "
|
||||
"hardware and every design detail. The product in the output must be the same physical "
|
||||
"item as in the input images, merely photographed in a new setting.\n"
|
||||
"MAY CHANGE: background, scene, props, camera angle, lighting, composition "
|
||||
"and in-image marketing typography.\n"
|
||||
"STYLE SCOPE: all style, mood, color-palette and decoration instructions below describe "
|
||||
"the SCENE AND BACKGROUND ONLY — never apply them to the product itself. "
|
||||
"Do not restyle, recolor, re-pattern or redecorate the product. "
|
||||
"You may relight the product so it sits naturally in the new scene "
|
||||
"(matched shadows and color temperature), but never change its design, colors or pattern."
|
||||
)
|
||||
def gpt_edits_contract(ctx: dict) -> str:
|
||||
"""gpt-image edits 语义契约(放开头,指令权重最高处)。
|
||||
|
||||
除通用锁定条款外,注入商品文字锚定(标题 + 关键参数 + 描述):
|
||||
官逆通道(gpt-image-2-vip 等)会把参考图当对话附件弱化处理,
|
||||
input_fidelity 类 API 参数不生效,此时商品文字描述是保真的唯一兜底。
|
||||
"""
|
||||
anchor = f" The product is: \"{ctx['title']}\""
|
||||
if ctx.get("params_line"):
|
||||
anchor += f" (key specs: {ctx['params_line']})"
|
||||
if ctx.get("desc"):
|
||||
anchor += f". {ctx['desc']}"
|
||||
return (
|
||||
"TASK: Edit the attached product photos — re-photograph THE SAME physical product "
|
||||
"in a new setting. This is an edit of the input images, NOT a new product design.\n"
|
||||
"INPUT IMAGES: Image 1 = product front view (PRIMARY source of truth for the product's "
|
||||
f"true appearance); Image 2 (if present) = product back / detail view.{anchor}\n"
|
||||
"PRODUCT LOCK (highest priority, overrides everything else in this prompt): exactly "
|
||||
"preserve the product's shape, silhouette, proportions, colors, label text, logos, "
|
||||
"print/pattern, materials and texture. Do not redesign, restyle, recolor, re-pattern "
|
||||
"or substitute the product with a similar one. The output must show the very product "
|
||||
"from the input images AND match the product description above; if the generated "
|
||||
"product differs from either in any design detail, the image is rejected.\n"
|
||||
"MAY CHANGE: background, scene, props, camera angle, lighting, composition "
|
||||
"and in-image marketing typography only. You may relight the product so it sits "
|
||||
"naturally in the new scene (matched shadows and color temperature).\n"
|
||||
"STYLE SCOPE: all style, mood, color-palette and decoration instructions below describe "
|
||||
"the SCENE AND BACKGROUND ONLY — never apply them to the product. "
|
||||
"When any style instruction conflicts with product fidelity, product fidelity always wins."
|
||||
)
|
||||
|
||||
|
||||
GPT_EDITS_FINAL_CHECK = (
|
||||
"FINAL CHECK before output: if the product in your result differs from the input product in any "
|
||||
"design detail (shape, color, pattern, material, logo), the image is rejected. "
|
||||
"Render any listed marketing copy / headlines exactly as written (verbatim, no extra characters, "
|
||||
"no paraphrasing)."
|
||||
"FINAL CHECK before output: if the product in your result differs from the input product "
|
||||
"or the product description above in any design detail (shape, color, pattern, material, "
|
||||
"logo), the image is rejected. Render any listed marketing copy / headlines exactly as "
|
||||
"written (verbatim, no extra characters, no paraphrasing)."
|
||||
)
|
||||
|
||||
|
||||
def wrap_prompt_for_gpt_edits(prompt: str) -> str:
|
||||
def wrap_prompt_for_gpt_edits(prompt: str, ctx: dict) -> str:
|
||||
"""gpt-image edits 语义适配:契约放开头(指令权重最高处),终检放结尾。"""
|
||||
return f"{GPT_EDITS_CONTRACT}\n\n{prompt}\n\n{GPT_EDITS_FINAL_CHECK}"
|
||||
return f"{gpt_edits_contract(ctx)}\n\n{prompt}\n\n{GPT_EDITS_FINAL_CHECK}"
|
||||
|
||||
# ── 商品上下文提炼 ────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user