Spaces:
Running on Zero
refactor(upscale): drop LoRA support per spec
Browse filesCLAUDE.md and docs/superpowers/specs marked LoRA on the Upscale refinement
pass as out-of-scope for v1, but the UI + handler still exposed it. In
practice the upscale flow is RealESRGAN x2 -> 5 step Z-Image-Turbo img2img
at 0.33 denoising — a window so tight that style LoRAs (Toon5, DarkGhibly,
etc.) have almost no purchase on the output. Worse, users expect "Use a
LoRA" to actually do something visible.
Remove:
- LoRA checkbox / file / strength group from ui.build_upscale_tab
- lora_enabled/lora_path/lora_strength params + _coerce_lora call in
app.on_upscale_generate
- The lora_enabled.change visibility wiring in build_app
- applied_lora wrapper + lora/lora_strength meta fields in
modes.call_upscale
Test coverage:
- Update existing call_upscale tests to drop the no-longer-accepted
lora_path / lora_strength params.
- Add test_build_upscale_tab_has_no_lora_components to lock the UI
surface against regression.
The lora module + the T2I/ControlNet LoRA paths are untouched.
- app.py +0 -20
- modes.py +1 -4
- tests/test_modes.py +0 -6
- tests/test_ui.py +8 -4
- ui.py +0 -21
|
@@ -206,26 +206,14 @@ def on_upscale_generate(
|
|
| 206 |
refine_steps,
|
| 207 |
refine_denoise,
|
| 208 |
seed,
|
| 209 |
-
lora_enabled,
|
| 210 |
-
lora_path,
|
| 211 |
-
lora_strength,
|
| 212 |
progress=gr.Progress(track_tqdm=True), # noqa: B008
|
| 213 |
):
|
| 214 |
-
if not lora_enabled:
|
| 215 |
-
lora_path = None
|
| 216 |
-
try:
|
| 217 |
-
lora_p = _coerce_lora(lora_path)
|
| 218 |
-
except lora_mod.LoRAValidationError as e:
|
| 219 |
-
raise gr.Error(str(e)) from e
|
| 220 |
-
|
| 221 |
params = dict(
|
| 222 |
prompt=prompt or "masterpiece, 8k",
|
| 223 |
input_image=input_image,
|
| 224 |
refine_steps=int(refine_steps),
|
| 225 |
refine_denoise=float(refine_denoise),
|
| 226 |
seed=_maybe_random_seed(int(seed)),
|
| 227 |
-
lora_path=lora_p,
|
| 228 |
-
lora_strength=float(lora_strength),
|
| 229 |
esrgan_model_path=_esrgan_path(),
|
| 230 |
)
|
| 231 |
image, meta = backend.generate_with_retry(get_backend(), mode="upscale", params=params)
|
|
@@ -344,17 +332,9 @@ def build_app() -> gr.Blocks:
|
|
| 344 |
u["refine_steps"],
|
| 345 |
u["refine_denoise"],
|
| 346 |
u["seed"],
|
| 347 |
-
u["lora_enabled"],
|
| 348 |
-
u["lora_path"],
|
| 349 |
-
u["lora_strength"],
|
| 350 |
],
|
| 351 |
outputs=[u["output_image"], u["output_meta"]],
|
| 352 |
)
|
| 353 |
-
u["lora_enabled"].change(
|
| 354 |
-
fn=lambda v: gr.Group(visible=v),
|
| 355 |
-
inputs=[u["lora_enabled"]],
|
| 356 |
-
outputs=[u["lora_group"]],
|
| 357 |
-
)
|
| 358 |
return demo
|
| 359 |
|
| 360 |
|
|
|
|
| 206 |
refine_steps,
|
| 207 |
refine_denoise,
|
| 208 |
seed,
|
|
|
|
|
|
|
|
|
|
| 209 |
progress=gr.Progress(track_tqdm=True), # noqa: B008
|
| 210 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
params = dict(
|
| 212 |
prompt=prompt or "masterpiece, 8k",
|
| 213 |
input_image=input_image,
|
| 214 |
refine_steps=int(refine_steps),
|
| 215 |
refine_denoise=float(refine_denoise),
|
| 216 |
seed=_maybe_random_seed(int(seed)),
|
|
|
|
|
|
|
| 217 |
esrgan_model_path=_esrgan_path(),
|
| 218 |
)
|
| 219 |
image, meta = backend.generate_with_retry(get_backend(), mode="upscale", params=params)
|
|
|
|
| 332 |
u["refine_steps"],
|
| 333 |
u["refine_denoise"],
|
| 334 |
u["seed"],
|
|
|
|
|
|
|
|
|
|
| 335 |
],
|
| 336 |
outputs=[u["output_image"], u["output_meta"]],
|
| 337 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
return demo
|
| 339 |
|
| 340 |
|
|
@@ -185,8 +185,7 @@ def call_upscale(pipe: Any, params: dict[str, Any]) -> tuple[Image.Image, dict[s
|
|
| 185 |
seed=int(params.get("seed", 0)),
|
| 186 |
)
|
| 187 |
|
| 188 |
-
|
| 189 |
-
image = pipe(**kwargs)
|
| 190 |
|
| 191 |
meta = dict(
|
| 192 |
mode="upscale",
|
|
@@ -196,7 +195,5 @@ def call_upscale(pipe: Any, params: dict[str, Any]) -> tuple[Image.Image, dict[s
|
|
| 196 |
seed=kwargs["seed"],
|
| 197 |
width=upscaled.size[0],
|
| 198 |
height=upscaled.size[1],
|
| 199 |
-
lora=str(params.get("lora_path")) if params.get("lora_path") else None,
|
| 200 |
-
lora_strength=params.get("lora_strength", 0.0),
|
| 201 |
)
|
| 202 |
return image, meta
|
|
|
|
| 185 |
seed=int(params.get("seed", 0)),
|
| 186 |
)
|
| 187 |
|
| 188 |
+
image = pipe(**kwargs)
|
|
|
|
| 189 |
|
| 190 |
meta = dict(
|
| 191 |
mode="upscale",
|
|
|
|
| 195 |
seed=kwargs["seed"],
|
| 196 |
width=upscaled.size[0],
|
| 197 |
height=upscaled.size[1],
|
|
|
|
|
|
|
| 198 |
)
|
| 199 |
return image, meta
|
|
@@ -182,8 +182,6 @@ def test_upscale_runs_realesrgan_then_pipeline(fake_pipe, monkeypatch):
|
|
| 182 |
refine_steps=5,
|
| 183 |
refine_denoise=0.33,
|
| 184 |
seed=42,
|
| 185 |
-
lora_path=None,
|
| 186 |
-
lora_strength=0.0,
|
| 187 |
esrgan_model_path="/fake/path/RealESRGAN_x4plus.pth",
|
| 188 |
),
|
| 189 |
)
|
|
@@ -220,8 +218,6 @@ def test_upscale_crops_to_multiple_of_16(fake_pipe, monkeypatch):
|
|
| 220 |
refine_steps=5,
|
| 221 |
refine_denoise=0.33,
|
| 222 |
seed=0,
|
| 223 |
-
lora_path=None,
|
| 224 |
-
lora_strength=0.0,
|
| 225 |
esrgan_model_path="/fake/path/RealESRGAN_x4plus.pth",
|
| 226 |
),
|
| 227 |
)
|
|
@@ -244,8 +240,6 @@ def test_upscale_rejects_missing_image(fake_pipe):
|
|
| 244 |
refine_steps=5,
|
| 245 |
refine_denoise=0.33,
|
| 246 |
seed=0,
|
| 247 |
-
lora_path=None,
|
| 248 |
-
lora_strength=0.0,
|
| 249 |
esrgan_model_path="/fake.pth",
|
| 250 |
),
|
| 251 |
)
|
|
|
|
| 182 |
refine_steps=5,
|
| 183 |
refine_denoise=0.33,
|
| 184 |
seed=42,
|
|
|
|
|
|
|
| 185 |
esrgan_model_path="/fake/path/RealESRGAN_x4plus.pth",
|
| 186 |
),
|
| 187 |
)
|
|
|
|
| 218 |
refine_steps=5,
|
| 219 |
refine_denoise=0.33,
|
| 220 |
seed=0,
|
|
|
|
|
|
|
| 221 |
esrgan_model_path="/fake/path/RealESRGAN_x4plus.pth",
|
| 222 |
),
|
| 223 |
)
|
|
|
|
| 240 |
refine_steps=5,
|
| 241 |
refine_denoise=0.33,
|
| 242 |
seed=0,
|
|
|
|
|
|
|
| 243 |
esrgan_model_path="/fake.pth",
|
| 244 |
),
|
| 245 |
)
|
|
@@ -105,12 +105,16 @@ def test_build_upscale_tab_returns_components():
|
|
| 105 |
"refine_steps",
|
| 106 |
"refine_denoise",
|
| 107 |
"seed",
|
| 108 |
-
"lora_enabled",
|
| 109 |
-
"lora_group",
|
| 110 |
-
"lora_path",
|
| 111 |
-
"lora_strength",
|
| 112 |
"generate_btn",
|
| 113 |
"output_image",
|
| 114 |
"output_meta",
|
| 115 |
}
|
| 116 |
assert expected.issubset(components.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
"refine_steps",
|
| 106 |
"refine_denoise",
|
| 107 |
"seed",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
"generate_btn",
|
| 109 |
"output_image",
|
| 110 |
"output_meta",
|
| 111 |
}
|
| 112 |
assert expected.issubset(components.keys())
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def test_build_upscale_tab_has_no_lora_components():
|
| 116 |
+
"""LoRA is intentionally not wired on Upscale — the refinement pass uses
|
| 117 |
+
too low a denoising window for style LoRAs to meaningfully apply."""
|
| 118 |
+
components = ui.build_upscale_tab()
|
| 119 |
+
for key in ("lora_enabled", "lora_group", "lora_path", "lora_strength"):
|
| 120 |
+
assert key not in components
|
|
@@ -262,23 +262,6 @@ def build_upscale_tab() -> dict[str, gr.components.Component]:
|
|
| 262 |
info=TOOLTIPS["refine_denoise"],
|
| 263 |
)
|
| 264 |
|
| 265 |
-
lora_enabled = gr.Checkbox(label="Use a LoRA (compatible with Z-Image-Turbo)", value=False)
|
| 266 |
-
with gr.Group(visible=False) as lora_group:
|
| 267 |
-
lora_path = gr.File(
|
| 268 |
-
label="LoRA file",
|
| 269 |
-
file_types=[".safetensors"],
|
| 270 |
-
type="filepath",
|
| 271 |
-
elem_classes=["zis-lora-file"],
|
| 272 |
-
)
|
| 273 |
-
lora_strength = gr.Slider(
|
| 274 |
-
0.0,
|
| 275 |
-
1.5,
|
| 276 |
-
value=0.8,
|
| 277 |
-
step=0.05,
|
| 278 |
-
label="LoRA strength",
|
| 279 |
-
info=TOOLTIPS["lora_strength"],
|
| 280 |
-
)
|
| 281 |
-
|
| 282 |
with gr.Accordion("Advanced", open=False):
|
| 283 |
seed = gr.Number(value=0, precision=0, label="Seed", info=TOOLTIPS["seed"])
|
| 284 |
|
|
@@ -302,10 +285,6 @@ def build_upscale_tab() -> dict[str, gr.components.Component]:
|
|
| 302 |
refine_steps=refine_steps,
|
| 303 |
refine_denoise=refine_denoise,
|
| 304 |
seed=seed,
|
| 305 |
-
lora_enabled=lora_enabled,
|
| 306 |
-
lora_group=lora_group,
|
| 307 |
-
lora_path=lora_path,
|
| 308 |
-
lora_strength=lora_strength,
|
| 309 |
generate_btn=generate_btn,
|
| 310 |
output_image=output_image,
|
| 311 |
output_meta=output_meta,
|
|
|
|
| 262 |
info=TOOLTIPS["refine_denoise"],
|
| 263 |
)
|
| 264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
with gr.Accordion("Advanced", open=False):
|
| 266 |
seed = gr.Number(value=0, precision=0, label="Seed", info=TOOLTIPS["seed"])
|
| 267 |
|
|
|
|
| 285 |
refine_steps=refine_steps,
|
| 286 |
refine_denoise=refine_denoise,
|
| 287 |
seed=seed,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
generate_btn=generate_btn,
|
| 289 |
output_image=output_image,
|
| 290 |
output_meta=output_meta,
|