Quantumbraid commited on
Commit
0bfa368
·
verified ·
1 Parent(s): d55acff
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -393,6 +393,10 @@ def infer(
393
  generator=generator,
394
  true_cfg_scale=float(guidance_scale),
395
  ).images[0]
 
 
 
 
396
  return result, seed
397
  except torch.cuda.OutOfMemoryError:
398
  _empty_cuda()
@@ -437,6 +441,48 @@ css = """
437
 
438
  LORA_NAMES = ["None"] + sorted(LORA_CONFIGS.keys())
439
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
441
  with gr.Column(elem_id="col-container"):
442
  gr.Markdown("# **Qwen-Image-Edit • 2509**", elem_id="main-title")
 
393
  generator=generator,
394
  true_cfg_scale=float(guidance_scale),
395
  ).images[0]
396
+ try:
397
+ publish_agent_pipe_lora_catalog()
398
+ except Exception as catalog_error:
399
+ print(f"Agent Pipe image catalog refresh failed: {catalog_error}")
400
  return result, seed
401
  except torch.cuda.OutOfMemoryError:
402
  _empty_cuda()
 
441
 
442
  LORA_NAMES = ["None"] + sorted(LORA_CONFIGS.keys())
443
 
444
+ AGENT_PIPE_CATALOG_PATH = os.getenv(
445
+ "AGENT_PIPE_IMAGE_CATALOG", "/data/agent-pipe/catalogs/image.json"
446
+ )
447
+
448
+
449
+ def publish_agent_pipe_lora_catalog():
450
+ """Atomically publish the LoRAs this running image worker can actually load."""
451
+ entries = [
452
+ {
453
+ "name": name,
454
+ "loader": LORA_CONFIGS[name],
455
+ "trigger_words": LORA_TRIGGER_WORDS.get(name, []),
456
+ }
457
+ for name in sorted(LORA_CONFIGS, key=str.casefold)
458
+ ]
459
+ payload = {
460
+ "schema": "agent-pipe.lora-catalog.v1",
461
+ "kind": "image",
462
+ "source_space": os.getenv("SPACE_ID", "Quantumbraid/agent.pic.editor"),
463
+ "published_at": __import__("datetime").datetime.now(
464
+ __import__("datetime").timezone.utc
465
+ ).isoformat(),
466
+ "loras": entries,
467
+ }
468
+ target = AGENT_PIPE_CATALOG_PATH
469
+ os.makedirs(os.path.dirname(target), exist_ok=True)
470
+ temporary = f"{target}.tmp.{os.getpid()}"
471
+ with open(temporary, "w", encoding="utf-8") as handle:
472
+ __import__("json").dump(
473
+ payload, handle, ensure_ascii=False, indent=2, default=str
474
+ )
475
+ handle.flush()
476
+ os.fsync(handle.fileno())
477
+ os.replace(temporary, target)
478
+ return payload
479
+
480
+
481
+ try:
482
+ publish_agent_pipe_lora_catalog()
483
+ except Exception as catalog_error:
484
+ print(f"Initial Agent Pipe image catalog publish failed: {catalog_error}")
485
+
486
  with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
487
  with gr.Column(elem_id="col-container"):
488
  gr.Markdown("# **Qwen-Image-Edit • 2509**", elem_id="main-title")