Artiprocher commited on
Commit
32aa1f1
·
1 Parent(s): 072cb3e

update model

Browse files
Files changed (3) hide show
  1. README.md +40 -0
  2. config.json +41 -0
  3. diffusion_pytorch_model.bin +3 -0
README.md CHANGED
@@ -1,3 +1,43 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ tags:
4
+ - pytorch
5
+ - diffusers
6
+ - text-to-image
7
  ---
8
+
9
+ # Chinese Latent Diffusion Model
10
+
11
+ 我们开源了适配模型 `alibaba-pai/pai-diffusion-general-large-zh` 的 ControlNet,输入图像的 Canny 特征,进行可控的生成。
12
+
13
+ * Github: [EasyNLP](https://github.com/alibaba/EasyNLP)
14
+
15
+ ```python
16
+ from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
17
+ from PIL import Image
18
+ import numpy as np
19
+ import cv2
20
+
21
+
22
+ def to_canny(image):
23
+ low_threshold = 100
24
+ high_threshold = 200
25
+ image = np.array(image)
26
+ image = cv2.Canny(image, low_threshold, high_threshold)
27
+ image = image[:, :, None]
28
+ image = np.concatenate([image, image, image], axis=2)
29
+ image = Image.fromarray(image)
30
+ return image
31
+
32
+ controlnet_id = "alibaba-pai/pai-diffusion-general-large-zh-controlnet-canny"
33
+ controlnet = ControlNetModel.from_pretrained(controlnet_id)
34
+ model_id = "alibaba-pai/pai-diffusion-general-large-zh"
35
+ pipe = StableDiffusionControlNetPipeline.from_pretrained(model_id, controlnet=controlnet)
36
+ pipe = pipe.to("cuda")
37
+
38
+ image = Image.open("bird.png")
39
+ image_canny = to_canny(image)
40
+ prompt = "白色羽毛的小鸟"
41
+ image = pipe(prompt, image_canny).images[0]
42
+ image.save("result.png")
43
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "ControlNetModel",
3
+ "_diffusers_version": "0.15.0.dev0",
4
+ "act_fn": "silu",
5
+ "attention_head_dim": 8,
6
+ "block_out_channels": [
7
+ 320,
8
+ 640,
9
+ 1280,
10
+ 1280
11
+ ],
12
+ "class_embed_type": null,
13
+ "conditioning_embedding_out_channels": [
14
+ 16,
15
+ 32,
16
+ 96,
17
+ 256
18
+ ],
19
+ "controlnet_conditioning_channel_order": "rgb",
20
+ "cross_attention_dim": 768,
21
+ "down_block_types": [
22
+ "CrossAttnDownBlock2D",
23
+ "CrossAttnDownBlock2D",
24
+ "CrossAttnDownBlock2D",
25
+ "DownBlock2D"
26
+ ],
27
+ "downsample_padding": 1,
28
+ "flip_sin_to_cos": true,
29
+ "freq_shift": 0,
30
+ "in_channels": 4,
31
+ "layers_per_block": 2,
32
+ "mid_block_scale_factor": 1,
33
+ "norm_eps": 1e-05,
34
+ "norm_num_groups": 32,
35
+ "num_class_embeds": null,
36
+ "only_cross_attention": false,
37
+ "projection_class_embeddings_input_dim": null,
38
+ "resnet_time_scale_shift": "default",
39
+ "upcast_attention": false,
40
+ "use_linear_projection": false
41
+ }
diffusion_pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1eaf3fbae4cdb6c2ab909c12c85b5aa695a7b58157903730ab0fa74b8a0142a7
3
+ size 1445248857