guanghulab/video-ai-system/tools/char003_gen_r7.py
bingshuo 6d5fcdfb21
Some checks failed
自动更新代码和重启 / update-and-restart (push) Has been cancelled
CI检查 + 自动部署 / check (push) Has been cancelled
CI检查 + 自动部署 / deploy (push) Has been cancelled
ICE-GL-ZY001 · CHAR-003苏白V2 R9批准入库 · 风格基准锁定 · D161
2026-07-02 16:18:26 +08:00

85 lines
3.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""CHAR-003 V2 R7 · Seedream 4.0 · 强力不良人/万妖图录传风格 + 17-18岁"""
import os, sys, json, time, subprocess
from pathlib import Path
ROOT = Path('D:/WorkBuddy/guanghulab/video-ai-system')
ENV_FILE = ROOT / ".env"
env = {}
for line in open(ENV_FILE):
line = line.strip()
if not line or line.startswith("#"): continue
if "=" in line:
k, v = line.split("=", 1)
env[k.strip()] = v.strip()
AK = env["JIMENG_API_KEY"]
URL = env["JIMENG_BASE_URL"]
MODEL = "doubao-seedream-4-0-250828"
OUT = ROOT / "assets/candidates/D158-VA-05-001-V2/CHAR-003-SuBai/R7"
OUT.mkdir(parents=True, exist_ok=True)
# === 中文提示词 · 不良人/万妖图录传风格 ===
P = """写实3D中国动画角色立绘不良人/万妖图录传美术风格,纯白背景,单人全身。
17-18岁少年俊秀剑眉星目明亮的眼睛自信灿烂笑容气质开朗略带痞气。
面部写实有皮肤纹理毛孔细节,不磨皮不光滑,骨相清晰下颌线锐利,中国动画男角色脸型。
黑色长发,半束半披,青色发带,发丝有真实重量感和质感。
白色交领长衫,袖口挽起露小臂,腰间深青色丝绦腰带,布料有褶皱和自然垂坠,干净整洁无破损。
身形挺拔,肩膀开阔,双手叉腰,下巴微扬,气场自信笃定,中国古代修仙少年。"""
N = """真人照片,摄影棚打光,杂志写真,明星精修,网红脸,美颜滤镜,磨皮,皮肤过于光滑,偶像剧男主,奶油小生,整容脸,西方人脸型,混血脸。
迪士尼卡通日系动漫Q版可爱娃娃脸圆脸女性化裙子女装。
畸形肢体,五官崩坏,模糊,水印,破损衣服,补丁,乞丐感,流浪汉,表情阴郁。诸葛风脸。"""
VARIANTS = [
"正面直视镜头,表情自信爽朗,少年英气",
"微微侧身站姿,目光明亮看向前方",
"略微仰视,下巴抬起,痞气但不下流",
"3/4侧脸看向左前方俊秀少年锋芒初露"
]
SEEDS = [777, 333, 555, 999]
def gen(prompt, neg, seed):
body = json.dumps({"model": MODEL, "prompt": prompt, "negative_prompt": neg, "size": "1440x2560", "n": 1, "seed": seed})
r = subprocess.run(["curl", "-s", "-m", "120", "--noproxy", "*", "-X", "POST", f"{URL}/images/generations",
"-H", f"Authorization: Bearer {AK}", "-H", "Content-Type: application/json", "-d", body],
capture_output=True, text=True, timeout=130)
try:
d = json.loads(r.stdout)
return d["data"][0].get("url")
except:
print(f" API error: {r.stdout[:200]}")
return None
def dl(url, dst):
Path(dst).parent.mkdir(parents=True, exist_ok=True)
subprocess.run(["curl", "-s", "-m", "120", "-L", "--noproxy", "*", "-o", dst, url], capture_output=True, timeout=130)
return os.path.exists(dst) and os.path.getsize(dst) > 1024
def main():
print("CHAR-003 V2 R7 · Seedream 4.0 · 强力不良人/万妖图录传")
ts = time.strftime("%Y%m%d-%H%M%S")
results = []
for i, (seed, var) in enumerate(zip(SEEDS, VARIANTS)):
full = f"{P} {var}"
print(f"[{i+1}/4] seed={seed}", flush=True)
url = gen(full, N, seed)
if not url:
results.append({"c": i+1, "ok": False, "err": "api"})
continue
dst = OUT / f"CHAR-003-V2-R7-candidate-{i+1:02d}-1440x2560.png"
if not dl(url, str(dst)):
results.append({"c": i+1, "ok": False, "err": "dl"})
continue
results.append({"c": i+1, "ok": True, "raw": str(dst), "seed": seed})
print(f" -> {dst.name}")
time.sleep(3)
ok = sum(1 for r in results if r["ok"])
print(f"完成: {ok}/4")
with open(OUT / "generation-meta.json", "w", encoding="utf-8") as f:
json.dump({"spec": "VA-05-001-V2-R7", "ts": ts, "ok": ok, "model": MODEL, "engine": "Seedream", "results": results}, f, ensure_ascii=False, indent=2)
if __name__ == "__main__":
main()