guanghulab/video-ai-system/tools/char003_gen_r8.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

71 lines
3.8 KiB
Python
Raw 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 R8 · Seedream 4.0 · 拒绝偶像化·3D国漫真人质感·不良人方向"""
import os, sys, json, time, subprocess
from pathlib import Path
ROOT = Path('D:/WorkBuddy/guanghulab/video-ai-system')
ENV = {k.strip(): v.strip() for k, v in (line.split("=", 1) for line in open(ROOT/".env")
if line.strip() and not line.startswith("#") and "=" in line)}
AK, URL, MODEL = ENV["JIMENG_API_KEY"], ENV["JIMENG_BASE_URL"], "doubao-seedream-4-0-250828"
OUT = ROOT / "assets/candidates/D158-VA-05-001-V2/CHAR-003-SuBai/R8"
OUT.mkdir(parents=True, exist_ok=True)
P = """3D国漫写实风格人物模型如真人演员但保留三维动画质感不是真人照片不是电影明星写真不是网红美颜脸。
单人全身立绘,纯白背景。
17-18岁男性少年面部轮廓硬朗下颌线锐利颧骨略高剑眉星目眼神有锐气和自信不奶不萌不卖萌不做可爱表情。
皮肤有真实纹理质感,不是光滑磨皮,毛孔和细微瑕疵可见,暗部下沉有重量感。
黑色长发,半束半披,青色发带,发丝有真实质感,不飘逸如绸缎。
白色交领长衫,袖口挽起,腰间深青色腰带,布料有朴素褶皱和垂坠感,整洁无破损。
身形挺拔,肩膀开阔,双手叉腰,站姿沉稳有气场,中国武侠玄幻修仙气质。"""
N = """迪士尼皮克斯欧美动画3D卡通可爱娃娃脸圆润脸大眼睛卖萌奶油小生偶像剧男主网红脸男明星写真杂志封面摄影棚打光磨皮美白皮肤光滑如镜整容脸过度精致。
真人照片,摄影,写实照片,真实人物。
日系动漫二次元Q版女性化裙子女装。
畸形肢体,五官崩坏,模糊,水印,破损衣服,补丁,污渍,乞丐感,表情阴郁。诸葛风脸。"""
VARS = ["正面沉稳直视", "微微侧身眼神锐利", "下巴微扬意气风发", "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:
return json.loads(r.stdout)["data"][0].get("url")
except:
print(f" API err: {r.stdout[:200]}")
return None
def dl(url, dst):
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 R8 · Seedream 4.0 · 拒绝偶像化")
ts = time.strftime("%Y%m%d-%H%M%S")
rs = []
for i, (seed, var) in enumerate(zip(SEEDS, VARS)):
print(f"[{i+1}/4] seed={seed}", flush=True)
url = gen(f"{P} {var}", N, seed)
if not url:
rs.append({"c": i+1, "ok": False, "err": "api"})
continue
dst = OUT / f"CHAR-003-V2-R8-candidate-{i+1:02d}-1440x2560.png"
if not dl(url, str(dst)):
rs.append({"c": i+1, "ok": False, "err": "dl"})
continue
rs.append({"c": i+1, "ok": True, "raw": str(dst), "seed": seed})
print(f" -> {dst.name}")
time.sleep(3)
ok = sum(1 for r in rs 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-R8", "ts": ts, "ok": ok, "model": MODEL, "engine": "Seedream", "results": rs}, f, ensure_ascii=False, indent=2)
if __name__ == "__main__":
main()