guanghulab/video-ai-system/tools/system_panel_gen.py
Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

81 lines
3.4 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
"""系统面板UI · Seedream直接出图 · 仙侠古卷轴"""
import os, sys, json, time, subprocess
from pathlib import Path
ROOT = Path('D:/WorkBuddy/guanghulab/video-ai-system')
env = {}
for line in open(ROOT/".env"):
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/D169-VA-05-001/UI-SystemPanel"
OUT.mkdir(parents=True, exist_ok=True)
P = """一幅中国古代修仙界宗门系统面板,半透明古朴卷轴样式悬浮于空中。
卷轴背景为淡金米色半透明薄绢,隐约可见丝绸纹理,四角有青铜色古朴纹饰。
卷轴顶部用鎏金大字书写【天道宗】,字体古朴有力显眼。
下方竖排古朴墨色文字:
宗门等级:零星
宗门人数:壹人
宗门领地:方圆百米
宗门资产:零
宗门积分:零
全部字体清晰可读、笔画工整、大小适中,不是模糊的鬼画符。
底部有任务栏:
任务:尽快升级一星宗门
奖励:仙法阁一座
条件:招收一名弟子(需磕头拜师)
卷轴散发淡淡金色灵光,悬浮在深色虚空中,四周有细微灵光粒子漂浮。
3D写实渲染不良人风格字体清晰大号可辨识。"""
N = """模糊文字,看不清的文字,鬼画符,乱码,笔画断裂,过小字体,看不清的字体,歪斜扭曲文字。
现代UI玻璃面板科技界面电脑屏幕手机界面蓝色科技面板赛博朋克。
现代字体,黑体,宋体印刷体,英文,拼音,无关文字,错误文字。
光线过亮过曝,文字被光线遮挡,文字和背景融为一体看不清。
人物,角色,人脸,手,身体。"""
SEEDS = [888, 999, 777, 666]
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[:300]}")
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
results = []
for i, seed in enumerate(SEEDS):
print(f"[{i+1}/4] seed={seed}", flush=True)
url = gen(P, N, seed)
if not url:
results.append({"c": i+1, "ok": False, "err": "api"})
continue
dst = OUT / f"system-panel-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"\n完成: {ok}/4")
json.dump({"spec":"UI-SystemPanel-V1","ok":ok,"model":MODEL,"results":results},
open(OUT/"generation-meta.json","w",encoding="utf-8"), ensure_ascii=False, indent=2)