frogleo commited on
Commit
61c16d1
·
verified ·
1 Parent(s): f30cd13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  import gradio as gr
2
  import numpy as np
3
  import spaces
@@ -8,9 +13,12 @@ from PIL import Image
8
  from diffusers import FluxKontextPipeline
9
  from diffusers.utils import load_image
10
 
 
 
11
  MAX_SEED = np.iinfo(np.int32).max
12
 
13
  pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
 
14
 
15
  @spaces.GPU
16
  def infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.5, steps=28, progress=gr.Progress()):
 
1
+ # PyTorch 2.8 (temporary hack)
2
+ import os
3
+ os.system('pip install --upgrade --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu126 "torch<2.9" spaces')
4
+
5
+ # Actual demo code
6
  import gradio as gr
7
  import numpy as np
8
  import spaces
 
13
  from diffusers import FluxKontextPipeline
14
  from diffusers.utils import load_image
15
 
16
+ from optimization import optimize_pipeline_
17
+
18
  MAX_SEED = np.iinfo(np.int32).max
19
 
20
  pipe = FluxKontextPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev", torch_dtype=torch.bfloat16).to("cuda")
21
+ optimize_pipeline_(pipe, image=Image.new("RGB", (512, 512)), prompt='prompt')
22
 
23
  @spaces.GPU
24
  def infer(input_image, prompt, seed=42, randomize_seed=False, guidance_scale=2.5, steps=28, progress=gr.Progress()):