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

53 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-003 免费招徒广告牌 · 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-003-R2"/"PROP-003-Recruit-Board"
P="""3D动漫卡通渲染国风玄幻动态漫质感一件游戏道具无字广告牌纯白背景。
木制立式支架+米黄色空白宣纸底板,正面平视角度。
木质支架为原木色,简单不华丽,结构稳固但朴素。宣纸平整贴在木板上,纸张略带质感,干净没有任何文字和墨迹。
典型的修仙世界摊位宣传木板,适合动态漫场景道具使用。
线条清晰,卡通渲染质感,非写实摄影。"""
N="""写实照片真实木纹家具摄影产品图PBR高精度文字字母汉字书法墨迹笔划破损裂缝污渍旧报纸。"""
V=["正面平视,标准构图","略斜角度,展示支架结构","特写宣纸面板","完整支架+面板构图"]
S=[50,60,70,80]
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-003 R2 · 3D动漫卡通风格广告牌")
if not AK: sys.exit("✗ no key")
ts=time.strftime("%Y%m%d-%H%M%S");rd=J/"PROP-003-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-003-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-003-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-003-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())