Spaces:
Sleeping
Sleeping
expose prompt + LoRA strength + steps/guidance for dial-in
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ from diffusers import Flux2KleinPipeline
|
|
| 7 |
|
| 8 |
BASE = "black-forest-labs/FLUX.2-klein-4B"
|
| 9 |
LORA = "noema-art/impresstation-klein"
|
| 10 |
-
#
|
| 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."
|
|
@@ -22,15 +22,16 @@ pipe.to("cuda")
|
|
| 22 |
|
| 23 |
|
| 24 |
@spaces.GPU(duration=120)
|
| 25 |
-
def station_this(image, 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 |
g = torch.Generator("cuda").manual_seed(int(seed))
|
| 31 |
out = pipe(
|
| 32 |
image=[image.convert("RGB")],
|
| 33 |
-
prompt=PROMPT,
|
| 34 |
guidance_scale=float(guidance),
|
| 35 |
num_inference_steps=int(steps),
|
| 36 |
generator=g,
|
|
@@ -57,7 +58,9 @@ with gr.Blocks(css=CSS, title="stationthis") as demo:
|
|
| 57 |
with gr.Row():
|
| 58 |
with gr.Column():
|
| 59 |
inp = gr.Image(label="Your image", type="pil", height=360)
|
| 60 |
-
with gr.Accordion("
|
|
|
|
|
|
|
| 61 |
steps = gr.Slider(4, 30, value=8, step=1, label="Steps")
|
| 62 |
guidance = gr.Slider(1.0, 6.0, value=2.5, step=0.1, label="Guidance")
|
| 63 |
seed = gr.Slider(0, MAX_SEED, value=42, step=1, label="Seed")
|
|
@@ -66,7 +69,7 @@ with gr.Blocks(css=CSS, title="stationthis") as demo:
|
|
| 66 |
with gr.Column():
|
| 67 |
out = gr.Image(label="result", height=360)
|
| 68 |
used_seed = gr.Number(label="Seed used", interactive=False)
|
| 69 |
-
go.click(station_this, [inp, steps, guidance, seed, randomize], [out, used_seed])
|
| 70 |
|
| 71 |
if __name__ == "__main__":
|
| 72 |
demo.launch()
|
|
|
|
| 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."
|
|
|
|
| 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,
|
|
|
|
| 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")
|
|
|
|
| 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()
|