multimodalart HF staff commited on
Commit
e1fcf74
1 Parent(s): 00fc70b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import spaces
3
  from clip_slider_pipeline import CLIPSliderFlux
4
- from diffusers import FluxPipeline
5
  import torch
6
  import numpy as np
7
  import cv2
@@ -18,18 +18,22 @@ def process_controlnet_img(image):
18
  controlnet_img = Image.fromarray(controlnet_img)
19
 
20
  # load pipelines
21
- pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell",
 
 
22
  torch_dtype=torch.bfloat16)
23
  #pipe.enable_model_cpu_offload()
24
  clip_slider = CLIPSliderFlux(pipe, device=torch.device("cuda"))
25
 
 
 
 
26
  base_model = 'black-forest-labs/FLUX.1-schnell'
27
  controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Canny-alpha'
28
  # controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
29
  # pipe_controlnet = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
30
  # t5_slider_controlnet = T5SliderFlux(sd_pipe=pipe_controlnet,device=torch.device("cuda"))
31
 
32
-
33
  @spaces.GPU(duration=200)
34
  def generate(slider_x, prompt, seed, recalc_directions, iterations, steps, guidance_scale,
35
  x_concept_1, x_concept_2,
 
1
  import gradio as gr
2
  import spaces
3
  from clip_slider_pipeline import CLIPSliderFlux
4
+ from diffusers import FluxPipeline, AutoencoderTiny
5
  import torch
6
  import numpy as np
7
  import cv2
 
18
  controlnet_img = Image.fromarray(controlnet_img)
19
 
20
  # load pipelines
21
+ taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
22
+ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell",
23
+ vae=taef1,
24
  torch_dtype=torch.bfloat16)
25
  #pipe.enable_model_cpu_offload()
26
  clip_slider = CLIPSliderFlux(pipe, device=torch.device("cuda"))
27
 
28
+ clip_slider.transformer.to(memory_format=torch.channels_last)
29
+ clip_slider.transformer = torch.compile(clip_slider.unet, mode="max-autotune", fullgraph=True)
30
+
31
  base_model = 'black-forest-labs/FLUX.1-schnell'
32
  controlnet_model = 'InstantX/FLUX.1-dev-Controlnet-Canny-alpha'
33
  # controlnet = FluxControlNetModel.from_pretrained(controlnet_model, torch_dtype=torch.bfloat16)
34
  # pipe_controlnet = FluxControlNetPipeline.from_pretrained(base_model, controlnet=controlnet, torch_dtype=torch.bfloat16)
35
  # t5_slider_controlnet = T5SliderFlux(sd_pipe=pipe_controlnet,device=torch.device("cuda"))
36
 
 
37
  @spaces.GPU(duration=200)
38
  def generate(slider_x, prompt, seed, recalc_directions, iterations, steps, guidance_scale,
39
  x_concept_1, x_concept_2,