KingNish commited on
Commit
a276cfd
·
verified ·
1 Parent(s): 3db3884

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -0
app.py CHANGED
@@ -6,6 +6,7 @@ import torch
6
  import time
7
  from diffusers import DiffusionPipeline, AutoencoderTiny
8
  from custom_pipeline import FluxWithCFGPipeline
 
9
 
10
  # --- Torch Optimizations ---
11
  torch.backends.cuda.matmul.allow_tf32 = True
@@ -30,6 +31,8 @@ pipe.vae = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtyp
30
 
31
  pipe.to(device)
32
 
 
 
33
  # --- Inference Function ---
34
  @spaces.GPU
35
  def generate_image(prompt: str, seed: int = 42, width: int = DEFAULT_WIDTH, height: int = DEFAULT_HEIGHT, randomize_seed: bool = False, num_inference_steps: int = DEFAULT_INFERENCE_STEPS, is_enhance: bool = False):
 
6
  import time
7
  from diffusers import DiffusionPipeline, AutoencoderTiny
8
  from custom_pipeline import FluxWithCFGPipeline
9
+ from diffusers.hooks import apply_first_block_cache, FirstBlockCacheConfig
10
 
11
  # --- Torch Optimizations ---
12
  torch.backends.cuda.matmul.allow_tf32 = True
 
31
 
32
  pipe.to(device)
33
 
34
+ apply_first_block_cache(pipe.transformer, FirstBlockCacheConfig(threshold=0.4))
35
+
36
  # --- Inference Function ---
37
  @spaces.GPU
38
  def generate_image(prompt: str, seed: int = 42, width: int = DEFAULT_WIDTH, height: int = DEFAULT_HEIGHT, randomize_seed: bool = False, num_inference_steps: int = DEFAULT_INFERENCE_STEPS, is_enhance: bool = False):