ZennyKenny commited on
Commit
0dec9f5
·
verified ·
1 Parent(s): 3b268ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -5,7 +5,7 @@ import spaces
5
  import os
6
  import torch
7
 
8
- from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL
9
  from huggingface_hub import login
10
  from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_images
11
 
@@ -17,11 +17,9 @@ if hf_token:
17
  dtype = torch.bfloat16
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
 
20
- # Load VAEs
21
  taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
22
- good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=dtype).to(device)
23
 
24
- # Load base model with TAEF1 injected
25
  pipe = DiffusionPipeline.from_pretrained(
26
  "black-forest-labs/FLUX.1-dev",
27
  torch_dtype=dtype,
@@ -29,7 +27,6 @@ pipe = DiffusionPipeline.from_pretrained(
29
  vae=taef1
30
  ).to(device)
31
 
32
- # Inject method + apply LoRA
33
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
34
  pipe.load_lora_weights("ZennyKenny/flux_lora_natalie-diffusion")
35
 
@@ -42,7 +39,6 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
42
  seed = random.randint(0, MAX_SEED)
43
  generator = torch.Generator().manual_seed(seed)
44
 
45
- # Prepend XTON
46
  prompt = f"XTON {prompt}"
47
 
48
  for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
@@ -115,7 +111,7 @@ Generate images in the surreal style of artist [Natalie Kav](https://www.behance
115
  guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=15, step=0.1, value=3.5)
116
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=50, step=1, value=28)
117
 
118
- # Define hidden result image just for example caching
119
  result_example = gr.Image(visible=False)
120
 
121
  gr.Examples(
 
5
  import os
6
  import torch
7
 
8
+ from diffusers import DiffusionPipeline, AutoencoderTiny
9
  from huggingface_hub import login
10
  from live_preview_helpers import flux_pipe_call_that_returns_an_iterable_of_images
11
 
 
17
  dtype = torch.bfloat16
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
 
20
+ # DO NOT CHANGE: Working pipeline using taef1
21
  taef1 = AutoencoderTiny.from_pretrained("madebyollin/taef1", torch_dtype=dtype).to(device)
 
22
 
 
23
  pipe = DiffusionPipeline.from_pretrained(
24
  "black-forest-labs/FLUX.1-dev",
25
  torch_dtype=dtype,
 
27
  vae=taef1
28
  ).to(device)
29
 
 
30
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
31
  pipe.load_lora_weights("ZennyKenny/flux_lora_natalie-diffusion")
32
 
 
39
  seed = random.randint(0, MAX_SEED)
40
  generator = torch.Generator().manual_seed(seed)
41
 
 
42
  prompt = f"XTON {prompt}"
43
 
44
  for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
 
111
  guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=15, step=0.1, value=3.5)
112
  num_inference_steps = gr.Slider(label="Number of inference steps", minimum=1, maximum=50, step=1, value=28)
113
 
114
+ # Use hidden result for examples only
115
  result_example = gr.Image(visible=False)
116
 
117
  gr.Examples(