jadechoghari commited on
Commit
c7eaabb
β€’
1 Parent(s): 90f85c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -82,6 +82,7 @@
82
  import gradio as gr
83
  import torch
84
  from diffusers import FluxPipeline
 
85
  from torchao.quantization import swap_conv2d_1x1_to_linear, apply_dynamic_quant
86
 
87
  # Step 1: Enable PyTorch 2-specific optimizations
@@ -123,6 +124,7 @@ pipe.unet = torch.compile(pipe.unet, mode="max-autotune", fullgraph=True)
123
  pipe.vae.decode = torch.compile(pipe.vae.decode, mode="max-autotune", fullgraph=True)
124
 
125
  # Image generation function
 
126
  def generate_image(prompt, guidance_scale, num_inference_steps):
127
  # Generate the image using the optimized pipeline
128
  image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
 
82
  import gradio as gr
83
  import torch
84
  from diffusers import FluxPipeline
85
+ import spaces
86
  from torchao.quantization import swap_conv2d_1x1_to_linear, apply_dynamic_quant
87
 
88
  # Step 1: Enable PyTorch 2-specific optimizations
 
124
  pipe.vae.decode = torch.compile(pipe.vae.decode, mode="max-autotune", fullgraph=True)
125
 
126
  # Image generation function
127
+ @spaces.GPU(duration=120)
128
  def generate_image(prompt, guidance_scale, num_inference_steps):
129
  # Generate the image using the optimized pipeline
130
  image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]