linoyts HF Staff commited on
Commit
74ee40c
·
verified ·
1 Parent(s): 11a704b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -5,7 +5,10 @@ import torch
5
  import spaces
6
 
7
  from PIL import Image
8
- from diffusers import QwenImageEditPlusPipeline
 
 
 
9
 
10
  import os
11
  import base64
@@ -161,6 +164,13 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
161
  # Load the model pipeline
162
  pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509", torch_dtype=dtype).to(device)
163
 
 
 
 
 
 
 
 
164
  # --- UI Constants and Helpers ---
165
  MAX_SEED = np.iinfo(np.int32).max
166
 
 
5
  import spaces
6
 
7
  from PIL import Image
8
+ from optimization import optimize_pipeline_
9
+ from qwenimage.pipeline_qwenimage_edit_plus import QwenImageEditPlusPipeline
10
+ from qwenimage.transformer_qwenimage import QwenImageTransformer2DModel
11
+ from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
12
 
13
  import os
14
  import base64
 
164
  # Load the model pipeline
165
  pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509", torch_dtype=dtype).to(device)
166
 
167
+ # Apply the same optimizations from the first version
168
+ pipe.transformer.__class__ = QwenImageTransformer2DModel
169
+ pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
170
+
171
+ # --- Ahead-of-time compilation ---
172
+ optimize_pipeline_(pipe, image=[Image.new("RGB", (1024, 1024)), Image.new("RGB", (1024, 1024))], prompt="prompt")
173
+
174
  # --- UI Constants and Helpers ---
175
  MAX_SEED = np.iinfo(np.int32).max
176