Spaces:
Running
on
Zero
Running
on
Zero
Update optimized.py
Browse files- optimized.py +4 -4
optimized.py
CHANGED
|
@@ -44,7 +44,7 @@ good_vae = AutoencoderKL.from_pretrained(
|
|
| 44 |
use_safetensors=True,
|
| 45 |
device_map=None, # Disable automatic mapping
|
| 46 |
token=huggingface_token
|
| 47 |
-
)
|
| 48 |
# 2. Main Pipeline Initialization WITH VAE SCOPE
|
| 49 |
pipe = FluxControlNetPipeline.from_pretrained(
|
| 50 |
"LPX55/FLUX.1-merged_uncensored",
|
|
@@ -58,7 +58,7 @@ pipe = FluxControlNetPipeline.from_pretrained(
|
|
| 58 |
device_map=None,
|
| 59 |
token=huggingface_token # Note corrected env var name
|
| 60 |
)
|
| 61 |
-
|
| 62 |
# 3. Strict Order for Optimization Steps
|
| 63 |
# A. Apply CPU Offloading FIRST
|
| 64 |
pipe.enable_sequential_cpu_offload() # No arguments for new API
|
|
@@ -73,8 +73,8 @@ if getattr(pipe, "vae", None) is not None:
|
|
| 73 |
|
| 74 |
pipe.enable_attention_slicing(1)
|
| 75 |
# B. Enable Memory Optimizations
|
| 76 |
-
pipe.enable_vae_tiling()
|
| 77 |
-
pipe.enable_xformers_memory_efficient_attention()
|
| 78 |
|
| 79 |
# C. Unified Precision Handling
|
| 80 |
# for comp in [pipe.unet, pipe.vae, pipe.controlnet]:
|
|
|
|
| 44 |
use_safetensors=True,
|
| 45 |
device_map=None, # Disable automatic mapping
|
| 46 |
token=huggingface_token
|
| 47 |
+
).to(device)
|
| 48 |
# 2. Main Pipeline Initialization WITH VAE SCOPE
|
| 49 |
pipe = FluxControlNetPipeline.from_pretrained(
|
| 50 |
"LPX55/FLUX.1-merged_uncensored",
|
|
|
|
| 58 |
device_map=None,
|
| 59 |
token=huggingface_token # Note corrected env var name
|
| 60 |
)
|
| 61 |
+
pipe.to(device)
|
| 62 |
# 3. Strict Order for Optimization Steps
|
| 63 |
# A. Apply CPU Offloading FIRST
|
| 64 |
pipe.enable_sequential_cpu_offload() # No arguments for new API
|
|
|
|
| 73 |
|
| 74 |
pipe.enable_attention_slicing(1)
|
| 75 |
# B. Enable Memory Optimizations
|
| 76 |
+
# pipe.enable_vae_tiling()
|
| 77 |
+
# pipe.enable_xformers_memory_efficient_attention()
|
| 78 |
|
| 79 |
# C. Unified Precision Handling
|
| 80 |
# for comp in [pipe.unet, pipe.vae, pipe.controlnet]:
|