"""Render the real page builder without ComfyUI, weights, or GPU allocation.""" import ast import os import sys from pathlib import Path import gradio as gr ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT)) from jujo_loras import JUJO_ENTRIES, NONE_LORA, jujo_label, lora_selected, sample_card, pony_selection_notice from tag_completion import prompt_with_completion from jujo_browser import build_jujo_browser from browser_settings import bind_browser_settings from model_samples import build_model_samples from qwen_prompt import build_qwen_prompt from snapref_backend import build_reference_controls source = ast.parse((ROOT / "app.py").read_text(encoding="utf-8")) for node in source.body: if isinstance(node, ast.Assign) and isinstance(node.targets[0], ast.Name): if node.targets[0].id in ("RESOLUTIONS", "SAMPLERS", "SCHEDULERS", "ANIMA_PRESETS", "ILLUSTRIOUS_PRESETS"): globals()[node.targets[0].id] = ast.literal_eval(node.value) builder = next(n for n in source.body if isinstance(n, ast.FunctionDef) and n.name == "build_generation_page") STATIC_INFO = "LoRA UI validation · No model loaded" # Only isfile() is exercised; no embedding bytes are loaded in this fixture. EMBEDDING_PATHS = {"test-embedding": __file__} def generate_image_ui(*args, **kwargs): reference = {key:value for key,value in kwargs.items() if key!="reference_image"} reference["has_image"] = kwargs.get("reference_image") is not None return None, "Received LoRA slots: " + repr(args[11:23]) + " | seed " + str(3952492001372691585 if int(args[6]) < 0 else int(args[6])) + " | reference " + repr(reference) exec(compile(ast.Module(body=[builder], type_ignores=[]), "app.py", "exec")) with gr.Blocks(analytics_enabled=False) as demo: for family, label in (("anima", "Anima"), ("illustrious", "Illustrious")): with gr.Tab(label): preset_file = "Turbo-ANIMA-v2.safetensors" if family == "anima" else "dmd2_sdxl_4step_lora.safetensors" build_generation_page( family_label=label, model_choices=[family + "-checkpoint", family + "-checkpoint-2"], lora_choices=["existing.safetensors", preset_file] + list(JUJO_ENTRIES[family]), prompt_default="masterpiece, best quality,", negative_default="bad quality,", steps_default=30, cfg_default=5, sampler_default="euler", scheduler_default="normal", lora_defaults=[(True,"existing.safetensors",0.8), (False,"existing.safetensors",0.8), (False,NONE_LORA,0.8), (False,preset_file,1.0)], preset_specs=ANIMA_PRESETS if family == "anima" else ILLUSTRIOUS_PRESETS, preset_default="turbo" if family == "anima" else "wai", vae_choices=[("Checkpoint内蔵VAE", "embedded"), ("SDXL VAE", "sdxl")] if family == "illustrious" else None, vae_default="embedded" if family == "illustrious" else None, embedding_files=[("test-embedding", "", "SDXL")] if family == "illustrious" else None, credits=label + " test credits", ) if __name__ == "__main__": demo.launch(server_name="127.0.0.1", server_port=7868, css=(ROOT / "lora_ui.css").read_text(encoding="utf-8"))