Update app.py
Browse files
app.py
CHANGED
|
@@ -7,21 +7,17 @@ from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCM
|
|
| 7 |
|
| 8 |
# Load ControlNet model
|
| 9 |
controlnet = ControlNetModel.from_pretrained(
|
| 10 |
-
"lllyasviel/sd-controlnet-canny", torch_dtype=torch.
|
| 11 |
)
|
| 12 |
|
| 13 |
# Load Stable Diffusion pipeline with ControlNet
|
| 14 |
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
| 15 |
-
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.
|
| 16 |
)
|
| 17 |
|
| 18 |
# Set the scheduler
|
| 19 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
| 20 |
|
| 21 |
-
# Enable optimization for faster generation
|
| 22 |
-
pipe.enable_model_cpu_offload()
|
| 23 |
-
pipe.enable_xformers_memory_efficient_attention()
|
| 24 |
-
|
| 25 |
def process_and_generate(image, prompt, num_inference_steps, guidance_scale):
|
| 26 |
# Convert PIL image to numpy array
|
| 27 |
image = np.array(image)
|
|
|
|
| 7 |
|
| 8 |
# Load ControlNet model
|
| 9 |
controlnet = ControlNetModel.from_pretrained(
|
| 10 |
+
"lllyasviel/sd-controlnet-canny", torch_dtype=torch.float32
|
| 11 |
)
|
| 12 |
|
| 13 |
# Load Stable Diffusion pipeline with ControlNet
|
| 14 |
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
| 15 |
+
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float32
|
| 16 |
)
|
| 17 |
|
| 18 |
# Set the scheduler
|
| 19 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
def process_and_generate(image, prompt, num_inference_steps, guidance_scale):
|
| 22 |
# Convert PIL image to numpy array
|
| 23 |
image = np.array(image)
|