Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,32 +87,20 @@ def generate_image(prompt, input_image, low_threshold, high_threshold, strength,
|
|
| 87 |
|
| 88 |
print(pipe.get_active_adapters())
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
return edge_detected, result
|
| 106 |
-
|
| 107 |
-
else:
|
| 108 |
-
# Generate styled image using ControlNet
|
| 109 |
-
result = pipe(
|
| 110 |
-
prompt=prompt,
|
| 111 |
-
num_inference_steps=30,
|
| 112 |
-
guidance_scale=guidance
|
| 113 |
-
).images[0]
|
| 114 |
-
|
| 115 |
-
return None, result
|
| 116 |
|
| 117 |
# 🖥️ Gradio UI
|
| 118 |
with gr.Blocks() as demo:
|
|
|
|
| 87 |
|
| 88 |
print(pipe.get_active_adapters())
|
| 89 |
|
| 90 |
+
# Apply edge detection
|
| 91 |
+
edge_detected = apply_canny(input_image, low_threshold, high_threshold)
|
| 92 |
+
|
| 93 |
+
# Generate styled image using ControlNet
|
| 94 |
+
result = pipe(
|
| 95 |
+
prompt=prompt,
|
| 96 |
+
image=edge_detected,
|
| 97 |
+
num_inference_steps=30,
|
| 98 |
+
guidance_scale=guidance,
|
| 99 |
+
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
| 100 |
+
strength=strength
|
| 101 |
+
).images[0]
|
| 102 |
+
|
| 103 |
+
return edge_detected, result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# 🖥️ Gradio UI
|
| 106 |
with gr.Blocks() as demo:
|