Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,31 +32,46 @@ pipe = QwenImageEditPlusPipeline.from_pretrained(
|
|
| 32 |
torch_dtype=dtype
|
| 33 |
).to(device)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
"
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
# Load second LoRA
|
| 43 |
pipe.load_lora_weights(
|
| 44 |
"lightx2v/Qwen-Image-Lightning",
|
| 45 |
-
weight_name="Qwen-Image-Lightning-8steps-V2.0
|
| 46 |
-
adapter_name="
|
| 47 |
)
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
)
|
| 54 |
|
| 55 |
-
|
| 56 |
-
pipe.fuse_lora(
|
| 57 |
-
|
| 58 |
-
lora_scale=1.0
|
| 59 |
-
)
|
| 60 |
pipe.unload_lora_weights()
|
| 61 |
|
| 62 |
#spaces.aoti_blocks_load(pipe.transformer, "zerogpu-aoti/Qwen-Image", variant="fa3")
|
|
@@ -75,7 +90,6 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
| 75 |
# Default prompt for light migration
|
| 76 |
DEFAULT_PROMPT = "参考色调,移除图1原有的光照并参考图2的光照和色调对图1重新照明"
|
| 77 |
|
| 78 |
-
|
| 79 |
@spaces.GPU
|
| 80 |
def infer_light_migration(
|
| 81 |
image: Optional[Image.Image] = None,
|
|
|
|
| 32 |
torch_dtype=dtype
|
| 33 |
).to(device)
|
| 34 |
|
| 35 |
+
scheduler_config = {
|
| 36 |
+
"base_image_seq_len": 256,
|
| 37 |
+
"base_shift": math.log(3),
|
| 38 |
+
"invert_sigmas": False,
|
| 39 |
+
"max_image_seq_len": 8192,
|
| 40 |
+
"max_shift": math.log(3),
|
| 41 |
+
"num_train_timesteps": 1000,
|
| 42 |
+
"shift": 1.0,
|
| 43 |
+
"shift_terminal": None,
|
| 44 |
+
"stochastic_sampling": False,
|
| 45 |
+
"time_shift_type": "exponential",
|
| 46 |
+
"use_beta_sigmas": False,
|
| 47 |
+
"use_dynamic_shifting": True,
|
| 48 |
+
"use_exponential_sigmas": False,
|
| 49 |
+
"use_karras_sigmas": False,
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
|
| 53 |
+
|
| 54 |
+
pipe = QwenImageEditPlusPipeline.from_pretrained(
|
| 55 |
+
"Qwen/Qwen-Image-Edit-2509",
|
| 56 |
+
scheduler=scheduler,
|
| 57 |
+
torch_dtype=dtype
|
| 58 |
+
).to(device)
|
| 59 |
|
|
|
|
| 60 |
pipe.load_lora_weights(
|
| 61 |
"lightx2v/Qwen-Image-Lightning",
|
| 62 |
+
weight_name="Qwen-Image-Lightning-8steps-V2.0.safetensors",
|
| 63 |
+
adapter_name="fast"
|
| 64 |
)
|
| 65 |
|
| 66 |
+
pipe.load_lora_weights(
|
| 67 |
+
"dx8152/Qwen-Edit-2509-Light-Migration",
|
| 68 |
+
weight_name="参考色调.safetensors",
|
| 69 |
+
adapter_name="angles"
|
| 70 |
)
|
| 71 |
|
| 72 |
+
pipe.set_adapters(["angles","fast"], adapter_weights=[1.,1.])
|
| 73 |
+
pipe.fuse_lora(adapter_names=["angles"], lora_scale=1.)
|
| 74 |
+
pipe.fuse_lora(adapter_names=["fast"], lora_scale=1.)
|
|
|
|
|
|
|
| 75 |
pipe.unload_lora_weights()
|
| 76 |
|
| 77 |
#spaces.aoti_blocks_load(pipe.transformer, "zerogpu-aoti/Qwen-Image", variant="fa3")
|
|
|
|
| 90 |
# Default prompt for light migration
|
| 91 |
DEFAULT_PROMPT = "参考色调,移除图1原有的光照并参考图2的光照和色调对图1重新照明"
|
| 92 |
|
|
|
|
| 93 |
@spaces.GPU
|
| 94 |
def infer_light_migration(
|
| 95 |
image: Optional[Image.Image] = None,
|