Uploading weights, images and Readme
Browse files- README.md +89 -0
- sd21_encD_canny_14m.ckpt +3 -0
- sd21_encD_depth_14m.ckpt +3 -0
- sdxl_encD_canny_48m.safetensors +3 -0
- sdxl_encD_depth_48m.safetensors +3 -0
README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
| 1 |
---
|
| 2 |
license: openrail
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: openrail
|
| 3 |
---
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
# ControlNet-XS
|
| 7 |
+
|
| 8 |
+

|
| 9 |
+
|
| 10 |
+
These are ControlNet-XS weights trained on [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) and [stabilityai/stable-diffusion-2-1](https://huggingface.co/stabilityai/stable-diffusion-2-1) on edge and depthmap conditioning respectively. You can find more details and further visual examples on the project page [ControlNet-XS](https://vislearn.github.io/ControlNet-XS/).
|
| 11 |
+
|
| 12 |
+
## The codebase
|
| 13 |
+
The code is based on on the StableDiffusion frameworks. To use the ControlNet-XS, you need to access the weights for the StableDiffusion version that you want to control separately.
|
| 14 |
+
We provide the weights with both depth and edge control for StableDiffusion2.1 and StableDiffusion-XL.
|
| 15 |
+
|
| 16 |
+
After obtaining the weights, you need the replace the paths to the weights of StableDiffusion and ControlNet-XS in the config files.
|
| 17 |
+
|
| 18 |
+
## Usage
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
Example for StableDiffusion-XL with Canny Edges
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
import scripts.control_utils as cu
|
| 25 |
+
import matplotlib.pyplot as plt
|
| 26 |
+
import torch
|
| 27 |
+
from PIL import Image
|
| 28 |
+
|
| 29 |
+
path_to_config = 'ControlNet-XS-main/configs/inference/sdxl/sdxl_encD_canny_48m.yaml'
|
| 30 |
+
model = cu.create_model(config_path_depth)
|
| 31 |
+
|
| 32 |
+
image_path = 'PATH/TO/IMAGES/Shoe.png'
|
| 33 |
+
|
| 34 |
+
canny_high_th = 250
|
| 35 |
+
canny_low_th = 100
|
| 36 |
+
size = 768
|
| 37 |
+
num_samples=2
|
| 38 |
+
|
| 39 |
+
image = cu.get_image(image_path, size=size)
|
| 40 |
+
edges = cu.get_canny_edges(image, low_th=canny_low_th, high_th=canny_high_th)
|
| 41 |
+
|
| 42 |
+
samples, controls = cu.get_sdxl_sample(
|
| 43 |
+
guidance=edges,
|
| 44 |
+
ddim_steps=10,
|
| 45 |
+
num_samples=2,
|
| 46 |
+
model=model,
|
| 47 |
+
shape=[4, size // 8, size // 8],
|
| 48 |
+
control_scale=0.95,
|
| 49 |
+
prompt='cinematic, shoe in the streets, made from meat, photorealistic shoe, highly detailed',
|
| 50 |
+
n_prompt='lowres, bad anatomy, worst quality, low quality',
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
Image.fromarray(cu.create_image_grid(samples)).save('SDXL_MyShoe.png')
|
| 55 |
+
```
|
| 56 |
+

|
| 57 |
+
|
| 58 |
+
Example for StableDiffusion2.1 with depth maps
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
import scripts.control_utils as cu
|
| 63 |
+
import matplotlib.pyplot as plt
|
| 64 |
+
import torch
|
| 65 |
+
from PIL import Image
|
| 66 |
+
|
| 67 |
+
path_to_config = 'PATH/TO/CONFIG/sd21_encD_depth_14m.yaml'
|
| 68 |
+
model = cu.create_model(path_to_config)
|
| 69 |
+
|
| 70 |
+
size = 768
|
| 71 |
+
image_path = 'PATH/TO/IMAGES/Shoe.png'
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
image = cu.get_image(image_path, size=size)
|
| 75 |
+
depth = cu.get_midas_depth(image, max_resolution=size)
|
| 76 |
+
num_samples = 2
|
| 77 |
+
|
| 78 |
+
samples, controls = cu.get_sd_sample(
|
| 79 |
+
guidance=depth,
|
| 80 |
+
ddim_steps=10,
|
| 81 |
+
num_samples=num_samples,
|
| 82 |
+
model=model,
|
| 83 |
+
shape=[4, size // 8, size // 8],
|
| 84 |
+
control_scale=0.95,
|
| 85 |
+
prompt='cinematic, advertising shot, shoe in a city street, photorealistic shoe, colourful, highly detailed',
|
| 86 |
+
n_prompt='low quality, bad quality, sketches'
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
Image.fromarray(cu.create_image_grid(samples)).save('SD_MyShoe.png')
|
| 91 |
+
```
|
| 92 |
+

|
sd21_encD_canny_14m.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb0b63002b89247a770da8a534be12ee239d17dac6840eb8d7536cd9d9d1a385
|
| 3 |
+
size 56916738
|
sd21_encD_depth_14m.ckpt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bb6747e7a8c7fd9f7cbf222a537676b8b8ea00c24edc65aeb575385cc642b255
|
| 3 |
+
size 56916738
|
sdxl_encD_canny_48m.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:394eac155a33f9bb3c2d8a419e876cc45ab8662abebdcb08cdb81e3fa7827e39
|
| 3 |
+
size 190796044
|
sdxl_encD_depth_48m.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43be7925d9bff95dae5bbc53109898287f3844d676e74e9ae307cb36cc641151
|
| 3 |
+
size 190796044
|