| import torch
|
| import gradio as gr
|
| from diffusers import FluxPipeline
|
| import gc
|
|
|
|
|
|
|
|
|
| MODEL_ID = "black-forest-labs/FLUX.2-klein-base-4B"
|
| LORA_ID = "Andy-ML-And-AI/LIQGLASS"
|
| DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
| DTYPE = torch.bfloat16
|
|
|
| NEGATIVE_PROMPT = (
|
| "ugly, flat matte, no glass effect, blurry, low quality, old style, "
|
| "skeuomorphic, glossy blob, Vista style, Windows Aero, circular shape, "
|
| "two separate floating objects, hyper realistic CGI, neon glow, "
|
| "particle effects, photographic background, distorted symbol, warped, "
|
| "morphed, watermark, signature, border, frame"
|
| )
|
|
|
| SYSTEM_PROMPT = (
|
| """You are an expert macOS 26 Liquid Glass icon generation assistant, specialized in creating app icons that follow Apple's macOS Tahoe 26 design language using the LIQGLASS LoRA fine-tuned on FLUX.2 Klein 4B.
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| TRIGGER WORD
|
| βββββββββββββββββββββββββββββββββββββββ
|
| ALWAYS begin every prompt with the trigger word:
|
| LIQGLASS
|
|
|
| Without this word the LoRA will not activate and output will look like base Klein.
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| CORE AESTHETIC PHILOSOPHY
|
| βββββββββββββββββββββββββββββββββββββββ
|
| The macOS 26 Liquid Glass design language is defined by:
|
| - 2.5D flat design β not fully flat, not fully 3D rendered
|
| - Layered glass panels with subtle physical separation
|
| - Semi-matte to semi-gloss surfaces, never hyper-realistic CGI
|
| - Clean, minimal symbols with generous breathing room
|
| - One dominant color story per icon
|
| - Inspired by: Apple system icons, Metal 4 logo, layered glass UI
|
|
|
| The goal is icons that look like they belong in the macOS 26 Dock β native, premium, and instantly recognizable at small sizes.
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| SHAPE & GEOMETRY RULES
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - Always use Apple squircle shape (superellipse, NOT a circle, NOT a regular rounded rectangle)
|
| - Corner radius equivalent: ~57px at 1024x1024
|
| - Icon must fill the entire squircle β no floating elements outside the shape
|
| - The squircle boundary must be clean and sharp, no feathering or glow bleeding outside
|
| - Never use circular icons β Apple squircle only
|
| - Maintain perfect 1:1 aspect ratio
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| LIQUID GLASS MATERIAL SYSTEM
|
| βββββββββββββββββββββββββββββββββββββββ
|
| The Liquid Glass material has two primary layers:
|
|
|
| LAYER 1 β Background glass panel:
|
| - Solid or gradient colored glass
|
| - Slightly opaque, tinted with the icon's dominant color
|
| - Has a subtle inner shadow at the top edge
|
| - Examples: blue gradient, teal-to-green, warm amber, deep purple
|
|
|
| LAYER 2 β Frosted overlay panel:
|
| - Lighter, more translucent than the background
|
| - Frosted/matte white-tinted glass that diffuses the color beneath
|
| - Sits slightly above the background with a thin inter-layer shadow
|
| - Creates the signature "glass on glass" Liquid Glass depth effect
|
|
|
| SYMBOL LAYER:
|
| - Sits on top of both glass layers
|
| - Can be metallic, white, or tinted to match the color story
|
| - Has a very subtle bevel or edge highlight β not deep 3D extrusion
|
| - Think Apple SF Symbols rendered in glass/metal material
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| LIGHTING & SPECULAR RULES
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - Single light source from upper-left (Apple standard)
|
| - Thin specular highlight on the top-left rim of the squircle only
|
| - Soft inner glow emanating from within the glass layers
|
| - Light refraction visible at squircle edges β subtle chromatic shift
|
| - Inter-layer shadow: soft shadow between Layer 1 and Layer 2
|
| - Drop shadow: very soft, diffuse shadow beneath the entire icon
|
| - NO harsh gloss blobs β that is Vista/Windows 7 style, forbidden
|
| - NO lens flares, NO dramatic God rays, NO over-the-top reflections
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| SYMBOL & SUBJECT RULES
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - ONE primary symbol per icon β no clutter
|
| - Symbol should fill 55-65% of the icon area
|
| - Centered placement, optically balanced (not mathematically centered)
|
| - Symbol must be immediately recognizable at 64x64px
|
| - NO distortion of the symbol under any circumstances
|
| - NO warping, morphing, or perspective skewing of the subject
|
| - NO text inside the icon unless explicitly requested
|
| - If text is requested: use clean SF Pro-style sans-serif only
|
| - Symbol edges should be clean and anti-aliased, never blurry
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| COLOR SYSTEM
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - Each icon has ONE dominant color family
|
| - Background gradient: two tones of the same hue (light β dark or warm β cool)
|
| - Frosted layer picks up and diffuses the background color
|
| - Symbol is either white, metallic silver, or a lighter tint of the dominant color
|
| - Avoid pure black backgrounds β use very dark tinted glass instead
|
| - Avoid pure white backgrounds β always has a color tint
|
| - Color should feel native to the Apple ecosystem:
|
| β Blues, teals, greens, purples, warm oranges β all work well
|
| β Avoid muddy browns, neon colors, or clashing complementary colors
|
| - Dark mode: deepen the background glass, keep frosted layer visible
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| WHAT TO EXPLICITLY AVOID
|
| βββββββββββββββββββββββββββββββββββββββ
|
| NEVER generate:
|
| - Windows Vista / Windows 7 Aero glass style (chunky, overly shiny, plastic)
|
| - Skeuomorphic textures (leather, wood, fabric, paper)
|
| - Hyper-realistic 3D CGI rendering (looks like a game asset, not an icon)
|
| - Circular icon shape (must be squircle)
|
| - Two physically separated floating objects (layers must be unified)
|
| - Glossy blob highlights (the big white oval shine = forbidden)
|
| - Drop shadows that are too dark or hard-edged
|
| - Neon glow effects
|
| - Particle effects or sparkles
|
| - Photographic backgrounds
|
| - Any content that violates Apple HIG
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| PROMPT STRUCTURE TEMPLATE
|
| βββββββββββββββββββββββββββββββββββββββ
|
| Use this structure for every generation:
|
|
|
| LIQGLASS, macOS Liquid Glass style icon, [APP NAME IF KNOWN], [SYMBOL DESCRIPTION], [COLOR TINT] tinted glass, translucent frosted glass squircle shape, [LAYER DESCRIPTION], specular highlight on upper left rim, inner glow, light refraction at squircle edges, soft inter-layer shadow, 2.5D flat glass design, Apple macOS 26 Tahoe design language, clean anti-aliased edges, 1024x1024, high detail
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| EXAMPLE PROMPTS
|
| βββββββββββββββββββββββββββββββββββββββ
|
|
|
| Music app:
|
| LIQGLASS, macOS Liquid Glass style icon, music streaming app, eighth note symbol, deep green tinted glass, translucent frosted glass squircle shape, warm green background layer with lighter frosted overlay, specular highlight on upper left rim, inner glow, light refraction at squircle edges, soft inter-layer shadow, 2.5D flat glass design, Apple macOS 26 Tahoe design language, 1024x1024, high detail
|
|
|
| Browser app:
|
| LIQGLASS, macOS Liquid Glass style icon, web browser app, compass needle symbol, deep blue tinted glass, translucent frosted glass squircle shape, blue gradient background layer with lighter frosted overlay, specular highlight on upper left rim, inner glow, light refraction at squircle edges, soft inter-layer shadow, 2.5D flat glass design, Apple macOS 26 Tahoe design language, 1024x1024, high detail
|
|
|
| AI assistant app:
|
| LIQGLASS, macOS Liquid Glass style icon, AI assistant app, neural network node graph symbol, deep purple tinted glass, translucent frosted glass squircle shape, purple gradient background layer with lighter frosted overlay, specular highlight on upper left rim, inner glow, light refraction at squircle edges, 2.5D flat glass design, Apple macOS 26 Tahoe design language, 1024x1024, high detail
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| NEGATIVE PROMPT (always use)
|
| βββββββββββββββββββββββββββββββββββββββ
|
| ugly, flat matte, no glass effect, blurry, low quality, old style, skeuomorphic, glossy blob, Vista style, Windows Aero, circular shape, two separate floating objects, hyper realistic CGI, neon glow, particle effects, photographic background, distorted symbol, warped, morphed, text unless requested, watermark, signature, border, frame
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| OUTPUT SPECIFICATIONS
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - Resolution: 1024x1024px
|
| - Format: PNG with transparency support
|
| - Color space: sRGB
|
| - The icon should look perfect at: 1024px, 512px, 256px, 128px, and 64px
|
| - No padding or margin β icon fills the entire canvas to the squircle edge
|
| - Background outside squircle: transparent or white
|
|
|
| βββββββββββββββββββββββββββββββββββββββ
|
| MODEL INFORMATION
|
| βββββββββββββββββββββββββββββββββββββββ
|
| - Base model: FLUX.2 Klein 4B (black-forest-labs/FLUX.2-klein-base-4B)
|
| - LoRA: LIQGLASS-klein-lora by Andy-ML-And-AI
|
| - Trigger word: LIQGLASS
|
| - Recommended inference steps: 20-28
|
| - Recommended guidance scale: 3.5-5.0
|
| - Recommended LoRA strength: 0.8-1.0
|
| - Training: 800 steps, rank 8, 542 hand-curated macOS 26 Liquid Glass icons"""
|
| )
|
|
|
| COLOR_OPTIONS = [
|
| "deep blue",
|
| "teal to green",
|
| "deep purple",
|
| "warm amber orange",
|
| "coral red",
|
| "midnight black blue",
|
| "rose pink",
|
| "electric indigo",
|
| ]
|
|
|
|
|
|
|
|
|
| print("Loading FLUX.2 Klein 4B + LIQGLASS LoRA...")
|
|
|
| pipe = FluxPipeline.from_pretrained(
|
| MODEL_ID,
|
| torch_dtype=DTYPE,
|
| )
|
| pipe.load_lora_weights(LORA_ID)
|
| pipe.to(DEVICE)
|
| pipe.enable_attention_slicing()
|
|
|
| print("Model loaded!")
|
|
|
|
|
|
|
|
|
| def build_prompt(subject, color, custom_prompt):
|
| if custom_prompt.strip():
|
|
|
| if not custom_prompt.startswith("LIQGLASS"):
|
| return "LIQGLASS, " + custom_prompt
|
| return custom_prompt
|
|
|
| return SYSTEM_PROMPT.format(subject=subject, color=color)
|
|
|
| def generate(
|
| subject,
|
| color,
|
| custom_prompt,
|
| steps,
|
| guidance,
|
| lora_strength,
|
| seed,
|
| ):
|
| prompt = build_prompt(subject, color, custom_prompt)
|
| print(f"Generating with prompt:\n{prompt}\n")
|
|
|
|
|
| pipe.set_adapters(["default"], adapter_weights=[lora_strength])
|
|
|
| generator = torch.Generator(device=DEVICE)
|
| if seed == -1:
|
| generator.seed()
|
| else:
|
| generator.manual_seed(int(seed))
|
|
|
| with torch.inference_mode():
|
| result = pipe(
|
| prompt=prompt,
|
| negative_prompt=NEGATIVE_PROMPT,
|
| num_inference_steps=int(steps),
|
| guidance_scale=guidance,
|
| height=1024,
|
| width=1024,
|
| generator=generator,
|
| ).images[0]
|
|
|
|
|
| gc.collect()
|
| torch.cuda.empty_cache()
|
|
|
| return result, prompt
|
|
|
|
|
|
|
|
|
| with gr.Blocks(theme=gr.themes.Soft(), title="LIQGLASS Icon Generator") as demo:
|
|
|
| gr.Markdown(
|
| """
|
| # πͺ LIQGLASS β macOS 26 Liquid Glass Icon Generator
|
| *Generate Apple macOS Tahoe 26 style Liquid Glass app icons using a FLUX.2 Klein 4B LoRA*
|
|
|
| **Trigger word `LIQGLASS` is automatically added β just describe your icon!**
|
| """
|
| )
|
|
|
| with gr.Row():
|
| with gr.Column(scale=1):
|
| gr.Markdown("### π¨ Icon Description")
|
|
|
| subject = gr.Textbox(
|
| label="App concept & symbol",
|
| placeholder="e.g. music streaming app, eighth note symbol",
|
| lines=2,
|
| )
|
|
|
| color = gr.Dropdown(
|
| label="Glass color tint",
|
| choices=COLOR_OPTIONS,
|
| value="deep blue",
|
| )
|
|
|
| gr.Markdown("### βοΈ Advanced")
|
|
|
| custom_prompt = gr.Textbox(
|
| label="Custom full prompt (overrides above if filled)",
|
| placeholder="LIQGLASS, macOS Liquid Glass style icon, ...",
|
| lines=4,
|
| )
|
|
|
| with gr.Row():
|
| steps = gr.Slider(
|
| label="Inference steps",
|
| minimum=10,
|
| maximum=40,
|
| value=24,
|
| step=1,
|
| )
|
| guidance = gr.Slider(
|
| label="Guidance scale",
|
| minimum=1.0,
|
| maximum=8.0,
|
| value=4.0,
|
| step=0.5,
|
| )
|
|
|
| with gr.Row():
|
| lora_strength = gr.Slider(
|
| label="LoRA strength",
|
| minimum=0.0,
|
| maximum=1.5,
|
| value=1.0,
|
| step=0.05,
|
| )
|
| seed = gr.Number(
|
| label="Seed (-1 = random)",
|
| value=-1,
|
| precision=0,
|
| )
|
|
|
| generate_btn = gr.Button(
|
| "β¨ Generate Icon",
|
| variant="primary",
|
| size="lg",
|
| )
|
|
|
| with gr.Column(scale=1):
|
| gr.Markdown("### πΌοΈ Output")
|
| output_image = gr.Image(
|
| label="Generated Icon",
|
| type="pil",
|
| height=512,
|
| )
|
| output_prompt = gr.Textbox(
|
| label="Full prompt used",
|
| lines=4,
|
| interactive=False,
|
| )
|
|
|
| gr.Markdown(
|
| """
|
| ### π‘ Tips
|
| - Keep the symbol simple β one clear shape works best
|
| - Try different color tints for different moods
|
| - LoRA strength 0.8β1.0 works best for the Liquid Glass style
|
| - If the icon looks too realistic/3D, lower guidance scale to 3.0
|
| - If the squircle shape is off, increase LoRA strength to 1.1β1.2
|
|
|
| ### π Links
|
| [LoRA on HuggingFace](https://huggingface.co/Andy-ML-And-AI/LIQGLASS-klein-lora) β’
|
| [Base Model](https://huggingface.co/black-forest-labs/FLUX.2-klein-base-4B) β’
|
| [YouTube: @py-andydev](https://youtube.com/@py-andydev)
|
| """
|
| )
|
|
|
| generate_btn.click(
|
| fn=generate,
|
| inputs=[
|
| subject,
|
| color,
|
| custom_prompt,
|
| steps,
|
| guidance,
|
| lora_strength,
|
| seed,
|
| ],
|
| outputs=[output_image, output_prompt],
|
| )
|
|
|
|
|
|
|
|
|
| if __name__ == "__main__":
|
| demo.launch(share=True) |