Update README.md
Browse files
README.md
CHANGED
|
@@ -91,6 +91,53 @@ controlnet_strength:1.0
|
|
| 91 |
stargt_percent:0.0
|
| 92 |
end_percent:0.9
|
| 93 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## Checkpoints
|
| 96 |
* mistoLine_rank256.safetensors : General usage version, for ComfyUI and AUTOMATIC1111-WebUI.
|
|
|
|
| 91 |
stargt_percent:0.0
|
| 92 |
end_percent:0.9
|
| 93 |
```
|
| 94 |
+
## Diffusers pipeline
|
| 95 |
+
Make sure to first install the libraries:
|
| 96 |
+
```
|
| 97 |
+
pip install accelerate transformers safetensors opencv-python diffusers
|
| 98 |
+
```
|
| 99 |
+
And then we're ready to go:
|
| 100 |
+
```
|
| 101 |
+
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
|
| 102 |
+
from diffusers.utils import load_image
|
| 103 |
+
from PIL import Image
|
| 104 |
+
import torch
|
| 105 |
+
import numpy as np
|
| 106 |
+
import cv2
|
| 107 |
+
|
| 108 |
+
prompt = "aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"
|
| 109 |
+
negative_prompt = 'low quality, bad quality, sketches'
|
| 110 |
+
|
| 111 |
+
image = load_image("https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")
|
| 112 |
+
|
| 113 |
+
controlnet_conditioning_scale = 0.5
|
| 114 |
+
|
| 115 |
+
controlnet = ControlNetModel.from_pretrained(
|
| 116 |
+
"diffusers/controlnet-canny-sdxl-1.0",
|
| 117 |
+
torch_dtype=torch.float16
|
| 118 |
+
)
|
| 119 |
+
vae = AutoencoderKL.from_pretrained("TheMistoAI/MistoLine", torch_dtype=torch.float16)
|
| 120 |
+
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
| 121 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 122 |
+
controlnet=controlnet,
|
| 123 |
+
vae=vae,
|
| 124 |
+
torch_dtype=torch.float16,
|
| 125 |
+
)
|
| 126 |
+
pipe.enable_model_cpu_offload()
|
| 127 |
+
|
| 128 |
+
image = np.array(image)
|
| 129 |
+
image = cv2.Canny(image, 100, 200)
|
| 130 |
+
image = image[:, :, None]
|
| 131 |
+
image = np.concatenate([image, image, image], axis=2)
|
| 132 |
+
image = Image.fromarray(image)
|
| 133 |
+
|
| 134 |
+
images = pipe(
|
| 135 |
+
prompt, negative_prompt=negative_prompt, image=image, controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 136 |
+
).images
|
| 137 |
+
|
| 138 |
+
images[0].save(f"hug_lab.png")
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
|
| 142 |
## Checkpoints
|
| 143 |
* mistoLine_rank256.safetensors : General usage version, for ComfyUI and AUTOMATIC1111-WebUI.
|