Add Diffusers weights
#6
by
patrickvonplaten
- opened
- README.md +39 -0
- config.json +47 -0
- diffusion_pytorch_model.bin +3 -0
- diffusion_pytorch_model.fp16.bin +3 -0
- diffusion_pytorch_model.fp16.safetensors +3 -0
- diffusion_pytorch_model.safetensors +3 -0
README.md
CHANGED
@@ -8,6 +8,7 @@ tags:
|
|
8 |
- face
|
9 |
- mediapipe
|
10 |
license: "openrail"
|
|
|
11 |
datasets:
|
12 |
- LAION-Face
|
13 |
- LAION
|
@@ -110,6 +111,44 @@ model.load_state_dict(load_state_dict('./models/control_sd21_openpose.pth', loca
|
|
110 |
|
111 |
The model has some limitations: while it is empirically better at tracking gaze and mouth poses than previous attempts, it may still ignore controls. Adding details to the prompt like, "looking right" can abate bad behavior.
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
# License:
|
115 |
|
|
|
8 |
- face
|
9 |
- mediapipe
|
10 |
license: "openrail"
|
11 |
+
base_model: stabilityai/stable-diffusion-2-1-base
|
12 |
datasets:
|
13 |
- LAION-Face
|
14 |
- LAION
|
|
|
111 |
|
112 |
The model has some limitations: while it is empirically better at tracking gaze and mouth poses than previous attempts, it may still ignore controls. Adding details to the prompt like, "looking right" can abate bad behavior.
|
113 |
|
114 |
+
## 🧨 Diffusers
|
115 |
+
|
116 |
+
It is recommended to use the checkpoint with [Stable Diffusion 2.1 - Base](stabilityai/stable-diffusion-2-1-base) as the checkpoint has been trained on it.
|
117 |
+
Experimentally, the checkpoint can be used with other diffusion models such as dreamboothed stable diffusion.
|
118 |
+
|
119 |
+
1. Let's install `diffusers` and related packages:
|
120 |
+
```
|
121 |
+
$ pip install diffusers transformers accelerate
|
122 |
+
```
|
123 |
+
|
124 |
+
2. Run code:
|
125 |
+
```py
|
126 |
+
from PIL import Image
|
127 |
+
import numpy as np
|
128 |
+
import torch
|
129 |
+
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
|
130 |
+
from diffusers.utils import load_image
|
131 |
+
|
132 |
+
image = load_image(
|
133 |
+
"https://huggingface.co/CrucibleAI/ControlNetMediaPipeFace/resolve/main/samples_laion_face_dataset/family_annotation.png"
|
134 |
+
)
|
135 |
+
|
136 |
+
controlnet = ControlNetModel.from_pretrained("CrucibleAI/ControlNetMediaPipeFace", torch_dtype=torch.float16, variant="fp16")
|
137 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
138 |
+
"stabilityai/stable-diffusion-2-1-base", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16
|
139 |
+
)
|
140 |
+
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
141 |
+
|
142 |
+
# Remove if you do not have xformers installed
|
143 |
+
# see https://huggingface.co/docs/diffusers/v0.13.0/en/optimization/xformers#installing-xformers
|
144 |
+
# for installation instructions
|
145 |
+
pipe.enable_xformers_memory_efficient_attention()
|
146 |
+
pipe.enable_model_cpu_offload()
|
147 |
+
|
148 |
+
image = pipe("a happy family at a dentist advertisement", image=image, num_inference_steps=30).images[0]
|
149 |
+
image.save('./images.png')
|
150 |
+
```
|
151 |
+
|
152 |
|
153 |
# License:
|
154 |
|
config.json
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "ControlNetModel",
|
3 |
+
"_diffusers_version": "0.15.0.dev0",
|
4 |
+
"_name_or_path": "/home/patrick_huggingface_co/temp_control",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"attention_head_dim": [
|
7 |
+
5,
|
8 |
+
10,
|
9 |
+
20,
|
10 |
+
20
|
11 |
+
],
|
12 |
+
"block_out_channels": [
|
13 |
+
320,
|
14 |
+
640,
|
15 |
+
1280,
|
16 |
+
1280
|
17 |
+
],
|
18 |
+
"class_embed_type": null,
|
19 |
+
"conditioning_embedding_out_channels": [
|
20 |
+
16,
|
21 |
+
32,
|
22 |
+
96,
|
23 |
+
256
|
24 |
+
],
|
25 |
+
"controlnet_conditioning_channel_order": "rgb",
|
26 |
+
"cross_attention_dim": 1024,
|
27 |
+
"down_block_types": [
|
28 |
+
"CrossAttnDownBlock2D",
|
29 |
+
"CrossAttnDownBlock2D",
|
30 |
+
"CrossAttnDownBlock2D",
|
31 |
+
"DownBlock2D"
|
32 |
+
],
|
33 |
+
"downsample_padding": 1,
|
34 |
+
"flip_sin_to_cos": true,
|
35 |
+
"freq_shift": 0,
|
36 |
+
"in_channels": 4,
|
37 |
+
"layers_per_block": 2,
|
38 |
+
"mid_block_scale_factor": 1,
|
39 |
+
"norm_eps": 1e-05,
|
40 |
+
"norm_num_groups": 32,
|
41 |
+
"num_class_embeds": null,
|
42 |
+
"only_cross_attention": false,
|
43 |
+
"projection_class_embeddings_input_dim": null,
|
44 |
+
"resnet_time_scale_shift": "default",
|
45 |
+
"upcast_attention": false,
|
46 |
+
"use_linear_projection": true
|
47 |
+
}
|
diffusion_pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:36dcd318d499df44b35432599a1b70f598e7bb42b479e4e67d4adf7b7e87e87d
|
3 |
+
size 1457051321
|
diffusion_pytorch_model.fp16.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f70c38860e0d1fcd0f5ed38bc34e61c7337b9001bed57f7bff6eba6471406f0
|
3 |
+
size 728596455
|
diffusion_pytorch_model.fp16.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:02b3a8e04154b4c3d11f5210217f0dbf3fac8612d62d015cd059f2b9fe4c3364
|
3 |
+
size 728496846
|
diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a683e98e2427fd6242edc9af6620708f2f8fc84bfc049fafe549e350f8d42d73
|
3 |
+
size 1456953564
|