File size: 18,365 Bytes
4190256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
import torch
import gradio as gr
from diffusers import FluxPipeline
import gc

# ═══════════════════════════════════════
# CONFIG
# ═══════════════════════════════════════
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",
]

# ═══════════════════════════════════════
# LOAD MODEL
# ═══════════════════════════════════════
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!")

# ═══════════════════════════════════════
# INFERENCE
# ═══════════════════════════════════════
def build_prompt(subject, color, custom_prompt):
    if custom_prompt.strip():
        # User wrote their own full prompt β€” just ensure trigger word
        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")

    # Set LoRA strength
    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]

    # Free memory
    gc.collect()
    torch.cuda.empty_cache()

    return result, prompt

# ═══════════════════════════════════════
# GRADIO UI
# ═══════════════════════════════════════
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],
    )

# ═══════════════════════════════════════
# LAUNCH
# ═══════════════════════════════════════
if __name__ == "__main__":
    demo.launch(share=True)