LPX55 commited on
Commit
e5d1cff
·
verified ·
1 Parent(s): f27ea3a

Update raw.py

Browse files
Files changed (1) hide show
  1. raw.py +6 -3
raw.py CHANGED
@@ -2,19 +2,22 @@ import torch
2
  import spaces
3
  import os
4
  from diffusers.utils import load_image
5
- from diffusers import FluxControlNetModel, FluxControlNetPipeline
6
  import gradio as gr
7
  huggingface_token = os.getenv("HUGGINFACE_TOKEN")
8
 
 
 
9
  # Load pipeline
10
  controlnet = FluxControlNetModel.from_pretrained(
11
  "jasperai/Flux.1-dev-Controlnet-Upscaler",
12
  torch_dtype=torch.bfloat16
13
  )
14
  pipe = FluxControlNetPipeline.from_pretrained(
15
- "black-forest-labs/FLUX.1-dev",
16
  controlnet=controlnet,
17
  torch_dtype=torch.bfloat16,
 
18
  token=huggingface_token
19
  )
20
  pipe.to("cuda")
@@ -25,7 +28,7 @@ def generate_image(prompt, scale, steps, control_image):
25
  control_image = load_image(control_image)
26
  w, h = control_image.size
27
  # Upscale x1
28
- control_image = control_image.resize((w * scale, h * scale))
29
  image = pipe(
30
  prompt=prompt,
31
  control_image=control_image,
 
2
  import spaces
3
  import os
4
  from diffusers.utils import load_image
5
+ from diffusers import FluxControlNetModel, FluxControlNetPipeline, AutoencoderKL
6
  import gradio as gr
7
  huggingface_token = os.getenv("HUGGINFACE_TOKEN")
8
 
9
+ good_vae = AutoencoderKL.from_pretrained("black-forest-labs/FLUX.1-dev", subfolder="vae", torch_dtype=torch.bfloat16, token=huggingface_token).to(device)
10
+
11
  # Load pipeline
12
  controlnet = FluxControlNetModel.from_pretrained(
13
  "jasperai/Flux.1-dev-Controlnet-Upscaler",
14
  torch_dtype=torch.bfloat16
15
  )
16
  pipe = FluxControlNetPipeline.from_pretrained(
17
+ "LPX55/FLUX.1-merged_uncensored",
18
  controlnet=controlnet,
19
  torch_dtype=torch.bfloat16,
20
+ vae=good_vae,
21
  token=huggingface_token
22
  )
23
  pipe.to("cuda")
 
28
  control_image = load_image(control_image)
29
  w, h = control_image.size
30
  # Upscale x1
31
+ control_image = control_image.resize((int(w * scale), int(h * scale)))
32
  image = pipe(
33
  prompt=prompt,
34
  control_image=control_image,