Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
|
| 3 |
import torch
|
| 4 |
import numpy as np
|
| 5 |
import cv2
|
|
@@ -20,11 +20,15 @@ controlnet = ControlNetModel.from_pretrained(
|
|
| 20 |
# when test with other base model, you need to change the vae also.
|
| 21 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=precision)
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
| 24 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 25 |
controlnet=controlnet,
|
| 26 |
vae=vae,
|
| 27 |
torch_dtype=precision,
|
|
|
|
| 28 |
).to(device)
|
| 29 |
|
| 30 |
# 📸 Edge detection function using OpenCV (Canny)
|
|
@@ -68,7 +72,7 @@ with gr.Blocks() as demo:
|
|
| 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 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL, EulerAncestralDiscreteScheduler
|
| 3 |
import torch
|
| 4 |
import numpy as np
|
| 5 |
import cv2
|
|
|
|
| 20 |
# when test with other base model, you need to change the vae also.
|
| 21 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=precision)
|
| 22 |
|
| 23 |
+
# Scheduler
|
| 24 |
+
eulera_scheduler = EulerAncestralDiscreteScheduler.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", subfolder="scheduler")
|
| 25 |
+
|
| 26 |
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
| 27 |
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 28 |
controlnet=controlnet,
|
| 29 |
vae=vae,
|
| 30 |
torch_dtype=precision,
|
| 31 |
+
scheduler=eulera_scheduler,
|
| 32 |
).to(device)
|
| 33 |
|
| 34 |
# 📸 Edge detection function using OpenCV (Canny)
|
|
|
|
| 72 |
|
| 73 |
strength = gr.Slider(0.1, 1.0, value=0.8, label="Denoising Strength")
|
| 74 |
guidance = gr.Slider(1, 20, value=7.5, label="Guidance Scale (Creativity)")
|
| 75 |
+
controlnet_conditioning_scale = gr.Slider(0, 1, value=0.5, step=0.01, label="ControlNet Conditioning Scale")
|
| 76 |
|
| 77 |
generate_button = gr.Button("Generate Styled Image")
|
| 78 |
|