Create optimization.py

#1
by linoyts HF Staff - opened
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -8,6 +8,7 @@ import json
8
  from io import BytesIO
9
  from PIL import Image, ImageDraw
10
  from diffusers import Flux2KleinPipeline
 
11
 
12
  MAX_SEED = np.iinfo(np.int32).max
13
 
@@ -22,6 +23,16 @@ pipe.load_lora_weights(
22
  "linoyts/flux_klein_9b_bbox_lora",
23
  weight_name="flux_klein_9b_bbox_lora.safetensors",
24
  )
 
 
 
 
 
 
 
 
 
 
25
  print("Pipeline ready.")
26
 
27
  DEFAULT_PROMPT = (
 
8
  from io import BytesIO
9
  from PIL import Image, ImageDraw
10
  from diffusers import Flux2KleinPipeline
11
+ from optimization import optimize_pipeline_
12
 
13
  MAX_SEED = np.iinfo(np.int32).max
14
 
 
23
  "linoyts/flux_klein_9b_bbox_lora",
24
  weight_name="flux_klein_9b_bbox_lora.safetensors",
25
  )
26
+
27
+ optimize_pipeline_(
28
+ pipe,
29
+ image=[Image.new("RGB", (1024, 1024))],
30
+ prompt = "Move the object inside the red bounding box to the position and size indicated by the green bounding box. Remove the object from its original location in the red box, filling in the background naturally. Remove the bounding boxes and seamlessly blend the repositioned object into the scene, preserving all other objects and the background exactly as they are.",
31
+ guidance_scale=4,
32
+ width=1024,
33
+ height=1024,
34
+ num_inference_steps=1
35
+ )
36
  print("Pipeline ready.")
37
 
38
  DEFAULT_PROMPT = (