infosave commited on
Commit
38ede21
路
verified 路
1 Parent(s): a8eaf74

app: ZIMAGE_ONLY switch (no behaviour change here)

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -69,6 +69,10 @@ MODELS = {
69
  "size_gb": 10.46,
70
  },
71
  }
 
 
 
 
72
  MODEL_NAMES = list(MODELS)
73
 
74
  SAMPLE_PROMPTS = [
@@ -288,7 +292,12 @@ def download_bytes(name):
288
 
289
  def load_samples():
290
  items = []
291
- for label, repo in (("Z-Image-Turbo", "infosave/Z-Image-Turbo-cmf"), ("Z-Image", "infosave/Z-Image-cmf")):
 
 
 
 
 
292
  for i, prompt in enumerate(SAMPLE_PROMPTS, 1):
293
  cap = f"{label}: {prompt} (1024虏, seed 7)"
294
  try:
@@ -537,10 +546,13 @@ def build():
537
  samples = load_samples()
538
  default_model = MODEL_NAMES[0]
539
  default_size = "256" if DEVICE == "cpu" else "512"
 
540
  header = (
541
- "# Z-Image 路 CMF\n"
542
- "Text-to-image with Tongyi-MAI's Z-Image and Z-Image-Turbo (6B DiT + Qwen3-4B text encoder), "
543
- f"run by [cortiq]({GITHUB}), a Rust engine with no Python ML stack. "
 
 
544
  "Models: [Z-Image-Turbo-cmf](https://huggingface.co/infosave/Z-Image-Turbo-cmf) 路 "
545
  "[Z-Image-cmf](https://huggingface.co/infosave/Z-Image-cmf).\n\n"
546
  f"This Space runs on **{DEVICE_LABEL}**"
@@ -555,7 +567,7 @@ def build():
555
  else "Jobs run one at a time in a queue."
556
  )
557
  )
558
- with gr.Blocks(title="Z-Image CMF") as demo:
559
  gr.Markdown(header, elem_id="title")
560
  with gr.Tabs():
561
  with gr.Tab("Generate"):
 
69
  "size_gb": 10.46,
70
  },
71
  }
72
+ # ZIMAGE_ONLY=turbo|base pins a Space to one model (the dedicated Turbo Space)
73
+ ONLY = os.environ.get("ZIMAGE_ONLY", "").strip().lower()
74
+ if ONLY in ("turbo", "base"):
75
+ MODELS = {k: v for k, v in MODELS.items() if v["key"] == ONLY}
76
  MODEL_NAMES = list(MODELS)
77
 
78
  SAMPLE_PROMPTS = [
 
292
 
293
  def load_samples():
294
  items = []
295
+ pairs = (("Z-Image-Turbo", "infosave/Z-Image-Turbo-cmf"), ("Z-Image", "infosave/Z-Image-cmf"))
296
+ if ONLY == "turbo":
297
+ pairs = pairs[:1]
298
+ elif ONLY == "base":
299
+ pairs = pairs[1:]
300
+ for label, repo in pairs:
301
  for i, prompt in enumerate(SAMPLE_PROMPTS, 1):
302
  cap = f"{label}: {prompt} (1024虏, seed 7)"
303
  try:
 
546
  samples = load_samples()
547
  default_model = MODEL_NAMES[0]
548
  default_size = "256" if DEVICE == "cpu" else "512"
549
+ title = "Z-Image-Turbo 路 CMF" if ONLY == "turbo" else ("Z-Image 路 CMF")
550
  header = (
551
+ f"# {title}\n"
552
+ + ("Text-to-image with Tongyi-MAI's Z-Image-Turbo (6B DiT + Qwen3-4B text encoder, 8 steps, no CFG), "
553
+ if ONLY == "turbo" else
554
+ "Text-to-image with Tongyi-MAI's Z-Image and Z-Image-Turbo (6B DiT + Qwen3-4B text encoder), ")
555
+ + f"run by [cortiq]({GITHUB}), a Rust engine with no Python ML stack. "
556
  "Models: [Z-Image-Turbo-cmf](https://huggingface.co/infosave/Z-Image-Turbo-cmf) 路 "
557
  "[Z-Image-cmf](https://huggingface.co/infosave/Z-Image-cmf).\n\n"
558
  f"This Space runs on **{DEVICE_LABEL}**"
 
567
  else "Jobs run one at a time in a queue."
568
  )
569
  )
570
+ with gr.Blocks(title=title) as demo:
571
  gr.Markdown(header, elem_id="title")
572
  with gr.Tabs():
573
  with gr.Tab("Generate"):