Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,86 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Pipeline generated with
|
2 |
+
|
3 |
+
```python
|
4 |
+
import torch
|
5 |
+
from diffusers import AutoencoderKL, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler, StableDiffusion3Pipeline
|
6 |
+
from transformers import CLIPTextConfig, CLIPTextModelWithProjection, T5EncoderModel, CLIPTokenizer, AutoTokenizer
|
7 |
+
|
8 |
+
|
9 |
+
def get_dummy_components_sd3():
|
10 |
+
torch.manual_seed(0)
|
11 |
+
transformer = SD3Transformer2DModel(
|
12 |
+
sample_size=32,
|
13 |
+
patch_size=1,
|
14 |
+
in_channels=8,
|
15 |
+
num_layers=4,
|
16 |
+
attention_head_dim=8,
|
17 |
+
num_attention_heads=4,
|
18 |
+
joint_attention_dim=32,
|
19 |
+
caption_projection_dim=32,
|
20 |
+
pooled_projection_dim=64,
|
21 |
+
out_channels=8,
|
22 |
+
)
|
23 |
+
|
24 |
+
torch.manual_seed(0)
|
25 |
+
clip_text_encoder_config = CLIPTextConfig(
|
26 |
+
bos_token_id=0,
|
27 |
+
eos_token_id=2,
|
28 |
+
hidden_size=32,
|
29 |
+
intermediate_size=37,
|
30 |
+
layer_norm_eps=1e-05,
|
31 |
+
num_attention_heads=4,
|
32 |
+
num_hidden_layers=5,
|
33 |
+
pad_token_id=1,
|
34 |
+
vocab_size=1000,
|
35 |
+
hidden_act="gelu",
|
36 |
+
projection_dim=32,
|
37 |
+
)
|
38 |
+
|
39 |
+
torch.manual_seed(0)
|
40 |
+
text_encoder = CLIPTextModelWithProjection(clip_text_encoder_config)
|
41 |
+
|
42 |
+
torch.manual_seed(0)
|
43 |
+
text_encoder_2 = CLIPTextModelWithProjection(clip_text_encoder_config)
|
44 |
+
|
45 |
+
torch.manual_seed(0)
|
46 |
+
text_encoder_3 = T5EncoderModel.from_pretrained("./tiny-random-t5")
|
47 |
+
|
48 |
+
tokenizer = CLIPTokenizer.from_pretrained("./tiny-random-clip")
|
49 |
+
tokenizer_2 = CLIPTokenizer.from_pretrained("./tiny-random-clip")
|
50 |
+
tokenizer_3 = AutoTokenizer.from_pretrained("./tiny-random-t5")
|
51 |
+
|
52 |
+
torch.manual_seed(0)
|
53 |
+
vae = AutoencoderKL(
|
54 |
+
sample_size=32,
|
55 |
+
in_channels=3,
|
56 |
+
out_channels=3,
|
57 |
+
block_out_channels=(4,),
|
58 |
+
layers_per_block=1,
|
59 |
+
latent_channels=8,
|
60 |
+
norm_num_groups=1,
|
61 |
+
use_quant_conv=False,
|
62 |
+
use_post_quant_conv=False,
|
63 |
+
shift_factor=0.0609,
|
64 |
+
scaling_factor=1.5035,
|
65 |
+
)
|
66 |
+
|
67 |
+
scheduler = FlowMatchEulerDiscreteScheduler()
|
68 |
+
|
69 |
+
return {
|
70 |
+
"scheduler": scheduler,
|
71 |
+
"text_encoder": text_encoder,
|
72 |
+
"text_encoder_2": text_encoder_2,
|
73 |
+
"text_encoder_3": text_encoder_3,
|
74 |
+
"tokenizer": tokenizer,
|
75 |
+
"tokenizer_2": tokenizer_2,
|
76 |
+
"tokenizer_3": tokenizer_3,
|
77 |
+
"transformer": transformer,
|
78 |
+
"vae": vae,
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
if __name__ == "__main__":
|
83 |
+
components = get_dummy_components_sd3()
|
84 |
+
pipeline = StableDiffusion3Pipeline(**components)
|
85 |
+
pipeline.push_to_hub("DavyMorgan/tiny-sd3-pipe")
|
86 |
+
```
|