patrickvonplaten ayushtues commited on
Commit
b7479a7
0 Parent(s):

Duplicate from ayushtues/blipdiffusion

Browse files

Co-authored-by: Ayush Mangal <ayushtues@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: diffusers
6
+ ---
7
+ # BLIP-Diffusion: Pre-trained Subject Representation for Controllable Text-to-Image Generation and Editing
8
+
9
+
10
+ <!-- Provide a quick summary of what the model is/does. -->
11
+
12
+ Model card for BLIP-Diffusion, a text to image Diffusion model which enables zero-shot subject-driven generation and control-guided zero-shot generation.
13
+
14
+ The abstract from the paper is:
15
+
16
+ *Subject-driven text-to-image generation models create novel renditions of an input subject based on text prompts. Existing models suffer from lengthy fine-tuning and difficulties preserving the subject fidelity. To overcome these limitations, we introduce BLIP-Diffusion, a new subject-driven image generation model that supports multimodal control which consumes inputs of subject images and text prompts. Unlike other subject-driven generation models, BLIP-Diffusion introduces a new multimodal encoder which is pre-trained to provide subject representation. We first pre-train the multimodal encoder following BLIP-2 to produce visual representation aligned with the text. Then we design a subject representation learning task which enables a diffusion model to leverage such visual representation and generates new subject renditions. Compared with previous methods such as DreamBooth, our model enables zero-shot subject-driven generation, and efficient fine-tuning for customized subject with up to 20x speedup. We also demonstrate that BLIP-Diffusion can be flexibly combined with existing techniques such as ControlNet and prompt-to-prompt to enable novel subject-driven generation and editing applications.*
17
+
18
+ The model is created by Dongxu Li, Junnan Li, Steven C.H. Hoi.
19
+
20
+ ### Model Sources
21
+
22
+ <!-- Provide the basic links for the model. -->
23
+
24
+ - **Original Repository:** https://github.com/salesforce/LAVIS/tree/main
25
+ - **Project Page:** https://dxli94.github.io/BLIP-Diffusion-website/
26
+
27
+ ## Uses
28
+
29
+
30
+ ### Zero-Shot Subject Driven Generation
31
+ ```python
32
+ from diffusers.pipelines import BlipDiffusionPipeline
33
+ from diffusers.utils import load_image
34
+ import torch
35
+
36
+ blip_diffusion_pipe = BlipDiffusionPipeline.from_pretrained(
37
+ "Salesforce/blipdiffusion", torch_dtype=torch.float16
38
+ ).to("cuda")
39
+
40
+ cond_subject = "dog"
41
+ tgt_subject = "dog"
42
+ text_prompt_input = "swimming underwater"
43
+
44
+ cond_image = load_image(
45
+ "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/dog.jpg"
46
+ )
47
+
48
+ iter_seed = 88888
49
+ guidance_scale = 7.5
50
+ num_inference_steps = 25
51
+ negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
52
+
53
+ output = blip_diffusion_pipe(
54
+ text_prompt_input,
55
+ cond_image,
56
+ cond_subject,
57
+ tgt_subject,
58
+ guidance_scale=guidance_scale,
59
+ num_inference_steps=num_inference_steps,
60
+ neg_prompt=negative_prompt,
61
+ height=512,
62
+ width=512,
63
+ ).images
64
+ output[0].save("image.png")
65
+ ```
66
+ Input Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/dog.jpg" style="width:500px;"/>
67
+
68
+ Generatred Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/dog_underwater.png" style="width:500px;"/>
69
+
70
+ ### Controlled subject-driven generation
71
+
72
+ ```python
73
+ from diffusers.pipelines import BlipDiffusionControlNetPipeline
74
+ from diffusers.utils import load_image
75
+ from controlnet_aux import CannyDetector
76
+
77
+ blip_diffusion_pipe = BlipDiffusionControlNetPipeline.from_pretrained(
78
+ "Salesforce/blipdiffusion-controlnet", torch_dtype=torch.float16
79
+ ).to("cuda")
80
+
81
+ style_subject = "flower" # subject that defines the style
82
+ tgt_subject = "teapot" # subject to generate.
83
+ text_prompt = "on a marble table"
84
+
85
+ cldm_cond_image = load_image(
86
+ "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/kettle.jpg"
87
+ ).resize((512, 512))
88
+ canny = CannyDetector()
89
+ cldm_cond_image = canny(cldm_cond_image, 30, 70, output_type="pil")
90
+ style_image = load_image(
91
+ "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg"
92
+ )
93
+
94
+ guidance_scale = 7.5
95
+ num_inference_steps = 50
96
+ negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
97
+
98
+ output = blip_diffusion_pipe(
99
+ text_prompt,
100
+ style_image,
101
+ cldm_cond_image,
102
+ style_subject,
103
+ tgt_subject,
104
+ guidance_scale=guidance_scale,
105
+ num_inference_steps=num_inference_steps,
106
+ neg_prompt=negative_prompt,
107
+ height=512,
108
+ width=512,
109
+ ).images
110
+ output[0].save("image.png")
111
+ ```
112
+
113
+ Input Style Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg" style="width:500px;"/>
114
+ Canny Edge Input : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/kettle.jpg" style="width:500px;"/>
115
+ Generated Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/canny_generated.png" style="width:500px;"/>
116
+
117
+ ### Controlled subject-driven generation Scribble
118
+ ```python
119
+ from diffusers.pipelines import BlipDiffusionControlNetPipeline
120
+ from diffusers.utils import load_image
121
+ from controlnet_aux import HEDdetector
122
+
123
+ blip_diffusion_pipe = BlipDiffusionControlNetPipeline.from_pretrained(
124
+ "Salesforce/blipdiffusion-controlnet"
125
+ )
126
+ controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-scribble")
127
+ blip_diffusion_pipe.controlnet = controlnet
128
+ blip_diffusion_pipe.to("cuda")
129
+
130
+ style_subject = "flower" # subject that defines the style
131
+ tgt_subject = "bag" # subject to generate.
132
+ text_prompt = "on a table"
133
+ cldm_cond_image = load_image(
134
+ "https://huggingface.co/lllyasviel/sd-controlnet-scribble/resolve/main/images/bag.png"
135
+ ).resize((512, 512))
136
+ hed = HEDdetector.from_pretrained("lllyasviel/Annotators")
137
+ cldm_cond_image = hed(cldm_cond_image)
138
+ style_image = load_image(
139
+ "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg"
140
+ )
141
+
142
+ guidance_scale = 7.5
143
+ num_inference_steps = 50
144
+ negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
145
+
146
+ output = blip_diffusion_pipe(
147
+ text_prompt,
148
+ style_image,
149
+ cldm_cond_image,
150
+ style_subject,
151
+ tgt_subject,
152
+ guidance_scale=guidance_scale,
153
+ num_inference_steps=num_inference_steps,
154
+ neg_prompt=negative_prompt,
155
+ height=512,
156
+ width=512,
157
+ ).images
158
+ output[0].save("image.png")
159
+ ```
160
+
161
+ Input Style Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg" style="width:500px;"/>
162
+ Scribble Input : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/scribble.png" style="width:500px;"/>
163
+ Generated Image : <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/scribble_output.png" style="width:500px;"/>
164
+
165
+ ## Model Architecture
166
+
167
+ Blip-Diffusion learns a **pre-trained subject representation**. uch representation aligns with text embeddings and in the meantime also encodes the subject appearance. This allows efficient fine-tuning of the model for high-fidelity subject-driven applications, such as text-to-image generation, editing and style transfer.
168
+
169
+ To this end, they design a two-stage pre-training strategy to learn generic subject representation. In the first pre-training stage, they perform multimodal representation learning, which enforces BLIP-2 to produce text-aligned visual features based on the input image. In the second pre-training stage, they design a subject representation learning task, called prompted context generation, where the diffusion model learns to generate novel subject renditions based on the input visual features.
170
+
171
+ To achieve this, they curate pairs of input-target images with the same subject appearing in different contexts. Specifically, they synthesize input images by composing the subject with a random background. During pre-training, they feed the synthetic input image and the subject class label through BLIP-2 to obtain the multimodal embeddings as subject representation. The subject representation is then combined with a text prompt to guide the generation of the target image.
172
+
173
+ ![img](https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/arch.jpg)
174
+
175
+ The architecture is also compatible to integrate with established techniques built on top of the diffusion model, such as ControlNet.
176
+
177
+ They attach the U-Net of the pre-trained ControlNet to that of BLIP-Diffusion via residuals. In this way, the model takes into account the input structure condition, such as edge maps and depth maps, in addition to the subject cues. Since the model inherits the architecture of the original latent diffusion model, they observe satisfying generations using off-the-shelf integration with pre-trained ControlNet without further training.
178
+
179
+ <img src="https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/arch_controlnet.png" style="width:50%;"/>
180
+
181
+ ## Citation
182
+
183
+
184
+ **BibTeX:**
185
+
186
+ If you find this repository useful in your research, please cite:
187
+
188
+ ```
189
+ @misc{li2023blipdiffusion,
190
+ title={BLIP-Diffusion: Pre-trained Subject Representation for Controllable Text-to-Image Generation and Editing},
191
+ author={Dongxu Li and Junnan Li and Steven C. H. Hoi},
192
+ year={2023},
193
+ eprint={2305.14720},
194
+ archivePrefix={arXiv},
195
+ primaryClass={cs.CV}
196
+ }
197
+ ```
198
+
controlnet/config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "ControlNetModel",
3
+ "_diffusers_version": "0.14.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
+ }
controlnet/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e19821a00e6d1817b37286a21d5c4f8915076949b0e81846c4f92c96ffb46db7
3
+ size 1445157124
image_processor/preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_center_crop": true,
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.48145466,
9
+ 0.4578275,
10
+ 0.40821073
11
+ ],
12
+ "image_processor_type": "BlipImageProcessor",
13
+ "image_std": [
14
+ 0.26862954,
15
+ 0.26130258,
16
+ 0.27577711
17
+ ],
18
+ "resample": 3,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 224,
22
+ "width": 224
23
+ }
24
+ }
model_index.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "BlipDiffusionPipeline",
3
+ "_diffusers_version": "0.18.0.dev0",
4
+ "ctx_begin_pos": 2,
5
+ "image_processor": [
6
+ "blip_diffusion",
7
+ "BlipImageProcessor"
8
+ ],
9
+ "mean": [
10
+ 0.48145466,
11
+ 0.4578275,
12
+ 0.40821073
13
+ ],
14
+ "qformer": [
15
+ "blip_diffusion",
16
+ "Blip2QFormerModel"
17
+ ],
18
+ "scheduler": [
19
+ "diffusers",
20
+ "PNDMScheduler"
21
+ ],
22
+ "std": [
23
+ 0.26862954,
24
+ 0.26130258,
25
+ 0.27577711
26
+ ],
27
+ "text_encoder": [
28
+ "blip_diffusion",
29
+ "ContextCLIPTextModel"
30
+ ],
31
+ "tokenizer": [
32
+ "transformers",
33
+ "CLIPTokenizer"
34
+ ],
35
+ "unet": [
36
+ "diffusers",
37
+ "UNet2DConditionModel"
38
+ ],
39
+ "vae": [
40
+ "diffusers",
41
+ "AutoencoderKL"
42
+ ]
43
+ }
qformer/config.json ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_commit_hash": null,
3
+ "_name_or_path": "./blip2diffusion/qformer",
4
+ "architectures": [
5
+ "Blip2QFormerModel"
6
+ ],
7
+ "initializer_factor": 1.0,
8
+ "initializer_range": 0.02,
9
+ "model_type": "blip-2",
10
+ "num_query_tokens": 16,
11
+ "qformer_config": {
12
+ "_name_or_path": "",
13
+ "add_cross_attention": false,
14
+ "architectures": null,
15
+ "attention_probs_dropout_prob": 0.1,
16
+ "bad_words_ids": null,
17
+ "begin_suppress_tokens": null,
18
+ "bos_token_id": null,
19
+ "chunk_size_feed_forward": 0,
20
+ "cross_attention_frequency": 1,
21
+ "cross_attention_hidden_size": null,
22
+ "decoder_start_token_id": null,
23
+ "diversity_penalty": 0.0,
24
+ "do_sample": false,
25
+ "early_stopping": false,
26
+ "encoder_hidden_size": 1024,
27
+ "encoder_no_repeat_ngram_size": 0,
28
+ "eos_token_id": null,
29
+ "exponential_decay_length_penalty": null,
30
+ "finetuning_task": null,
31
+ "forced_bos_token_id": null,
32
+ "forced_eos_token_id": null,
33
+ "hidden_act": "gelu",
34
+ "hidden_dropout_prob": 0.1,
35
+ "hidden_size": 768,
36
+ "id2label": {
37
+ "0": "LABEL_0",
38
+ "1": "LABEL_1"
39
+ },
40
+ "initializer_range": 0.02,
41
+ "intermediate_size": 3072,
42
+ "is_decoder": false,
43
+ "is_encoder_decoder": false,
44
+ "label2id": {
45
+ "LABEL_0": 0,
46
+ "LABEL_1": 1
47
+ },
48
+ "layer_norm_eps": 1e-12,
49
+ "length_penalty": 1.0,
50
+ "max_length": 20,
51
+ "max_position_embeddings": 512,
52
+ "min_length": 0,
53
+ "model_type": "blip_2_qformer",
54
+ "no_repeat_ngram_size": 0,
55
+ "num_attention_heads": 12,
56
+ "num_beam_groups": 1,
57
+ "num_beams": 1,
58
+ "num_hidden_layers": 12,
59
+ "num_return_sequences": 1,
60
+ "output_attentions": false,
61
+ "output_hidden_states": false,
62
+ "output_scores": false,
63
+ "pad_token_id": 0,
64
+ "position_embedding_type": "absolute",
65
+ "prefix": null,
66
+ "problem_type": null,
67
+ "pruned_heads": {},
68
+ "remove_invalid_values": false,
69
+ "repetition_penalty": 1.0,
70
+ "return_dict": true,
71
+ "return_dict_in_generate": false,
72
+ "sep_token_id": null,
73
+ "suppress_tokens": null,
74
+ "task_specific_params": null,
75
+ "temperature": 1.0,
76
+ "tf_legacy_loss": false,
77
+ "tie_encoder_decoder": false,
78
+ "tie_word_embeddings": true,
79
+ "tokenizer_class": null,
80
+ "top_k": 50,
81
+ "top_p": 1.0,
82
+ "torch_dtype": null,
83
+ "torchscript": false,
84
+ "transformers_version": "4.31.0",
85
+ "typical_p": 1.0,
86
+ "use_bfloat16": false,
87
+ "vocab_size": 30523
88
+ },
89
+ "text_config": {
90
+ "_name_or_path": "",
91
+ "_remove_final_layer_norm": false,
92
+ "activation_function": "relu",
93
+ "add_cross_attention": false,
94
+ "architectures": null,
95
+ "attention_dropout": 0.0,
96
+ "bad_words_ids": null,
97
+ "begin_suppress_tokens": null,
98
+ "bos_token_id": 2,
99
+ "chunk_size_feed_forward": 0,
100
+ "cross_attention_hidden_size": null,
101
+ "decoder_start_token_id": null,
102
+ "diversity_penalty": 0.0,
103
+ "do_layer_norm_before": true,
104
+ "do_sample": false,
105
+ "dropout": 0.1,
106
+ "early_stopping": false,
107
+ "enable_bias": true,
108
+ "encoder_no_repeat_ngram_size": 0,
109
+ "eos_token_id": 2,
110
+ "exponential_decay_length_penalty": null,
111
+ "ffn_dim": 3072,
112
+ "finetuning_task": null,
113
+ "forced_bos_token_id": null,
114
+ "forced_eos_token_id": null,
115
+ "hidden_size": 768,
116
+ "id2label": {
117
+ "0": "LABEL_0",
118
+ "1": "LABEL_1"
119
+ },
120
+ "init_std": 0.02,
121
+ "is_decoder": false,
122
+ "is_encoder_decoder": false,
123
+ "label2id": {
124
+ "LABEL_0": 0,
125
+ "LABEL_1": 1
126
+ },
127
+ "layer_norm_elementwise_affine": true,
128
+ "layerdrop": 0.0,
129
+ "length_penalty": 1.0,
130
+ "max_length": 20,
131
+ "max_position_embeddings": 2048,
132
+ "min_length": 0,
133
+ "model_type": "opt",
134
+ "no_repeat_ngram_size": 0,
135
+ "num_attention_heads": 12,
136
+ "num_beam_groups": 1,
137
+ "num_beams": 1,
138
+ "num_hidden_layers": 12,
139
+ "num_return_sequences": 1,
140
+ "output_attentions": false,
141
+ "output_hidden_states": false,
142
+ "output_scores": false,
143
+ "pad_token_id": 1,
144
+ "prefix": null,
145
+ "problem_type": null,
146
+ "pruned_heads": {},
147
+ "remove_invalid_values": false,
148
+ "repetition_penalty": 1.0,
149
+ "return_dict": true,
150
+ "return_dict_in_generate": false,
151
+ "sep_token_id": null,
152
+ "suppress_tokens": null,
153
+ "task_specific_params": null,
154
+ "temperature": 1.0,
155
+ "tf_legacy_loss": false,
156
+ "tie_encoder_decoder": false,
157
+ "tie_word_embeddings": true,
158
+ "tokenizer_class": null,
159
+ "top_k": 50,
160
+ "top_p": 1.0,
161
+ "torch_dtype": null,
162
+ "torchscript": false,
163
+ "transformers_version": "4.31.0",
164
+ "typical_p": 1.0,
165
+ "use_bfloat16": false,
166
+ "use_cache": true,
167
+ "vocab_size": 50272,
168
+ "word_embed_proj_dim": 768
169
+ },
170
+ "torch_dtype": "float32",
171
+ "transformers_version": null,
172
+ "use_decoder_only_language_model": true,
173
+ "vision_config": {
174
+ "_name_or_path": "",
175
+ "add_cross_attention": false,
176
+ "architectures": null,
177
+ "attention_dropout": 0.0,
178
+ "bad_words_ids": null,
179
+ "begin_suppress_tokens": null,
180
+ "bos_token_id": null,
181
+ "chunk_size_feed_forward": 0,
182
+ "cross_attention_hidden_size": null,
183
+ "decoder_start_token_id": null,
184
+ "diversity_penalty": 0.0,
185
+ "do_sample": false,
186
+ "early_stopping": false,
187
+ "encoder_no_repeat_ngram_size": 0,
188
+ "eos_token_id": null,
189
+ "exponential_decay_length_penalty": null,
190
+ "finetuning_task": null,
191
+ "forced_bos_token_id": null,
192
+ "forced_eos_token_id": null,
193
+ "hidden_act": "quick_gelu",
194
+ "hidden_size": 1024,
195
+ "id2label": {
196
+ "0": "LABEL_0",
197
+ "1": "LABEL_1"
198
+ },
199
+ "image_size": 224,
200
+ "initializer_range": 1e-10,
201
+ "intermediate_size": 4096,
202
+ "is_decoder": false,
203
+ "is_encoder_decoder": false,
204
+ "label2id": {
205
+ "LABEL_0": 0,
206
+ "LABEL_1": 1
207
+ },
208
+ "layer_norm_eps": 1e-05,
209
+ "length_penalty": 1.0,
210
+ "max_length": 20,
211
+ "min_length": 0,
212
+ "model_type": "blip_2_vision_model",
213
+ "no_repeat_ngram_size": 0,
214
+ "num_attention_heads": 16,
215
+ "num_beam_groups": 1,
216
+ "num_beams": 1,
217
+ "num_hidden_layers": 23,
218
+ "num_return_sequences": 1,
219
+ "output_attentions": false,
220
+ "output_hidden_states": false,
221
+ "output_scores": false,
222
+ "pad_token_id": null,
223
+ "patch_size": 14,
224
+ "prefix": null,
225
+ "problem_type": null,
226
+ "pruned_heads": {},
227
+ "qkv_bias": true,
228
+ "remove_invalid_values": false,
229
+ "repetition_penalty": 1.0,
230
+ "return_dict": true,
231
+ "return_dict_in_generate": false,
232
+ "sep_token_id": null,
233
+ "suppress_tokens": null,
234
+ "task_specific_params": null,
235
+ "temperature": 1.0,
236
+ "tf_legacy_loss": false,
237
+ "tie_encoder_decoder": false,
238
+ "tie_word_embeddings": true,
239
+ "tokenizer_class": null,
240
+ "top_k": 50,
241
+ "top_p": 1.0,
242
+ "torch_dtype": null,
243
+ "torchscript": false,
244
+ "transformers_version": "4.31.0",
245
+ "typical_p": 1.0,
246
+ "use_bfloat16": false
247
+ }
248
+ }
qformer/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:709f641c6a2b4a932c51e57f14ebcb3b270efd9bbf31db0c34af7c208aa06bc6
3
+ size 1976162665
scheduler/scheduler_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "PNDMScheduler",
3
+ "_diffusers_version": "0.16.0",
4
+ "beta_end": 0.012,
5
+ "beta_schedule": "scaled_linear",
6
+ "beta_start": 0.00085,
7
+ "num_train_timesteps": 1000,
8
+ "prediction_type": "epsilon",
9
+ "set_alpha_to_one": false,
10
+ "skip_prk_steps": true,
11
+ "steps_offset": 0,
12
+ "trained_betas": null
13
+ }
text_encoder/config.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "cache/models--runwayml--stable-diffusion-v1-5",
3
+ "architectures": [
4
+ "ContextCLIPTextModel"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dropout": 0.0,
9
+ "eos_token_id": 2,
10
+ "hidden_act": "quick_gelu",
11
+ "hidden_size": 768,
12
+ "initializer_factor": 1.0,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "layer_norm_eps": 1e-05,
16
+ "max_position_embeddings": 77,
17
+ "model_type": "clip_text_model",
18
+ "num_attention_heads": 12,
19
+ "num_hidden_layers": 12,
20
+ "pad_token_id": 1,
21
+ "projection_dim": 768,
22
+ "torch_dtype": "float32",
23
+ "transformers_version": "4.32.1",
24
+ "vocab_size": 49408
25
+ }
text_encoder/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b374042419b2a5a28e7ee94503ff233719c7bd1345f5896ad982fdeff7c8cccc
3
+ size 492307041
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,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "bos_token": {
4
+ "__type": "AddedToken",
5
+ "content": "<|startoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false
10
+ },
11
+ "clean_up_tokenization_spaces": true,
12
+ "do_lower_case": true,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "<|endoftext|>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "errors": "replace",
22
+ "model_max_length": 77,
23
+ "pad_token": "<|endoftext|>",
24
+ "tokenizer_class": "CLIPTokenizer",
25
+ "unk_token": {
26
+ "__type": "AddedToken",
27
+ "content": "<|endoftext|>",
28
+ "lstrip": false,
29
+ "normalized": true,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
tokenizer/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
unet/config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "UNet2DConditionModel",
3
+ "_diffusers_version": "0.16.0",
4
+ "_name_or_path": "./blipdiffusion_hf_ckpt/",
5
+ "act_fn": "silu",
6
+ "addition_embed_type": null,
7
+ "addition_embed_type_num_heads": 64,
8
+ "attention_head_dim": 8,
9
+ "block_out_channels": [
10
+ 320,
11
+ 640,
12
+ 1280,
13
+ 1280
14
+ ],
15
+ "center_input_sample": false,
16
+ "class_embed_type": null,
17
+ "class_embeddings_concat": false,
18
+ "conv_in_kernel": 3,
19
+ "conv_out_kernel": 3,
20
+ "cross_attention_dim": 768,
21
+ "cross_attention_norm": null,
22
+ "down_block_types": [
23
+ "CrossAttnDownBlock2D",
24
+ "CrossAttnDownBlock2D",
25
+ "CrossAttnDownBlock2D",
26
+ "DownBlock2D"
27
+ ],
28
+ "downsample_padding": 1,
29
+ "dual_cross_attention": false,
30
+ "encoder_hid_dim": null,
31
+ "flip_sin_to_cos": true,
32
+ "freq_shift": 0,
33
+ "in_channels": 4,
34
+ "layers_per_block": 2,
35
+ "mid_block_only_cross_attention": null,
36
+ "mid_block_scale_factor": 1,
37
+ "mid_block_type": "UNetMidBlock2DCrossAttn",
38
+ "norm_eps": 1e-05,
39
+ "norm_num_groups": 32,
40
+ "num_class_embeds": null,
41
+ "only_cross_attention": false,
42
+ "out_channels": 4,
43
+ "projection_class_embeddings_input_dim": null,
44
+ "resnet_out_scale_factor": 1.0,
45
+ "resnet_skip_time_act": false,
46
+ "resnet_time_scale_shift": "default",
47
+ "sample_size": 64,
48
+ "time_cond_proj_dim": null,
49
+ "time_embedding_act_fn": null,
50
+ "time_embedding_dim": null,
51
+ "time_embedding_type": "positional",
52
+ "timestep_post_act": null,
53
+ "up_block_types": [
54
+ "UpBlock2D",
55
+ "CrossAttnUpBlock2D",
56
+ "CrossAttnUpBlock2D",
57
+ "CrossAttnUpBlock2D"
58
+ ],
59
+ "upcast_attention": false,
60
+ "use_linear_projection": false
61
+ }
unet/diffusion_pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c42d7cf4e4f028e3c955e13f4406231c946b602329de281b67c214f5efcb5137
3
+ size 3438366373
vae/config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKL",
3
+ "_diffusers_version": "0.16.0",
4
+ "_name_or_path": "./blipdiffusion_hf_ckpt/",
5
+ "act_fn": "silu",
6
+ "block_out_channels": [
7
+ 128,
8
+ 256,
9
+ 512,
10
+ 512
11
+ ],
12
+ "down_block_types": [
13
+ "DownEncoderBlock2D",
14
+ "DownEncoderBlock2D",
15
+ "DownEncoderBlock2D",
16
+ "DownEncoderBlock2D"
17
+ ],
18
+ "in_channels": 3,
19
+ "latent_channels": 4,
20
+ "layers_per_block": 2,
21
+ "norm_num_groups": 32,
22
+ "out_channels": 3,
23
+ "sample_size": 512,
24
+ "scaling_factor": 0.18215,
25
+ "up_block_types": [
26
+ "UpDecoderBlock2D",
27
+ "UpDecoderBlock2D",
28
+ "UpDecoderBlock2D",
29
+ "UpDecoderBlock2D"
30
+ ]
31
+ }
vae/diffusion_pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af27ea858349760ebe3311953e0bfe8d6fd257dc9537ae0b2b938c262132a2c6
3
+ size 334711857
vision_encoder/config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "E:/diffusers/cache/vit",
3
+ "architectures": [
4
+ "Blip2VisionModel"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "hidden_act": "quick_gelu",
8
+ "hidden_size": 1024,
9
+ "image_size": 224,
10
+ "initializer_range": 1e-10,
11
+ "intermediate_size": 4096,
12
+ "layer_norm_eps": 1e-05,
13
+ "model_type": "blip_2_vision_model",
14
+ "num_attention_heads": 16,
15
+ "num_hidden_layers": 23,
16
+ "patch_size": 14,
17
+ "qkv_bias": true,
18
+ "torch_dtype": "float32",
19
+ "transformers_version": "4.31.0"
20
+ }
vision_encoder/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84e3623a20ab1912527e682ca0467f1260599e845a69731335e5482f10482150
3
+ size 1162423609