badaoui HF Staff commited on
Commit
c4271d6
·
verified ·
1 Parent(s): b0b1de3

Add Neuron-optimized files for CompVis/stable-diffusion-v1-4

Browse files

🤖 Neuron Export Bot: Adding AWS Neuron-optimized model files.

Original model: [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4)
Task: text-to-image
Generated by: [badaoui](https://huggingface.co/badaoui)
Generated using: [Optimum Neuron Compiler Space](https://huggingface.co/spaces/optimum/neuron-export)

These files have been pre-compiled for AWS Neuron devices (Inferentia/Trainium) and should provide improved inference performance.

.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ text_encoder/model.neuron filter=lfs diff=lfs merge=lfs -text
37
+ unet/model.neuron filter=lfs diff=lfs merge=lfs -text
38
+ vae_encoder/model.neuron filter=lfs diff=lfs merge=lfs -text
39
+ vae_decoder/model.neuron filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - neuron
4
+ - optimized
5
+ - aws-neuron
6
+ - text-to-image
7
+ base_model: CompVis/stable-diffusion-v1-4
8
+ ---
9
+
10
+ # Neuron-Optimized CompVis/stable-diffusion-v1-4
11
+
12
+ This repository contains AWS Neuron-optimized files for [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4).
13
+
14
+ ## Model Details
15
+
16
+ - **Base Model**: [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4)
17
+ - **Task**: text-to-image
18
+ - **Optimization**: AWS Neuron compilation
19
+ - **Generated by**: [badaoui](https://huggingface.co/badaoui)
20
+ - **Generated using**: [Optimum Neuron Compiler Space](https://huggingface.co/spaces/optimum/neuron-export)
21
+
22
+ ## Usage
23
+
24
+ This model has been optimized for AWS Neuron devices (Inferentia/Trainium). To use it:
25
+
26
+ ```python
27
+ from optimum.neuron import NeuronStableDiffusionPipeline
28
+
29
+ model = NeuronStableDiffusionPipeline.from_pretrained("badaoui/CompVis-stable-diffusion-v1-4-neuron")
30
+ ```
31
+
32
+ ## Performance
33
+
34
+ These files are pre-compiled for AWS Neuron devices and should provide improved inference performance compared to the original model when deployed on Inferentia or Trainium instances.
35
+
36
+ ## Original Model
37
+
38
+ For the original model, training details, and more information, please visit: [CompVis/stable-diffusion-v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4)
feature_extractor/preprocessor_config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": 224,
4
+ "width": 224
5
+ },
6
+ "do_center_crop": true,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_rescale": true,
10
+ "do_resize": true,
11
+ "image_mean": [
12
+ 0.48145466,
13
+ 0.4578275,
14
+ 0.40821073
15
+ ],
16
+ "image_processor_type": "CLIPImageProcessor",
17
+ "image_std": [
18
+ 0.26862954,
19
+ 0.26130258,
20
+ 0.27577711
21
+ ],
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "shortest_edge": 224
26
+ }
27
+ }
model_index.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "StableDiffusionPipeline",
3
+ "_diffusers_version": "0.34.0",
4
+ "_name_or_path": "CompVis/stable-diffusion-v1-4",
5
+ "feature_extractor": [
6
+ "transformers",
7
+ "CLIPImageProcessor"
8
+ ],
9
+ "image_encoder": [
10
+ null,
11
+ null
12
+ ],
13
+ "requires_safety_checker": true,
14
+ "safety_checker": [
15
+ "stable_diffusion",
16
+ "StableDiffusionSafetyChecker"
17
+ ],
18
+ "scheduler": [
19
+ "diffusers",
20
+ "PNDMScheduler"
21
+ ],
22
+ "text_encoder": [
23
+ "transformers",
24
+ "CLIPTextModel"
25
+ ],
26
+ "tokenizer": [
27
+ "transformers",
28
+ "CLIPTokenizer"
29
+ ],
30
+ "unet": [
31
+ "diffusers",
32
+ "UNet2DConditionModel"
33
+ ],
34
+ "vae": [
35
+ "diffusers",
36
+ "AutoencoderKL"
37
+ ]
38
+ }
scheduler/scheduler_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "PNDMScheduler",
3
+ "_diffusers_version": "0.34.0",
4
+ "beta_end": 0.012,
5
+ "beta_schedule": "scaled_linear",
6
+ "beta_start": 0.00085,
7
+ "clip_sample": false,
8
+ "num_train_timesteps": 1000,
9
+ "prediction_type": "epsilon",
10
+ "set_alpha_to_one": false,
11
+ "skip_prk_steps": true,
12
+ "steps_offset": 1,
13
+ "timestep_spacing": "leading",
14
+ "trained_betas": null
15
+ }
text_encoder/config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_attn_implementation_autoset": true,
3
+ "architectures": [
4
+ "CLIPTextModel"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dropout": 0.0,
9
+ "eos_token_id": 2,
10
+ "export_model_type": "clip-text-model",
11
+ "hidden_act": "quick_gelu",
12
+ "hidden_size": 768,
13
+ "initializer_factor": 1.0,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 77,
18
+ "model_type": "clip_text_model",
19
+ "neuron": {
20
+ "auto_cast": "matmul",
21
+ "auto_cast_type": "bf16",
22
+ "compiler_type": "neuronx-cc",
23
+ "compiler_version": "2.19.8089.0+8ab9f450",
24
+ "dynamic_batch_size": false,
25
+ "inline_weights_to_neff": true,
26
+ "input_names": [
27
+ "input_ids"
28
+ ],
29
+ "model_type": "clip-text-model",
30
+ "optlevel": "2",
31
+ "output_attentions": false,
32
+ "output_hidden_states": false,
33
+ "output_names": [
34
+ "last_hidden_state",
35
+ "pooler_output"
36
+ ],
37
+ "static_batch_size": 1,
38
+ "static_sequence_length": 77,
39
+ "task": "feature-extraction",
40
+ "tensor_parallel_size": 1
41
+ },
42
+ "num_attention_heads": 12,
43
+ "num_hidden_layers": 12,
44
+ "pad_token_id": 1,
45
+ "projection_dim": 512,
46
+ "torch_dtype": "bfloat16",
47
+ "torchscript": true,
48
+ "transformers_version": "4.51.3",
49
+ "vocab_size": 49408
50
+ }
text_encoder/model.neuron ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd18698495540c1ec851f8bdda03c6d0d8be0c6673c2c272516bb0402806a767
3
+ size 307198263
tokenizer/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer/special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "49406": {
5
+ "content": "<|startoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "49407": {
13
+ "content": "<|endoftext|>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ }
20
+ },
21
+ "bos_token": "<|startoftext|>",
22
+ "clean_up_tokenization_spaces": false,
23
+ "do_lower_case": true,
24
+ "eos_token": "<|endoftext|>",
25
+ "errors": "replace",
26
+ "extra_special_tokens": {},
27
+ "model_max_length": 77,
28
+ "pad_token": "<|endoftext|>",
29
+ "tokenizer_class": "CLIPTokenizer",
30
+ "unk_token": "<|endoftext|>"
31
+ }
tokenizer/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
unet/config.json ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "UNet2DConditionModel",
3
+ "_commit_hash": null,
4
+ "_diffusers_version": "0.34.0",
5
+ "_use_default_values": [
6
+ "use_linear_projection",
7
+ "transformer_layers_per_block",
8
+ "resnet_out_scale_factor",
9
+ "time_embedding_act_fn",
10
+ "timestep_post_act",
11
+ "num_attention_heads",
12
+ "encoder_hid_dim_type",
13
+ "dual_cross_attention",
14
+ "num_class_embeds",
15
+ "reverse_transformer_layers_per_block",
16
+ "addition_time_embed_dim",
17
+ "time_embedding_dim",
18
+ "attention_type",
19
+ "dropout",
20
+ "resnet_skip_time_act",
21
+ "resnet_time_scale_shift",
22
+ "class_embeddings_concat",
23
+ "conv_in_kernel",
24
+ "conv_out_kernel",
25
+ "mid_block_type",
26
+ "addition_embed_type",
27
+ "only_cross_attention",
28
+ "encoder_hid_dim",
29
+ "projection_class_embeddings_input_dim",
30
+ "cross_attention_norm",
31
+ "time_embedding_type",
32
+ "time_cond_proj_dim",
33
+ "upcast_attention",
34
+ "addition_embed_type_num_heads",
35
+ "mid_block_only_cross_attention",
36
+ "class_embed_type"
37
+ ],
38
+ "act_fn": "silu",
39
+ "addition_embed_type": null,
40
+ "addition_embed_type_num_heads": 64,
41
+ "addition_time_embed_dim": null,
42
+ "attention_head_dim": 8,
43
+ "attention_type": "default",
44
+ "block_out_channels": [
45
+ 320,
46
+ 640,
47
+ 1280,
48
+ 1280
49
+ ],
50
+ "center_input_sample": false,
51
+ "class_embed_type": null,
52
+ "class_embeddings_concat": false,
53
+ "conv_in_kernel": 3,
54
+ "conv_out_kernel": 3,
55
+ "cross_attention_dim": 768,
56
+ "cross_attention_norm": null,
57
+ "down_block_types": [
58
+ "CrossAttnDownBlock2D",
59
+ "CrossAttnDownBlock2D",
60
+ "CrossAttnDownBlock2D",
61
+ "DownBlock2D"
62
+ ],
63
+ "downsample_padding": 1,
64
+ "dropout": 0.0,
65
+ "dual_cross_attention": false,
66
+ "encoder_hid_dim": null,
67
+ "encoder_hid_dim_type": null,
68
+ "flip_sin_to_cos": true,
69
+ "freq_shift": 0,
70
+ "in_channels": 4,
71
+ "layers_per_block": 2,
72
+ "mid_block_only_cross_attention": null,
73
+ "mid_block_scale_factor": 1,
74
+ "mid_block_type": "UNetMidBlock2DCrossAttn",
75
+ "neuron": {
76
+ "auto_cast": "matmul",
77
+ "auto_cast_type": "bf16",
78
+ "compiler_type": "neuronx-cc",
79
+ "compiler_version": "2.19.8089.0+8ab9f450",
80
+ "dynamic_batch_size": false,
81
+ "inline_weights_to_neff": true,
82
+ "input_names": [
83
+ "sample",
84
+ "timestep",
85
+ "encoder_hidden_states"
86
+ ],
87
+ "model_type": "unet",
88
+ "optlevel": "2",
89
+ "output_attentions": false,
90
+ "output_hidden_states": false,
91
+ "output_names": [
92
+ "sample"
93
+ ],
94
+ "static_batch_size": 1,
95
+ "static_height": 128,
96
+ "static_num_channels": 4,
97
+ "static_sequence_length": 77,
98
+ "static_vae_scale_factor": 8,
99
+ "static_width": 128,
100
+ "task": "semantic-segmentation",
101
+ "tensor_parallel_size": 1
102
+ },
103
+ "norm_eps": 1e-05,
104
+ "norm_num_groups": 32,
105
+ "num_attention_heads": null,
106
+ "num_class_embeds": null,
107
+ "only_cross_attention": false,
108
+ "out_channels": 4,
109
+ "projection_class_embeddings_input_dim": null,
110
+ "resnet_out_scale_factor": 1.0,
111
+ "resnet_skip_time_act": false,
112
+ "resnet_time_scale_shift": "default",
113
+ "reverse_transformer_layers_per_block": null,
114
+ "sample_size": 64,
115
+ "time_cond_proj_dim": null,
116
+ "time_embedding_act_fn": null,
117
+ "time_embedding_dim": null,
118
+ "time_embedding_type": "positional",
119
+ "timestep_post_act": null,
120
+ "transformer_layers_per_block": 1,
121
+ "transformers_version": null,
122
+ "up_block_types": [
123
+ "UpBlock2D",
124
+ "CrossAttnUpBlock2D",
125
+ "CrossAttnUpBlock2D",
126
+ "CrossAttnUpBlock2D"
127
+ ],
128
+ "upcast_attention": false,
129
+ "use_linear_projection": false
130
+ }
unet/model.neuron ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:609aed6600c12d5840fe6ea57e213358339e568860b06d8280402426e681c303
3
+ size 2853990707
vae_decoder/config.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKL",
3
+ "_commit_hash": null,
4
+ "_diffusers_version": "0.34.0",
5
+ "_use_default_values": [
6
+ "latents_mean",
7
+ "use_post_quant_conv",
8
+ "norm_num_groups",
9
+ "use_quant_conv",
10
+ "mid_block_add_attention",
11
+ "shift_factor",
12
+ "latents_std",
13
+ "force_upcast"
14
+ ],
15
+ "act_fn": "silu",
16
+ "block_out_channels": [
17
+ 128,
18
+ 256,
19
+ 512,
20
+ 512
21
+ ],
22
+ "down_block_types": [
23
+ "DownEncoderBlock2D",
24
+ "DownEncoderBlock2D",
25
+ "DownEncoderBlock2D",
26
+ "DownEncoderBlock2D"
27
+ ],
28
+ "force_upcast": true,
29
+ "in_channels": 3,
30
+ "latent_channels": 4,
31
+ "latents_mean": null,
32
+ "latents_std": null,
33
+ "layers_per_block": 2,
34
+ "mid_block_add_attention": true,
35
+ "neuron": {
36
+ "auto_cast": "matmul",
37
+ "auto_cast_type": "bf16",
38
+ "compiler_type": "neuronx-cc",
39
+ "compiler_version": "2.19.8089.0+8ab9f450",
40
+ "dynamic_batch_size": false,
41
+ "inline_weights_to_neff": true,
42
+ "input_names": [
43
+ "latent_sample"
44
+ ],
45
+ "model_type": "vae-decoder",
46
+ "optlevel": "2",
47
+ "output_attentions": false,
48
+ "output_hidden_states": false,
49
+ "output_names": [
50
+ "sample"
51
+ ],
52
+ "static_batch_size": 1,
53
+ "static_height": 128,
54
+ "static_num_channels": 4,
55
+ "static_width": 128,
56
+ "task": "semantic-segmentation",
57
+ "tensor_parallel_size": 1
58
+ },
59
+ "norm_num_groups": 32,
60
+ "out_channels": 3,
61
+ "sample_size": 512,
62
+ "scaling_factor": 0.18215,
63
+ "shift_factor": null,
64
+ "transformers_version": null,
65
+ "up_block_types": [
66
+ "UpDecoderBlock2D",
67
+ "UpDecoderBlock2D",
68
+ "UpDecoderBlock2D",
69
+ "UpDecoderBlock2D"
70
+ ],
71
+ "use_post_quant_conv": true,
72
+ "use_quant_conv": true
73
+ }
vae_decoder/model.neuron ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46e461b9cd7437ebfb2c04a4b3f1d823b180f6e7faaa32f9701d38427d92035d
3
+ size 370909619
vae_encoder/config.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKL",
3
+ "_commit_hash": null,
4
+ "_diffusers_version": "0.34.0",
5
+ "_use_default_values": [
6
+ "latents_mean",
7
+ "use_post_quant_conv",
8
+ "norm_num_groups",
9
+ "use_quant_conv",
10
+ "mid_block_add_attention",
11
+ "shift_factor",
12
+ "latents_std",
13
+ "force_upcast"
14
+ ],
15
+ "act_fn": "silu",
16
+ "block_out_channels": [
17
+ 128,
18
+ 256,
19
+ 512,
20
+ 512
21
+ ],
22
+ "down_block_types": [
23
+ "DownEncoderBlock2D",
24
+ "DownEncoderBlock2D",
25
+ "DownEncoderBlock2D",
26
+ "DownEncoderBlock2D"
27
+ ],
28
+ "force_upcast": true,
29
+ "in_channels": 3,
30
+ "latent_channels": 4,
31
+ "latents_mean": null,
32
+ "latents_std": null,
33
+ "layers_per_block": 2,
34
+ "mid_block_add_attention": true,
35
+ "neuron": {
36
+ "auto_cast": "matmul",
37
+ "auto_cast_type": "bf16",
38
+ "compiler_type": "neuronx-cc",
39
+ "compiler_version": "2.19.8089.0+8ab9f450",
40
+ "dynamic_batch_size": false,
41
+ "inline_weights_to_neff": true,
42
+ "input_names": [
43
+ "sample"
44
+ ],
45
+ "model_type": "vae-encoder",
46
+ "optlevel": "2",
47
+ "output_attentions": false,
48
+ "output_hidden_states": false,
49
+ "output_names": [
50
+ "latent_parameters"
51
+ ],
52
+ "static_batch_size": 1,
53
+ "static_height": 1024,
54
+ "static_num_channels": 3,
55
+ "static_width": 1024,
56
+ "task": "semantic-segmentation",
57
+ "tensor_parallel_size": 1
58
+ },
59
+ "norm_num_groups": 32,
60
+ "out_channels": 3,
61
+ "sample_size": 512,
62
+ "scaling_factor": 0.18215,
63
+ "shift_factor": null,
64
+ "transformers_version": null,
65
+ "up_block_types": [
66
+ "UpDecoderBlock2D",
67
+ "UpDecoderBlock2D",
68
+ "UpDecoderBlock2D",
69
+ "UpDecoderBlock2D"
70
+ ],
71
+ "use_post_quant_conv": true,
72
+ "use_quant_conv": true
73
+ }
vae_encoder/model.neuron ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4196c2f2b11b15c0ce566cd2bf19b2be5ad4b99d14f84de9b140279e006e185f
3
+ size 222985073