techfreakworm commited on
Commit
663f937
·
unverified ·
1 Parent(s): aa2a834

fix: actually use Base transformer when user picks Base

Browse files

Gradio 5 does not render components with visible=False to the DOM at
all — the element is entirely absent. The JS shim in _HEAD_JS called
document.querySelector('#zis-model-state textarea, #zis-model-state
input') which returned null, so hidden.value and the input event
dispatch were silently skipped. Gradio's internal state for model_state
therefore stayed "Turbo" on every Generate click regardless of which
card the user had selected.

Fix: drop visible=False and instead keep the textbox in the DOM with
elem_classes=["zis-hidden"] backed by a new CSS rule
`.zis-hidden { display: none !important; }` in theme.py. The element
is now invisible to users but present in the DOM so the JS selector
resolves, the value update propagates, and Gradio routes the correct
model name ("Base" or "Turbo") into on_t2i_generate → modes.call_t2i
→ _swap_transformer.

Files changed (2) hide show
  1. theme.py +3 -0
  2. ui.py +1 -1
theme.py CHANGED
@@ -150,6 +150,9 @@ body, .gradio-container {
150
  }
151
  .zis-info:hover::after, .zis-info.shown::after { opacity: 1; }
152
 
 
 
 
153
  /* ===== Custom model selector — 2-col phone / 4-col tablet+ (spec § 4.7) ===== */
154
 
155
  .zis-models {
 
150
  }
151
  .zis-info:hover::after, .zis-info.shown::after { opacity: 1; }
152
 
153
+ /* Hidden state carrier — in DOM for JS targeting, invisible to users */
154
+ .zis-hidden { display: none !important; }
155
+
156
  /* ===== Custom model selector — 2-col phone / 4-col tablet+ (spec § 4.7) ===== */
157
 
158
  .zis-models {
ui.py CHANGED
@@ -69,7 +69,7 @@ def build_t2i_tab() -> dict[str, gr.components.Component]:
69
  gr.HTML(labeled_label("Negative prompt (Base only)", TOOLTIPS["negative_prompt"]))
70
  negative_prompt = gr.Textbox(lines=2, show_label=False, placeholder="blurry, lowres, distorted")
71
  gr.HTML(labeled_label("Model", TOOLTIPS["model"]))
72
- model_state = gr.Textbox(value="Turbo", visible=False, elem_id="zis-model-state")
73
  gr.HTML(model_selector_html(current="Turbo"))
74
  with gr.Row():
75
  with gr.Column():
 
69
  gr.HTML(labeled_label("Negative prompt (Base only)", TOOLTIPS["negative_prompt"]))
70
  negative_prompt = gr.Textbox(lines=2, show_label=False, placeholder="blurry, lowres, distorted")
71
  gr.HTML(labeled_label("Model", TOOLTIPS["model"]))
72
+ model_state = gr.Textbox(value="Turbo", elem_id="zis-model-state", elem_classes=["zis-hidden"])
73
  gr.HTML(model_selector_html(current="Turbo"))
74
  with gr.Row():
75
  with gr.Column():