Update app.py
Browse files
app.py
CHANGED
|
@@ -35,9 +35,23 @@ pipe = pipe.to(device)
|
|
| 35 |
|
| 36 |
# Extra CPU optimizations
|
| 37 |
if device == "cpu":
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
# Define image generation function with quality toggle
|
| 43 |
def generate(prompt, quality):
|
|
|
|
| 35 |
|
| 36 |
# Extra CPU optimizations
|
| 37 |
if device == "cpu":
|
| 38 |
+
try:
|
| 39 |
+
pipe.enable_attention_slicing()
|
| 40 |
+
print("✅ Attention slicing enabled")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"⚠️ Could not enable attention slicing: {e}")
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
pipe.enable_sequential_cpu_offload()
|
| 46 |
+
print("✅ Sequential CPU offload enabled")
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print(f"⚠️ Could not enable sequential CPU offload: {e}")
|
| 49 |
+
|
| 50 |
+
try:
|
| 51 |
+
pipe.enable_vae_tiling()
|
| 52 |
+
print("✅ VAE tiling enabled")
|
| 53 |
+
except Exception as e:
|
| 54 |
+
print(f"⚠️ Could not enable VAE tiling: {e}")
|
| 55 |
|
| 56 |
# Define image generation function with quality toggle
|
| 57 |
def generate(prompt, quality):
|