Upload 13 files
Browse files- model_index.json +6 -1
- pipeline.py +7 -7
- unet/config.json +68 -0
- unet/diffusion_pytorch_model.safetensors +3 -0
model_index.json
CHANGED
@@ -6,5 +6,10 @@
|
|
6 |
"guidance_scale": null,
|
7 |
"lift": null,
|
8 |
"num_inference_steps": null,
|
9 |
-
"
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
|
|
6 |
"guidance_scale": null,
|
7 |
"lift": null,
|
8 |
"num_inference_steps": null,
|
9 |
+
"scheduler": "EulerDiscreteScheduler",
|
10 |
+
"seed": null,
|
11 |
+
"text_encoder": "CLIPTextModel",
|
12 |
+
"tokenizer": "CLIPTokenizer",
|
13 |
+
"unet": "UNet2DConditionModel",
|
14 |
+
"vae": "AutoencoderKL"
|
15 |
}
|
pipeline.py
CHANGED
@@ -9,13 +9,13 @@ from diffusers.configuration_utils import ConfigMixin
|
|
9 |
class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
10 |
"""SuperDiffPipeline."""
|
11 |
|
12 |
-
def __init__(self,
|
13 |
"""__init__.
|
14 |
|
15 |
Parameters
|
16 |
----------
|
17 |
-
|
18 |
-
|
19 |
vae : Callable
|
20 |
vae
|
21 |
text_encoder : Callable
|
@@ -33,7 +33,7 @@ class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
|
33 |
|
34 |
"""
|
35 |
super().__init__()
|
36 |
-
self.
|
37 |
self.vae = vae
|
38 |
self.text_encoder = text_encoder
|
39 |
self.tokenizer = tokenizer
|
@@ -42,7 +42,7 @@ class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
|
42 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
43 |
|
44 |
self.vae.to(device)
|
45 |
-
self.
|
46 |
self.text_encoder.to(device)
|
47 |
|
48 |
self.register_to_config(
|
@@ -124,7 +124,7 @@ class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
|
124 |
embeddings : Callable
|
125 |
embeddings
|
126 |
"""
|
127 |
-
def v(_x, _e): return self.
|
128 |
_x / ((sigma**2 + 1) ** 0.5), t, encoder_hidden_states=_e
|
129 |
).sample
|
130 |
embeds = torch.cat(embeddings)
|
@@ -191,7 +191,7 @@ class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
|
191 |
self.seed
|
192 |
) # Seed generator to create the initial latent noise
|
193 |
latents = torch.randn(
|
194 |
-
(batch_size, self.
|
195 |
generator=generator,
|
196 |
device=self.device,
|
197 |
)
|
|
|
9 |
class SuperDiffPipeline(DiffusionPipeline, ConfigMixin):
|
10 |
"""SuperDiffPipeline."""
|
11 |
|
12 |
+
def __init__(self, unet: Callable, vae: Callable, text_encoder: Callable, scheduler: Callable, tokenizer: Callable, **kwargs) -> None:
|
13 |
"""__init__.
|
14 |
|
15 |
Parameters
|
16 |
----------
|
17 |
+
unet : Callable
|
18 |
+
unet
|
19 |
vae : Callable
|
20 |
vae
|
21 |
text_encoder : Callable
|
|
|
33 |
|
34 |
"""
|
35 |
super().__init__()
|
36 |
+
self.unet = unet
|
37 |
self.vae = vae
|
38 |
self.text_encoder = text_encoder
|
39 |
self.tokenizer = tokenizer
|
|
|
42 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
43 |
|
44 |
self.vae.to(device)
|
45 |
+
self.unet.to(device)
|
46 |
self.text_encoder.to(device)
|
47 |
|
48 |
self.register_to_config(
|
|
|
124 |
embeddings : Callable
|
125 |
embeddings
|
126 |
"""
|
127 |
+
def v(_x, _e): return self.unet(
|
128 |
_x / ((sigma**2 + 1) ** 0.5), t, encoder_hidden_states=_e
|
129 |
).sample
|
130 |
embeds = torch.cat(embeddings)
|
|
|
191 |
self.seed
|
192 |
) # Seed generator to create the initial latent noise
|
193 |
latents = torch.randn(
|
194 |
+
(batch_size, self.unet.config.in_channels, height // 8, width // 8),
|
195 |
generator=generator,
|
196 |
device=self.device,
|
197 |
)
|
unet/config.json
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.31.0",
|
4 |
+
"_name_or_path": "CompVis/stable-diffusion-v1-4",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"addition_embed_type": null,
|
7 |
+
"addition_embed_type_num_heads": 64,
|
8 |
+
"addition_time_embed_dim": null,
|
9 |
+
"attention_head_dim": 8,
|
10 |
+
"attention_type": "default",
|
11 |
+
"block_out_channels": [
|
12 |
+
320,
|
13 |
+
640,
|
14 |
+
1280,
|
15 |
+
1280
|
16 |
+
],
|
17 |
+
"center_input_sample": false,
|
18 |
+
"class_embed_type": null,
|
19 |
+
"class_embeddings_concat": false,
|
20 |
+
"conv_in_kernel": 3,
|
21 |
+
"conv_out_kernel": 3,
|
22 |
+
"cross_attention_dim": 768,
|
23 |
+
"cross_attention_norm": null,
|
24 |
+
"down_block_types": [
|
25 |
+
"CrossAttnDownBlock2D",
|
26 |
+
"CrossAttnDownBlock2D",
|
27 |
+
"CrossAttnDownBlock2D",
|
28 |
+
"DownBlock2D"
|
29 |
+
],
|
30 |
+
"downsample_padding": 1,
|
31 |
+
"dropout": 0.0,
|
32 |
+
"dual_cross_attention": false,
|
33 |
+
"encoder_hid_dim": null,
|
34 |
+
"encoder_hid_dim_type": null,
|
35 |
+
"flip_sin_to_cos": true,
|
36 |
+
"freq_shift": 0,
|
37 |
+
"in_channels": 4,
|
38 |
+
"layers_per_block": 2,
|
39 |
+
"mid_block_only_cross_attention": null,
|
40 |
+
"mid_block_scale_factor": 1,
|
41 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
42 |
+
"norm_eps": 1e-05,
|
43 |
+
"norm_num_groups": 32,
|
44 |
+
"num_attention_heads": null,
|
45 |
+
"num_class_embeds": null,
|
46 |
+
"only_cross_attention": false,
|
47 |
+
"out_channels": 4,
|
48 |
+
"projection_class_embeddings_input_dim": null,
|
49 |
+
"resnet_out_scale_factor": 1.0,
|
50 |
+
"resnet_skip_time_act": false,
|
51 |
+
"resnet_time_scale_shift": "default",
|
52 |
+
"reverse_transformer_layers_per_block": null,
|
53 |
+
"sample_size": 64,
|
54 |
+
"time_cond_proj_dim": null,
|
55 |
+
"time_embedding_act_fn": null,
|
56 |
+
"time_embedding_dim": null,
|
57 |
+
"time_embedding_type": "positional",
|
58 |
+
"timestep_post_act": null,
|
59 |
+
"transformer_layers_per_block": 1,
|
60 |
+
"up_block_types": [
|
61 |
+
"UpBlock2D",
|
62 |
+
"CrossAttnUpBlock2D",
|
63 |
+
"CrossAttnUpBlock2D",
|
64 |
+
"CrossAttnUpBlock2D"
|
65 |
+
],
|
66 |
+
"upcast_attention": false,
|
67 |
+
"use_linear_projection": false
|
68 |
+
}
|
unet/diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d54d1800033f872c2ede03a45de06d176a53146e43bc9bdb81b0429560a07dc9
|
3 |
+
size 3438167536
|