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

54 lines
3.1 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
"""PROP-002 天道宗无字牌匾 · 3D动漫卡通渲染风格 · 重做"""
import sys,os,json,time,subprocess
from pathlib import Path
sys.path.insert(0,os.path.dirname(__file__))
from secrets_loader import secret,endpoint
AK=secret("SC-001");URL=endpoint("EPT-001");M="doubao-seedream-4-0-250828"
ROOT=Path(__file__).resolve().parents[1];J=Path("/Volumes/JZAO/铸渊-ICE-GL-ZY001/OUT-输出/图片/zai-fu-fei-xiu-xian/ep01")
CD=ROOT/"assets/candidates/D157-PROP-002-R2"/"PROP-002-Tiandao-Plaque"
P="""3D动漫卡通渲染国风玄幻动态漫质感一件游戏道具牌匾纯白背景。
深棕色木质无字牌匾底板,牌匾为长方形横版,边缘有简单的古朴雕花装饰。
木质纹理清晰但为卡通渲染风格,不是写实摄影。牌匾正面朝上平视角度。
木板表面平整,略有年代磨损痕迹但整体干净,没有写字,没有文字。
比例协调,线条清晰,光影柔和,适合作为动态漫中的道具使用。"""
N="""写实照片感真实木纹家具摄影产品图3D渲染PBR材质高精度写实文字字母汉字书法破损裂缝腐烂。"""
V=["正面平视,标准构图","轻微斜角,展示厚度感","俯视角度,展示完整板面","略侧角度,展示边缘雕花"]
S=[10,20,30,40]
def g(prompt,neg,seed):
url=f"{URL}/images/generations"
r=subprocess.run(["curl","-s","-m","120","--noproxy","*","-X","POST",url,
"-H",f"Authorization: Bearer {AK}","-H","Content-Type: application/json",
"-d",json.dumps({"model":M,"prompt":prompt,"negative_prompt":neg,"size":"1440x2560","n":1,"seed":seed})],
capture_output=True,text=True,timeout=130)
try:d=json.loads(r.stdout);return d["data"][0].get("url")
except:return None
def dl(url,dst):
Path(dst).parent.mkdir(parents=True,exist_ok=True)
subprocess.run(["curl","-s","-m","60","-L","--noproxy","*","-o",dst,url],capture_output=True,timeout=65)
return os.path.exists(dst) and os.path.getsize(dst)>1024
def main():
print("PROP-002 R2 · 3D动漫卡通风格牌匾")
if not AK: sys.exit("✗ no key")
ts=time.strftime("%Y%m%d-%H%M%S");rd=J/"PROP-002-R2"/ts;rd.mkdir(parents=True,exist_ok=True)
CD.mkdir(parents=True,exist_ok=True);rs=[]
for i,(seed,var) in enumerate(zip(S,V)):
full=f"{P} {var}";print(f"[{i+1}/4] seed={seed}",flush=True)
url=g(full,N,seed)
if not url:rs.append({"c":i+1,"ok":False,"err":"api"});continue
raw=rd/f"PROP-002-R2-{i+1:02d}-1440x2560.jpg"
if not dl(url,raw):rs.append({"c":i+1,"ok":False,"err":"dl"});continue
sc=CD/f"PROP-002-R2-candidate-{i+1:02d}-1080x1920.jpg"
subprocess.run(["sips","-z","1920","1080",str(raw),"--out",str(sc)],capture_output=True)
rs.append({"c":i+1,"ok":True,"raw":str(raw),"scaled":str(sc),"seed":seed});time.sleep(2)
ok=sum(1 for r in rs if r["ok"]);print(f"完成:{ok}/4")
with open(CD/"generation-meta.json","w") as f:json.dump({"spec":"PROP-002-R2","ts":ts,"ok":ok,"results":rs},f,ensure_ascii=False,indent=2)
return 0 if ok>=4 else 1
if __name__=="__main__":sys.exit(main())