Deadmon commited on
Commit
14d5805
·
verified ·
1 Parent(s): 379d66e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -24,19 +24,31 @@ control_modes = [
24
  ]
25
 
26
  @spaces.GPU
27
- def generate_image(prompt, control_image_depth, control_mode_depth_index, control_image_canny, control_mode_canny_index):
28
- control_mode_depth = control_modes.index(control_mode_depth_index)
 
 
 
 
 
 
 
 
 
29
  control_mode_canny = control_modes.index(control_mode_canny_index)
 
 
 
30
 
31
- width, height = control_image_depth.size
32
 
33
  image = pipe(
34
  prompt,
35
- control_image=[control_image_depth, control_image_canny],
36
- control_mode=[control_mode_depth, control_mode_canny],
37
  width=width,
38
  height=height,
39
- controlnet_conditioning_scale=[0.2, 0.4],
40
  num_inference_steps=24,
41
  guidance_scale=3.5,
42
  generator=torch.manual_seed(42),
@@ -50,6 +62,7 @@ iface = gr.Interface(
50
  gr.Text(label="Prompt"),
51
  gr.Image(label="Control Image (Depth)"),
52
  gr.Dropdown(choices=control_modes, value="depth", label="Control Mode (Depth)"),
 
53
  gr.Image(label="Control Image (Canny)"),
54
  gr.Dropdown(choices=control_modes, value="canny", label="Control Mode (Canny)")
55
  ],
@@ -58,4 +71,4 @@ iface = gr.Interface(
58
  description="Generate an image using FluxControlNet with depth and canny control images.",
59
  )
60
 
61
- iface.launch()
 
24
  ]
25
 
26
  @spaces.GPU
27
+ def generate_image(prompt, control_image_depth, control_mode_depth_index, use_depth, control_image_canny, control_mode_canny_index):
28
+ control_images = []
29
+ control_modes = []
30
+ conditioning_scales = []
31
+
32
+ if use_depth:
33
+ control_mode_depth = control_modes.index(control_mode_depth_index)
34
+ control_images.append(control_image_depth)
35
+ control_modes.append(control_mode_depth)
36
+ conditioning_scales.append(0.2)
37
+
38
  control_mode_canny = control_modes.index(control_mode_canny_index)
39
+ control_images.append(control_image_canny)
40
+ control_modes.append(control_mode_canny)
41
+ conditioning_scales.append(0.4)
42
 
43
+ width, height = control_image_canny.size
44
 
45
  image = pipe(
46
  prompt,
47
+ control_image=control_images,
48
+ control_mode=control_modes,
49
  width=width,
50
  height=height,
51
+ controlnet_conditioning_scale=conditioning_scales,
52
  num_inference_steps=24,
53
  guidance_scale=3.5,
54
  generator=torch.manual_seed(42),
 
62
  gr.Text(label="Prompt"),
63
  gr.Image(label="Control Image (Depth)"),
64
  gr.Dropdown(choices=control_modes, value="depth", label="Control Mode (Depth)"),
65
+ gr.Checkbox(label="Use Depth Control Image", value=True),
66
  gr.Image(label="Control Image (Canny)"),
67
  gr.Dropdown(choices=control_modes, value="canny", label="Control Mode (Canny)")
68
  ],
 
71
  description="Generate an image using FluxControlNet with depth and canny control images.",
72
  )
73
 
74
+ iface.launch(share=True)