ar0551 commited on
Commit
d39d36a
·
verified ·
1 Parent(s): f6e6e5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -25,13 +25,7 @@ pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
25
  controlnet=controlnet,
26
  vae=vae,
27
  torch_dtype=precision,
28
- )
29
-
30
- pipe.enable_model_cpu_offload()
31
- pipe.to(device)
32
-
33
- ## to move in the function
34
- controlnet_conditioning_scale = 0.5 # recommended for good generalization
35
 
36
  # 📸 Edge detection function using OpenCV (Canny)
37
  @spaces.GPU
@@ -44,7 +38,7 @@ def apply_canny(image, low_threshold, high_threshold):
44
 
45
  # 🎨 Image generation function
46
  @spaces.GPU
47
- def generate_image(prompt, input_image, low_threshold, high_threshold, strength, guidance):
48
  # Apply edge detection
49
  edge_detected = apply_canny(input_image, low_threshold, high_threshold)
50
 
@@ -74,6 +68,7 @@ with gr.Blocks() as demo:
74
 
75
  strength = gr.Slider(0.1, 1.0, value=0.8, label="Denoising Strength")
76
  guidance = gr.Slider(1, 20, value=7.5, label="Guidance Scale (Creativity)")
 
77
 
78
  generate_button = gr.Button("Generate Styled Image")
79
 
@@ -84,7 +79,7 @@ with gr.Blocks() as demo:
84
  # 🔗 Button Action
85
  generate_button.click(
86
  fn=generate_image,
87
- inputs=[prompt, input_image, low_threshold, high_threshold, strength, guidance],
88
  outputs=[edge_output, result_output]
89
  )
90
 
 
25
  controlnet=controlnet,
26
  vae=vae,
27
  torch_dtype=precision,
28
+ ).to(device)
 
 
 
 
 
 
29
 
30
  # 📸 Edge detection function using OpenCV (Canny)
31
  @spaces.GPU
 
38
 
39
  # 🎨 Image generation function
40
  @spaces.GPU
41
+ def generate_image(prompt, input_image, low_threshold, high_threshold, strength, guidance, controlnet_conditioning_scale):
42
  # Apply edge detection
43
  edge_detected = apply_canny(input_image, low_threshold, high_threshold)
44
 
 
68
 
69
  strength = gr.Slider(0.1, 1.0, value=0.8, label="Denoising Strength")
70
  guidance = gr.Slider(1, 20, value=7.5, label="Guidance Scale (Creativity)")
71
+ controlnet_conditioning_scale = gr.Slider(0, 1, value=0.5, label="ControlNet Conditioning Scale")
72
 
73
  generate_button = gr.Button("Generate Styled Image")
74
 
 
79
  # 🔗 Button Action
80
  generate_button.click(
81
  fn=generate_image,
82
+ inputs=[prompt, input_image, low_threshold, high_threshold, strength, guidance, controlnet_conditioning_scale],
83
  outputs=[edge_output, result_output]
84
  )
85