Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -169,36 +169,6 @@ def encode_image(pil_image):
|
|
| 169 |
dtype = torch.bfloat16
|
| 170 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 171 |
|
| 172 |
-
# Scheduler configuration for Lightning
|
| 173 |
-
# scheduler_config = {
|
| 174 |
-
# "base_image_seq_len": 256,
|
| 175 |
-
# "base_shift": math.log(3),
|
| 176 |
-
# "invert_sigmas": False,
|
| 177 |
-
# "max_image_seq_len": 8192,
|
| 178 |
-
# "max_shift": math.log(3),
|
| 179 |
-
# "num_train_timesteps": 1000,
|
| 180 |
-
# "shift": 1.0,
|
| 181 |
-
# "shift_terminal": None,
|
| 182 |
-
# "stochastic_sampling": False,
|
| 183 |
-
# "time_shift_type": "exponential",
|
| 184 |
-
# "use_beta_sigmas": False,
|
| 185 |
-
# "use_dynamic_shifting": True,
|
| 186 |
-
# "use_exponential_sigmas": False,
|
| 187 |
-
# "use_karras_sigmas": False,
|
| 188 |
-
# }
|
| 189 |
-
|
| 190 |
-
# # Initialize scheduler with Lightning config
|
| 191 |
-
# scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
|
| 192 |
-
|
| 193 |
-
# # Load the model pipeline
|
| 194 |
-
# pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509",
|
| 195 |
-
# scheduler=scheduler,
|
| 196 |
-
# torch_dtype=dtype).to(device)
|
| 197 |
-
# pipe.load_lora_weights(
|
| 198 |
-
# "lightx2v/Qwen-Image-Lightning",
|
| 199 |
-
# weight_name="Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors"
|
| 200 |
-
# )
|
| 201 |
-
# pipe.fuse_lora()
|
| 202 |
pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509",
|
| 203 |
# scheduler=scheduler,
|
| 204 |
torch_dtype=dtype).to(device)
|
|
@@ -209,7 +179,13 @@ weights_path = hf_hub_download(
|
|
| 209 |
)
|
| 210 |
state_dict = load_file(weights_path)
|
| 211 |
|
|
|
|
| 212 |
pipe.transformer.load_state_dict(state_dict, strict=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# Apply the same optimizations from the first version
|
| 215 |
pipe.transformer.__class__ = QwenImageTransformer2DModel
|
|
|
|
| 169 |
dtype = torch.bfloat16
|
| 170 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509",
|
| 173 |
# scheduler=scheduler,
|
| 174 |
torch_dtype=dtype).to(device)
|
|
|
|
| 179 |
)
|
| 180 |
state_dict = load_file(weights_path)
|
| 181 |
|
| 182 |
+
# load next scene LoRA
|
| 183 |
pipe.transformer.load_state_dict(state_dict, strict=False)
|
| 184 |
+
pipe.load_lora_weights(
|
| 185 |
+
"lovis93/next-scene-qwen-image-lora-2509",
|
| 186 |
+
weight_name="next-scene_lora-v2-3000.safetensors"
|
| 187 |
+
)
|
| 188 |
+
pipe.fuse_lora()
|
| 189 |
|
| 190 |
# Apply the same optimizations from the first version
|
| 191 |
pipe.transformer.__class__ = QwenImageTransformer2DModel
|