Bridge 图像生成技能: gs2-sdxl (GS-2 SDXL) + gs1-flux (GS-1 FLUX)

This commit is contained in:
admin9webs
2026-08-27 15:39:17 +08:00
commit 36f3b2e387
4 changed files with 250 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import json, urllib.request, urllib.error, time
BASE = 'http://192.168.9.113:8188'
wf = {
"1": {"class_type": "UnetLoaderGGUF", "inputs": {"unet_name": "flux1-dev-Q5_K_S.gguf"}},
"2": {"class_type": "DualCLIPLoaderGGUF", "inputs": {"clip_name1": "t5-v1_1-xxl-encoder-Q5_K_M.gguf", "clip_name2": "clip_l.safetensors", "type": "flux"}},
"3": {"class_type": "VAELoader", "inputs": {"vae_name": "ae.safetensors"}},
"4": {"class_type": "CLIPTextEncode", "inputs": {"clip": ["2", 0], "text": "a red apple on a wooden table, product photo, studio lighting"}},
"5": {"class_type": "CLIPTextEncode", "inputs": {"clip": ["2", 0], "text": "blurry, low quality"}},
"6": {"class_type": "EmptyLatentImage", "inputs": {"width": 1024, "height": 1024, "batch_size": 1}},
"7": {"class_type": "KSampler", "inputs": {"model": ["1", 0], "positive": ["4", 0], "negative": ["5", 0], "latent_image": ["6", 0], "seed": 12345, "steps": 20, "cfg": 1.0, "sampler_name": "euler", "scheduler": "simple", "denoise": 1.0}},
"8": {"class_type": "VAEDecode", "inputs": {"samples": ["7", 0], "vae": ["3", 0]}},
"9": {"class_type": "SaveImage", "inputs": {"filename_prefix": "flux_test", "images": ["8", 0]}},
}
req = urllib.request.Request(BASE + '/prompt', data=json.dumps({"prompt": wf}).encode(), headers={'Content-Type': 'application/json'})
try:
r = json.loads(urllib.request.urlopen(req, timeout=30).read())
pid = r.get('prompt_id')
print('prompt_id:', pid, '| node_errors:', r.get('node_errors'))
if not pid: raise SystemExit(1)
for i in range(60):
time.sleep(5)
try:
h = json.loads(urllib.request.urlopen(BASE + '/history/' + pid, timeout=10).read())
except Exception: continue
if pid in h:
st = h[pid].get('status', {})
if st.get('completed') or st.get('status_str') == 'success':
for nid, o in h[pid].get('outputs', {}).items():
for img in o.get('images', []):
print('出图:', img.get('filename'), '| 节点', nid)
print('FLUX 生成成功!'); raise SystemExit(0)
elif st.get('status_str') == 'error':
print('FLUX 错误:', json.dumps(st)[:500]); raise SystemExit(1)
except urllib.error.HTTPError as e:
print('HTTP', e.code, e.read().decode()[:600])