fffiloni commited on
Commit
8664707
·
verified ·
1 Parent(s): 55671a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -17,6 +17,15 @@ from diffusers.utils import load_image
17
  controlnet_canny = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny")
18
  controlnet_tile = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
19
 
 
 
 
 
 
 
 
 
 
20
 
21
  def resize_image(input_path, output_path, target_height):
22
  # Open the input image
@@ -43,11 +52,7 @@ def infer_canny(image_in, prompt, control_type, inference_steps, guidance_scale,
43
  n_prompt = 'NSFW, nude, naked, porn, ugly'
44
 
45
  if control_type == "canny":
46
- pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
47
- "stabilityai/stable-diffusion-3-medium-diffusers",
48
- controlnet=controlnet_canny
49
- )
50
-
51
  # Canny preprocessing
52
  image_to_canny = load_image(image_in)
53
  image_to_canny = np.array(image_to_canny)
@@ -59,15 +64,10 @@ def infer_canny(image_in, prompt, control_type, inference_steps, guidance_scale,
59
  control_image = image_to_canny
60
 
61
  elif control_type == "tile":
62
- pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
63
- "stabilityai/stable-diffusion-3-medium-diffusers",
64
- controlnet=controlnet_tile
65
- )
66
-
67
  control_image = load_image(image_in)
68
 
69
-
70
- pipe.to("cuda", torch.float16)
71
 
72
  # infer
73
  image = pipe(
 
17
  controlnet_canny = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny")
18
  controlnet_tile = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Tile")
19
 
20
+ pipe_canny = StableDiffusion3ControlNetPipeline.from_pretrained(
21
+ "stabilityai/stable-diffusion-3-medium-diffusers",
22
+ controlnet=controlnet_canny
23
+ )
24
+
25
+ pipe_tile = StableDiffusion3ControlNetPipeline.from_pretrained(
26
+ "stabilityai/stable-diffusion-3-medium-diffusers",
27
+ controlnet=controlnet_tile
28
+ )
29
 
30
  def resize_image(input_path, output_path, target_height):
31
  # Open the input image
 
52
  n_prompt = 'NSFW, nude, naked, porn, ugly'
53
 
54
  if control_type == "canny":
55
+ pipe = pipe_canny
 
 
 
 
56
  # Canny preprocessing
57
  image_to_canny = load_image(image_in)
58
  image_to_canny = np.array(image_to_canny)
 
64
  control_image = image_to_canny
65
 
66
  elif control_type == "tile":
67
+ pipe = pipe_tile
 
 
 
 
68
  control_image = load_image(image_in)
69
 
70
+ pipe.to("cuda", torch.float16)
 
71
 
72
  # infer
73
  image = pipe(