arthurtmonyman commited on
Commit
14729d7
Β·
verified Β·
1 Parent(s): df368f3

lock defaults (1.05/9/3), single-button UI, β­πŸ‘Œ emoji

Browse files
Files changed (1) hide show
  1. app.py +23 -24
app.py CHANGED
@@ -7,36 +7,43 @@ from diffusers import Flux2KleinPipeline
7
 
8
  BASE = "black-forest-labs/FLUX.2-klein-4B"
9
  LORA = "noema-art/impresstation-klein"
10
- # Default edit instruction for klein (an edit model): trigger words + style + directive.
11
  PROMPT = (
12
- "stationthis, stationthis, low poly playstation screenshot style. "
13
- "Convert this image into a low-poly PlayStation-era 3D game screenshot in the stationthis style."
 
 
 
 
 
14
  )
 
 
 
15
  HF_TOKEN = os.environ.get("HF_TOKEN")
16
  MAX_SEED = 2**31 - 1
17
 
18
  dtype = torch.bfloat16
19
  pipe = Flux2KleinPipeline.from_pretrained(BASE, torch_dtype=dtype, token=HF_TOKEN)
20
  pipe.load_lora_weights(LORA, adapter_name="stationthis", token=HF_TOKEN)
 
21
  pipe.to("cuda")
22
 
23
 
24
  @spaces.GPU(duration=120)
25
- def station_this(image, prompt, strength, steps, guidance, seed, randomize, progress=gr.Progress(track_tqdm=True)):
26
  if image is None:
27
  raise gr.Error("Drop in an image first.")
28
- if randomize:
29
- seed = random.randint(0, MAX_SEED)
30
- pipe.set_adapters("stationthis", adapter_weights=float(strength))
31
- g = torch.Generator("cuda").manual_seed(int(seed))
32
  out = pipe(
33
  image=[image.convert("RGB")],
34
- prompt=(prompt.strip() or PROMPT),
35
- guidance_scale=float(guidance),
36
- num_inference_steps=int(steps),
37
  generator=g,
38
  ).images[0]
39
- return out, seed
40
 
41
 
42
  CSS = """
@@ -50,26 +57,18 @@ footer { display:none !important; }
50
 
51
  with gr.Blocks(css=CSS, title="stationthis") as demo:
52
  gr.HTML(
53
- "<div id='title'><h1>πŸ•ΉοΈ stationthis</h1>"
54
  "<p>Drop an image β€” get it back as a low-poly PlayStation-era still. "
55
  "Powered by FLUX.2 klein + <b>NOEMA</b>. "
56
  "<a href='https://noema.art'>noema.art</a></p></div>"
57
  )
58
  with gr.Row():
59
  with gr.Column():
60
- inp = gr.Image(label="Your image", type="pil", height=360)
61
- with gr.Accordion("Dial it in", open=True):
62
- prompt = gr.Textbox(label="Prompt", value=PROMPT, lines=3)
63
- strength = gr.Slider(0.0, 1.5, value=1.0, step=0.05, label="LoRA strength (PS2 intensity)")
64
- steps = gr.Slider(4, 30, value=8, step=1, label="Steps")
65
- guidance = gr.Slider(1.0, 6.0, value=2.5, step=0.1, label="Guidance")
66
- seed = gr.Slider(0, MAX_SEED, value=42, step=1, label="Seed")
67
- randomize = gr.Checkbox(value=True, label="Randomize seed")
68
  go = gr.Button("Station this", variant="primary")
69
  with gr.Column():
70
- out = gr.Image(label="result", height=360)
71
- used_seed = gr.Number(label="Seed used", interactive=False)
72
- go.click(station_this, [inp, prompt, strength, steps, guidance, seed, randomize], [out, used_seed])
73
 
74
  if __name__ == "__main__":
75
  demo.launch()
 
7
 
8
  BASE = "black-forest-labs/FLUX.2-klein-4B"
9
  LORA = "noema-art/impresstation-klein"
10
+ # Locked-in look (dialed in: strength 1.05 / steps 9 / guidance 3).
11
  PROMPT = (
12
+ "stationthis, low poly playstation screenshot style. A low-poly PlayStation 2 era 3D model, "
13
+ "lightly upscaled like a PS2 emulator running at 2x internal resolution: keep the chunky "
14
+ "low-polygon geometry and flat-shaded surfaces, with cleaner, moderately sharp edges and "
15
+ "readable textures β€” but keep a gentle retro softness and a little texture warmth. Slightly "
16
+ "crisp, not razor-sharp; clean but not clinical. Extrude any flat 2D elements into solid 3D "
17
+ "polygonal forms with real depth and foreshortening. A nicely emulated PS2 screenshot β€” "
18
+ "clearer than the console, softer than 4K."
19
  )
20
+ STRENGTH = 1.05
21
+ STEPS = 9
22
+ GUIDANCE = 3.0
23
  HF_TOKEN = os.environ.get("HF_TOKEN")
24
  MAX_SEED = 2**31 - 1
25
 
26
  dtype = torch.bfloat16
27
  pipe = Flux2KleinPipeline.from_pretrained(BASE, torch_dtype=dtype, token=HF_TOKEN)
28
  pipe.load_lora_weights(LORA, adapter_name="stationthis", token=HF_TOKEN)
29
+ pipe.set_adapters("stationthis", adapter_weights=STRENGTH)
30
  pipe.to("cuda")
31
 
32
 
33
  @spaces.GPU(duration=120)
34
+ def station_this(image, progress=gr.Progress(track_tqdm=True)):
35
  if image is None:
36
  raise gr.Error("Drop in an image first.")
37
+ seed = random.randint(0, MAX_SEED)
38
+ g = torch.Generator("cuda").manual_seed(seed)
 
 
39
  out = pipe(
40
  image=[image.convert("RGB")],
41
+ prompt=PROMPT,
42
+ guidance_scale=GUIDANCE,
43
+ num_inference_steps=STEPS,
44
  generator=g,
45
  ).images[0]
46
+ return out
47
 
48
 
49
  CSS = """
 
57
 
58
  with gr.Blocks(css=CSS, title="stationthis") as demo:
59
  gr.HTML(
60
+ "<div id='title'><h1>β­πŸ‘Œ stationthis</h1>"
61
  "<p>Drop an image β€” get it back as a low-poly PlayStation-era still. "
62
  "Powered by FLUX.2 klein + <b>NOEMA</b>. "
63
  "<a href='https://noema.art'>noema.art</a></p></div>"
64
  )
65
  with gr.Row():
66
  with gr.Column():
67
+ inp = gr.Image(label="Your image", type="pil", height=380)
 
 
 
 
 
 
 
68
  go = gr.Button("Station this", variant="primary")
69
  with gr.Column():
70
+ out = gr.Image(label="result", height=380)
71
+ go.click(station_this, inp, out)
 
72
 
73
  if __name__ == "__main__":
74
  demo.launch()