update app
Browse files
app.py
CHANGED
|
@@ -79,7 +79,6 @@ print("Loading FLUX.2 Klein 9B model base...")
|
|
| 79 |
pipe = Flux2KleinPipeline.from_pretrained(
|
| 80 |
"black-forest-labs/FLUX.2-klein-9B",
|
| 81 |
torch_dtype=torch.bfloat16,
|
| 82 |
-
attn_implementation="kernels-community/flash-attn3",
|
| 83 |
).to(device)
|
| 84 |
print("Base Model loaded successfully.")
|
| 85 |
|
|
@@ -146,7 +145,6 @@ def infer(
|
|
| 146 |
width, height = update_dimensions_on_upload(input_image)
|
| 147 |
processed_input = input_image.resize((width, height), Image.LANCZOS).convert("RGB")
|
| 148 |
|
| 149 |
-
# 4. Inference
|
| 150 |
try:
|
| 151 |
image = pipe(
|
| 152 |
image=processed_input,
|
|
@@ -200,31 +198,32 @@ with gr.Blocks() as demo:
|
|
| 200 |
input_image = gr.Image(
|
| 201 |
label="Upload Image",
|
| 202 |
type="pil",
|
| 203 |
-
height=
|
| 204 |
sources=["upload", "webcam", "clipboard"]
|
| 205 |
)
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
| 217 |
|
| 218 |
run_button = gr.Button("Apply Style", variant="primary")
|
| 219 |
|
| 220 |
-
with gr.Accordion("Advanced Settings", open=False):
|
| 221 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
|
| 222 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 223 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=10.0, step=0.1, value=1.0)
|
| 224 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=4, step=1)
|
| 225 |
|
| 226 |
with gr.Column():
|
| 227 |
-
output_image = gr.Image(label="
|
| 228 |
used_seed = gr.Textbox(label="Used Seed", interactive=False, visible=False)
|
| 229 |
|
| 230 |
gr.Examples(
|
|
|
|
| 79 |
pipe = Flux2KleinPipeline.from_pretrained(
|
| 80 |
"black-forest-labs/FLUX.2-klein-9B",
|
| 81 |
torch_dtype=torch.bfloat16,
|
|
|
|
| 82 |
).to(device)
|
| 83 |
print("Base Model loaded successfully.")
|
| 84 |
|
|
|
|
| 145 |
width, height = update_dimensions_on_upload(input_image)
|
| 146 |
processed_input = input_image.resize((width, height), Image.LANCZOS).convert("RGB")
|
| 147 |
|
|
|
|
| 148 |
try:
|
| 149 |
image = pipe(
|
| 150 |
image=processed_input,
|
|
|
|
| 198 |
input_image = gr.Image(
|
| 199 |
label="Upload Image",
|
| 200 |
type="pil",
|
| 201 |
+
height=300,
|
| 202 |
sources=["upload", "webcam", "clipboard"]
|
| 203 |
)
|
| 204 |
+
with gr.Row():
|
| 205 |
+
prompt = gr.Text(
|
| 206 |
+
label="Edit Prompt",
|
| 207 |
+
show_label=True,
|
| 208 |
+
placeholder="e.g., a man with a red superhero mask"
|
| 209 |
+
)
|
| 210 |
+
with gr.Row():
|
| 211 |
+
lora_adapter = gr.Dropdown(
|
| 212 |
+
label="Choose Editing Style",
|
| 213 |
+
choices=list(ADAPTER_SPECS.keys()),
|
| 214 |
+
value="Klein-Delight-Style"
|
| 215 |
+
)
|
| 216 |
|
| 217 |
run_button = gr.Button("Apply Style", variant="primary")
|
| 218 |
|
| 219 |
+
with gr.Accordion("Advanced Settings", open=False, visible=False):
|
| 220 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=0)
|
| 221 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 222 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=0.0, maximum=10.0, step=0.1, value=1.0)
|
| 223 |
steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=4, step=1)
|
| 224 |
|
| 225 |
with gr.Column():
|
| 226 |
+
output_image = gr.Image(label="Output Image", interactive=False, format="png", height=420)
|
| 227 |
used_seed = gr.Textbox(label="Used Seed", interactive=False, visible=False)
|
| 228 |
|
| 229 |
gr.Examples(
|