Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,12 @@ import numpy as np
|
|
5 |
import cv2
|
6 |
from PIL import Image
|
7 |
import spaces
|
8 |
-
|
9 |
|
10 |
# 🌟 Auto-detect device (CPU/GPU)
|
11 |
device = "cuda"
|
12 |
precision = torch.float16
|
13 |
|
14 |
-
|
15 |
# 🏗️ Load ControlNet model for Canny edge detection
|
16 |
# xinsir/controlnet-canny-sdxl-1.0
|
17 |
# diffusers/controlnet-canny-sdxl-1.0
|
@@ -26,6 +25,7 @@ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype
|
|
26 |
# Scheduler
|
27 |
eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
|
28 |
|
|
|
29 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
30 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
31 |
controlnet=controlnet,
|
@@ -58,12 +58,8 @@ def generate_image(prompt, input_image, low_threshold, high_threshold, strength,
|
|
58 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
59 |
strength=strength
|
60 |
).images[0]
|
61 |
-
|
62 |
-
result_buffer = io.BytesIO()
|
63 |
-
result.save(result_buffer, format="JPEG")
|
64 |
-
result_buffer.seek(0)
|
65 |
|
66 |
-
return edge_detected,
|
67 |
|
68 |
# 🖥️ Gradio UI
|
69 |
with gr.Blocks() as demo:
|
|
|
5 |
import cv2
|
6 |
from PIL import Image
|
7 |
import spaces
|
8 |
+
|
9 |
|
10 |
# 🌟 Auto-detect device (CPU/GPU)
|
11 |
device = "cuda"
|
12 |
precision = torch.float16
|
13 |
|
|
|
14 |
# 🏗️ Load ControlNet model for Canny edge detection
|
15 |
# xinsir/controlnet-canny-sdxl-1.0
|
16 |
# diffusers/controlnet-canny-sdxl-1.0
|
|
|
25 |
# Scheduler
|
26 |
eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
|
27 |
|
28 |
+
# Stable Diffusion Model
|
29 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
30 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
31 |
controlnet=controlnet,
|
|
|
58 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
59 |
strength=strength
|
60 |
).images[0]
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
return edge_detected, result
|
63 |
|
64 |
# 🖥️ Gradio UI
|
65 |
with gr.Blocks() as demo:
|