Spaces:
Running
on
Zero
Running
on
Zero
Pre-Compile AoTI
#6
by
multimodalart
HF Staff
- opened
- app.py +8 -6
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -5,10 +5,10 @@ import torch
|
|
| 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,12 +164,14 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 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
|
|
|
|
| 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 |
+
spaces.aoti_blocks_load(pipe.transformer, "zerogpu-aoti/Qwen-Image", variant="fa3")
|
| 168 |
+
|
| 169 |
# Apply the same optimizations from the first version
|
| 170 |
+
# pipe.transformer.__class__ = QwenImageTransformer2DModel
|
| 171 |
+
# pipe.transformer.set_attn_processor(QwenDoubleStreamAttnProcessorFA3())
|
| 172 |
|
| 173 |
# --- Ahead-of-time compilation ---
|
| 174 |
+
# optimize_pipeline_(pipe, image=[Image.new("RGB", (1024, 1024)), Image.new("RGB", (1024, 1024))], prompt="prompt")
|
| 175 |
|
| 176 |
# --- UI Constants and Helpers ---
|
| 177 |
MAX_SEED = np.iinfo(np.int32).max
|
requirements.txt
CHANGED
|
@@ -5,4 +5,5 @@ safetensors
|
|
| 5 |
sentencepiece
|
| 6 |
dashscope
|
| 7 |
kernels
|
| 8 |
-
torchvision
|
|
|
|
|
|
| 5 |
sentencepiece
|
| 6 |
dashscope
|
| 7 |
kernels
|
| 8 |
+
torchvision
|
| 9 |
+
torch==2.8
|