Spaces:
Paused
Paused
jppy-logo FLUX.2-klein LoRA demo: app + README + requirements
Browse files- README.md +14 -9
- __pycache__/app.cpython-311.pyc +0 -0
- app.py +94 -0
- requirements.txt +5 -0
README.md
CHANGED
|
@@ -1,13 +1,18 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 6.
|
| 8 |
-
python_version:
|
| 9 |
app_file: app.py
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: JPPY Logo Demo
|
| 3 |
+
emoji: 🎨
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.15.1
|
| 8 |
+
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
+
models:
|
| 11 |
+
- black-forest-labs/FLUX.2-klein-base-4b
|
| 12 |
+
- aiconiccompany/jppy-logo-flux-lora
|
| 13 |
+
tags:
|
| 14 |
+
- flux
|
| 15 |
+
- lora
|
| 16 |
+
- logo-design
|
| 17 |
+
short_description: Generate clean vector-friendly logos with the jppy-logo LoRA
|
| 18 |
---
|
|
|
|
|
|
__pycache__/app.cpython-311.pyc
ADDED
|
Binary file (6.56 kB). View file
|
|
|
app.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
|
| 3 |
+
import spaces # MUST come before any CUDA-touching import (ZeroGPU rule 1)
|
| 4 |
+
import gradio as gr
|
| 5 |
+
import torch
|
| 6 |
+
from diffusers import FluxPipeline
|
| 7 |
+
|
| 8 |
+
MAX_SEED = 2**31 - 1
|
| 9 |
+
BASE_MODEL = "black-forest-labs/FLUX.2-klein-base-4b"
|
| 10 |
+
LORA_REPO = "aiconiccompany/jppy-logo-flux-lora"
|
| 11 |
+
|
| 12 |
+
# Module-scope load, eager .to("cuda") — ZeroGPU intercepts and packs these weights.
|
| 13 |
+
pipe = FluxPipeline.from_pretrained(BASE_MODEL, torch_dtype=torch.bfloat16).to("cuda")
|
| 14 |
+
pipe.load_lora_weights(LORA_REPO, adapter_name="jppy-logo")
|
| 15 |
+
|
| 16 |
+
DESCRIPTION = """
|
| 17 |
+
Demo for [aiconiccompany/jppy-logo-flux-lora](https://huggingface.co/aiconiccompany/jppy-logo-flux-lora) —
|
| 18 |
+
a logo-design LoRA for FLUX.2-klein trained on 15,815 clean vector-quality logos.
|
| 19 |
+
Just describe the mark. The `jppy-logo` trigger is appended automatically unless it's already in your prompt.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def build_prompt(prompt: str, append_trigger: bool) -> str:
|
| 24 |
+
p = prompt.strip()
|
| 25 |
+
if append_trigger and "jppy-logo" not in p.lower():
|
| 26 |
+
p = f"{p}, jppy-logo style"
|
| 27 |
+
return p
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@spaces.GPU(duration=90)
|
| 31 |
+
def generate(prompt, lora_scale, steps, guidance, width, height, seed, randomize_seed, append_trigger):
|
| 32 |
+
if not prompt or not prompt.strip():
|
| 33 |
+
raise gr.Error("Describe the logo first — e.g. 'a minimalist logo for a coffee shop'.")
|
| 34 |
+
if randomize_seed:
|
| 35 |
+
seed = random.randint(0, MAX_SEED)
|
| 36 |
+
pipe.set_adapters(["jppy-logo"], adapter_weights=[float(lora_scale)])
|
| 37 |
+
image = pipe(
|
| 38 |
+
build_prompt(prompt, append_trigger),
|
| 39 |
+
num_inference_steps=int(steps),
|
| 40 |
+
guidance_scale=float(guidance),
|
| 41 |
+
width=int(width),
|
| 42 |
+
height=int(height),
|
| 43 |
+
generator=torch.Generator("cuda").manual_seed(int(seed)),
|
| 44 |
+
).images[0]
|
| 45 |
+
return image, int(seed)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
with gr.Blocks(title="jppy-logo FLUX.2-klein LoRA demo") as demo:
|
| 49 |
+
gr.Markdown(f"# jppy-logo — logo LoRA demo\n{DESCRIPTION}")
|
| 50 |
+
with gr.Row():
|
| 51 |
+
with gr.Column():
|
| 52 |
+
prompt = gr.Textbox(
|
| 53 |
+
label="Prompt",
|
| 54 |
+
placeholder="a minimalist logo for a coffee shop",
|
| 55 |
+
lines=2,
|
| 56 |
+
)
|
| 57 |
+
append_trigger = gr.Checkbox(value=True, label="Append 'jppy-logo style' trigger")
|
| 58 |
+
run = gr.Button("Generate logo", variant="primary")
|
| 59 |
+
with gr.Accordion("Advanced", open=False):
|
| 60 |
+
lora_scale = gr.Slider(0.0, 1.5, value=1.0, step=0.05, label="LoRA weight (card recommends 0.8–1.0)")
|
| 61 |
+
steps = gr.Slider(8, 50, value=28, step=1, label="Inference steps")
|
| 62 |
+
guidance = gr.Slider(1.0, 7.0, value=3.5, step=0.1, label="Guidance scale")
|
| 63 |
+
width = gr.Slider(512, 1280, value=1024, step=128, label="Width (1024 = crisp vector-friendly)")
|
| 64 |
+
height = gr.Slider(512, 1280, value=1024, step=128, label="Height")
|
| 65 |
+
seed = gr.Number(value=0, precision=0, label="Seed")
|
| 66 |
+
randomize_seed = gr.Checkbox(value=True, label="Randomize seed")
|
| 67 |
+
with gr.Column():
|
| 68 |
+
output = gr.Image(label="Generated logo", show_download_button=True)
|
| 69 |
+
seed_out = gr.Number(label="Used seed", precision=0)
|
| 70 |
+
|
| 71 |
+
run.click(
|
| 72 |
+
generate,
|
| 73 |
+
inputs=[prompt, lora_scale, steps, guidance, width, height, seed, randomize_seed, append_trigger],
|
| 74 |
+
outputs=[output, seed_out],
|
| 75 |
+
api_name="generate",
|
| 76 |
+
)
|
| 77 |
+
prompt.submit(generate,
|
| 78 |
+
inputs=[prompt, lora_scale, steps, guidance, width, height, seed, randomize_seed, append_trigger],
|
| 79 |
+
outputs=[output, seed_out],
|
| 80 |
+
api_name="generate_submit",
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
gr.Examples(
|
| 84 |
+
examples=[
|
| 85 |
+
["a minimalist logo for a coffee shop", 1.0, 28, 3.5, 1024, 1024, 0, True, True],
|
| 86 |
+
["navy and gold shield monogram logo for a law firm, with text A&L", 1.0, 28, 3.5, 1024, 1024, 0, True, True],
|
| 87 |
+
["monochrome geometric tech logo, circular badge silhouette", 1.0, 28, 3.5, 1024, 1024, 0, True, True],
|
| 88 |
+
["red and white minimalist food logo", 0.9, 28, 3.5, 1024, 1024, 0, True, True],
|
| 89 |
+
],
|
| 90 |
+
inputs=[prompt, lora_scale, steps, guidance, width, height, seed, randomize_seed, append_trigger],
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
if __name__ == "__main__":
|
| 94 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diffusers
|
| 2 |
+
transformers
|
| 3 |
+
accelerate
|
| 4 |
+
sentencepiece
|
| 5 |
+
protobuf
|