Views
No views yet
softedge | weight-0.6 | weight-0.8 |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
1from diffusers import (
2 ControlNetModel,
3 StableDiffusionXLControlNetPipeline,
4 DPMSolverMultistepScheduler,
5 AutoencoderKL
6)
7from diffusers.utils import load_image
8from controlnet_aux import PidiNetDetector, HEDdetector
9import torch
10from PIL import Image
11
12controlnet = ControlNetModel.from_pretrained(
13 "alimama-creative/EcomXL_controlnet_softedge", torch_dtype=torch.float16, use_safetensors=True
14)
15vae = AutoencoderKL.from_pretrained('madebyollin/sdxl-vae-fp16-fix', torch_dtype=torch.float16)
16pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
17 "stabilityai/stable-diffusion-xl-base-1.0",
18 controlnet=controlnet,
19 vae=vae,
20 torch_dtype=torch.float16
21)
22
23pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
24# pipe.enable_xformers_memory_efficient_attention()
25pipe.to(device="cuda", dtype=torch.float16)
26pipe.enable_vae_slicing()
27
28
29image = load_image(
30 "https://huggingface.co/alimama-creative/EcomXL_controlnet_softedge/resolve/main/images/1_1.png"
31)
32edge_processor = PidiNetDetector.from_pretrained('lllyasviel/Annotators')
33edge_image = edge_processor(image, safe=False) # set True to use pidisafe
34
35prompt="a bottle on the Twilight Grassland, Sitting on the ground, a couple of tall grass sitting in a field of tall grass, sunset,"
36negative_prompt = "low quality, bad quality, sketches"
37
38output = pipe(
39 prompt,
40 negative_prompt=negative_prompt,
41 image=edge_image,
42 num_inference_steps=25,
43 controlnet_conditioning_scale=0.6,
44 guidance_scale=7,
45 width=1024,
46 height=1024,
47).images[0]
48
49output.save(f'test_edge.png')
50