taki0112 commited on
Commit
4f4656c
β€’
1 Parent(s): 2b3f761
app.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from pipelines.inverted_ve_pipeline import STYLE_DESCRIPTION_DICT, create_image_grid
3
+ import gradio as gr
4
+ import os, json
5
+
6
+ from pipelines.pipeline_stable_diffusion_xl import StableDiffusionXLPipeline
7
+ from diffusers import AutoencoderKL
8
+ from random import randint
9
+ from utils import init_latent
10
+
11
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
12
+ if device == 'cpu':
13
+ torch_dtype = torch.float32
14
+ else:
15
+ torch_dtype = torch.float16
16
+
17
+ def memory_efficient(model):
18
+ try:
19
+ model.to(device)
20
+ except Exception as e:
21
+ print("Error moving model to device:", e)
22
+
23
+ try:
24
+ model.enable_model_cpu_offload()
25
+ except AttributeError:
26
+ print("enable_model_cpu_offload is not supported.")
27
+ try:
28
+ model.enable_vae_slicing()
29
+ except AttributeError:
30
+ print("enable_vae_slicing is not supported.")
31
+ if device == 'cuda':
32
+ try:
33
+ model.enable_xformers_memory_efficient_attention()
34
+ except AttributeError:
35
+ print("enable_xformers_memory_efficient_attention is not supported.")
36
+
37
+ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch_dtype)
38
+ model = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch_dtype)
39
+
40
+ print("vae")
41
+ memory_efficient(vae)
42
+ print("SDXL")
43
+ memory_efficient(model)
44
+
45
+
46
+ # controlnet_scale, canny thres 1, 2 (2 > 1, 2:1, 3:1)
47
+
48
+ def parse_config(config):
49
+ with open(config, 'r') as f:
50
+ config = json.load(f)
51
+ return config
52
+
53
+
54
+ def load_example_style():
55
+ folder_path = 'assets/ref'
56
+ examples = []
57
+ for filename in os.listdir(folder_path):
58
+ if filename.endswith((".png")):
59
+ image_path = os.path.join(folder_path, filename)
60
+ image_name = os.path.basename(image_path)
61
+ style_name = image_name.split('_')[1]
62
+
63
+ config_path = './config/{}.json'.format(style_name)
64
+ config = parse_config(config_path)
65
+ inf_object_name = config["inference_info"]["inf_object_list"][0]
66
+
67
+ image_info = [image_path, style_name, inf_object_name, 1, 50]
68
+ examples.append(image_info)
69
+
70
+ return examples
71
+
72
+ def style_fn(image_path, style_name, content_text, output_number, diffusion_step=50):
73
+ """
74
+
75
+ :param style_name: μ–΄λ–€ json 파일 λΆ€λ₯Όκ±°λƒ ?
76
+ :param content_text: μ–΄λ–€ μ½˜ν…μΈ λ‘œ λ³€ν™”λ₯Ό μ›ν•˜λ‹ˆ ?
77
+ :param output_number: λͺ‡κ°œ μƒμ„±ν• κ±°λ‹ˆ ?
78
+ :return:
79
+ """
80
+ config_path = './config/{}.json'.format(style_name)
81
+ config = parse_config(config_path)
82
+
83
+ inf_object = content_text
84
+ inf_seeds = [randint(0, 10**10) for _ in range(int(output_number))]
85
+ # inf_seeds = [i for i in range(int(output_number))]
86
+
87
+
88
+ activate_layer_indices_list = config['inference_info']['activate_layer_indices_list']
89
+ activate_step_indices_list = config['inference_info']['activate_step_indices_list']
90
+ ref_seed = config['reference_info']['ref_seeds'][0]
91
+
92
+ attn_map_save_steps = config['inference_info']['attn_map_save_steps']
93
+ guidance_scale = config['guidance_scale']
94
+ use_inf_negative_prompt = config['inference_info']['use_negative_prompt']
95
+
96
+ style_name = config["style_name_list"][0]
97
+
98
+ ref_object = config["reference_info"]["ref_object_list"][0]
99
+ ref_with_style_description = config['reference_info']['with_style_description']
100
+ inf_with_style_description = config['inference_info']['with_style_description']
101
+
102
+ use_shared_attention = config['inference_info']['use_shared_attention']
103
+ adain_queries = config['inference_info']['adain_queries']
104
+ adain_keys = config['inference_info']['adain_keys']
105
+ adain_values = config['inference_info']['adain_values']
106
+
107
+ use_advanced_sampling = config['inference_info']['use_advanced_sampling']
108
+
109
+ style_description_pos, style_description_neg = STYLE_DESCRIPTION_DICT[style_name][0], \
110
+ STYLE_DESCRIPTION_DICT[style_name][1]
111
+
112
+ # Inference
113
+ with torch.inference_mode():
114
+ grid = None
115
+ if ref_with_style_description:
116
+ ref_prompt = style_description_pos.replace("{object}", ref_object)
117
+ else:
118
+ ref_prompt = ref_object
119
+
120
+ if inf_with_style_description:
121
+ inf_prompt = style_description_pos.replace("{object}", inf_object)
122
+ else:
123
+ inf_prompt = inf_object
124
+
125
+ for activate_layer_indices in activate_layer_indices_list:
126
+
127
+ for activate_step_indices in activate_step_indices_list:
128
+
129
+ str_activate_layer, str_activate_step = model.activate_layer(
130
+ activate_layer_indices=activate_layer_indices,
131
+ attn_map_save_steps=attn_map_save_steps,
132
+ activate_step_indices=activate_step_indices, use_shared_attention=use_shared_attention,
133
+ adain_queries=adain_queries,
134
+ adain_keys=adain_keys,
135
+ adain_values=adain_values,
136
+ )
137
+ # ref_latent = model.get_init_latent(ref_seed, precomputed_path=None)
138
+ ref_latent = init_latent(model, device_name=device, dtype=torch_dtype, seed=ref_seed)
139
+ latents = [ref_latent]
140
+
141
+ for inf_seed in inf_seeds:
142
+ # latents.append(model.get_init_latent(inf_seed, precomputed_path=None))
143
+ inf_latent = init_latent(model, device_name=device, dtype=torch_dtype, seed=inf_seed)
144
+ latents.append(inf_latent)
145
+
146
+ latents = torch.cat(latents, dim=0)
147
+ latents.to(device)
148
+
149
+ images = model(
150
+ prompt=ref_prompt,
151
+ negative_prompt=style_description_neg,
152
+ guidance_scale=guidance_scale,
153
+ num_inference_steps=diffusion_step,
154
+ latents=latents,
155
+ num_images_per_prompt=len(inf_seeds) + 1,
156
+ target_prompt=inf_prompt,
157
+ use_inf_negative_prompt=use_inf_negative_prompt,
158
+ use_advanced_sampling=use_advanced_sampling
159
+ )[0][1:]
160
+
161
+ n_row = 1
162
+ n_col = len(inf_seeds) # μ›λ³ΈμΆ”κ°€ν•˜λ €λ©΄ + 1
163
+
164
+ # make grid
165
+ grid = create_image_grid(images, n_row, n_col, padding=10)
166
+
167
+ torch.cuda.empty_cache()
168
+
169
+ return grid
170
+
171
+ description_md = """
172
+
173
+ ### We introduce `Visual Style Prompting`, which reflects the style of a reference image to the images generated by a pretrained text-to-image diffusion model without finetuning or optimization (e.g., Figure N).
174
+ ### πŸ“– [[Paper](https://arxiv.org/abs/2402.12974)] | ✨ [[Project page](https://curryjung.github.io/VisualStylePrompt)] | ✨ [[Code](https://github.com/naver-ai/Visual-Style-Prompting)]
175
+ ### πŸ”₯ [[w/ Controlnet ver](https://huggingface.co/spaces/naver-ai/VisualStylePrompting_Controlnet)]
176
+ ---
177
+ ### To try out our vanilla demo,
178
+ 1. Choose a `style reference` from the collection of images below.
179
+ 2. Enter the `text prompt`.
180
+ 3. Choose the `number of outputs`.
181
+
182
+ ### To achieve faster results, we recommend lowering the diffusion steps to 30.
183
+ ### Enjoy ! πŸ˜„
184
+ """
185
+
186
+ iface_style = gr.Interface(
187
+ fn=style_fn,
188
+ inputs=[
189
+ gr.components.Image(label="Style Image"),
190
+ gr.components.Textbox(label='Style name', visible=False),
191
+ gr.components.Textbox(label="Text prompt", placeholder="Enter Text prompt"),
192
+ gr.components.Textbox(label="Number of outputs", placeholder="Enter Number of outputs"),
193
+ gr.components.Slider(minimum=50, maximum=50, step=10, value=50, label="Diffusion steps")
194
+ ],
195
+ outputs=gr.components.Image(type="pil"),
196
+ title="🎨 Visual Style Prompting (default)",
197
+ description=description_md,
198
+ examples=load_example_style(),
199
+ )
200
+
201
+ iface_style.launch(debug=True)
config/chinese-ink-paint.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "chinese-ink-paint"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 1
15
+ ],
16
+ "ref_object_list": [
17
+ "A horse"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A tiger"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/cloud.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "cloud"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 3
15
+ ],
16
+ "ref_object_list": [
17
+ "a Cloud in the sky"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5
44
+
45
+ ],
46
+ "inf_object_list": [
47
+ "A photo of a dog"
48
+ ],
49
+ "with_style_description": true,
50
+ "negative_prompts": false,
51
+ "external_init_noise_path": false,
52
+ "attn_map_save_steps": [],
53
+ "guidance_scale": 7.0,
54
+ "use_negative_prompt": true,
55
+ "activate_step_indices_list": [
56
+ [
57
+ [
58
+ 0,
59
+ 49
60
+ ]
61
+ ]
62
+ ],
63
+ "use_advanced_sampling": true,
64
+ "use_shared_attention": false,
65
+ "adain_queries": true,
66
+ "adain_keys": true,
67
+ "adain_values": false
68
+ }
69
+ }
config/default.json ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "anime",
7
+ "Artstyle_Pop_Art",
8
+ "low_poly",
9
+ "line_art"
10
+ ],
11
+ "save_info": {
12
+ "base_exp_dir": "experiments",
13
+ "base_exp_name": "results"
14
+ },
15
+ "reference_info": {
16
+ "ref_seeds": [
17
+ 42
18
+ ],
19
+ "ref_object_list": [
20
+ "cat"
21
+ ],
22
+ "with_style_description": true,
23
+ "external_init_noise_path": false,
24
+ "guidance_scale": 7.0,
25
+ "use_negative_prompt": true
26
+ },
27
+ "inference_info": {
28
+ "activate_layer_indices_list": [
29
+ [
30
+ [
31
+ 0,
32
+ 0
33
+ ],
34
+ [
35
+ 128,
36
+ 140
37
+ ]
38
+ ]
39
+ ],
40
+ "inf_seeds": [
41
+ 0,
42
+ 1,
43
+ 2,
44
+ 3,
45
+ 4,
46
+ 5,
47
+ 6,
48
+ 7,
49
+ 8,
50
+ 9
51
+ ],
52
+ "inf_object_list": [
53
+ "A photo of a dog"
54
+ ],
55
+ "with_style_description": true,
56
+ "negative_prompts": false,
57
+ "external_init_noise_path": false,
58
+ "attn_map_save_steps": [],
59
+ "guidance_scale": 7.0,
60
+ "use_negative_prompt": true,
61
+ "activate_step_indices_list": [
62
+ [
63
+ [
64
+ 0,
65
+ 49
66
+ ]
67
+ ]
68
+ ],
69
+ "use_advanced_sampling": true,
70
+ "use_shared_attention": false,
71
+ "adain_queries": true,
72
+ "adain_keys": true,
73
+ "adain_values": false
74
+ }
75
+ }
config/digital-art.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "digital-art"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 42
15
+ ],
16
+ "ref_object_list": [
17
+ "A robot"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A woman playing basketball"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/fire.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "fire"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 3
15
+ ],
16
+ "ref_object_list": [
17
+ "fire"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A dragon"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/klimt.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "klimt"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 1
15
+ ],
16
+ "ref_object_list": [
17
+ "the kiss"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "Frog"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/line-art.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "line-art"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 42
15
+ ],
16
+ "ref_object_list": [
17
+ "an owl"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A dragon"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/low-poly.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "low-poly"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 42
15
+ ],
16
+ "ref_object_list": [
17
+ "A cat"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A rhino"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/munch.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "munch"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 1
15
+ ],
16
+ "ref_object_list": [
17
+ "The scream"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A dragon"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/totoro.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "totoro"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 42
15
+ ],
16
+ "ref_object_list": [
17
+ "totoro holding a tiny umbrella in the rain"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 108,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "1 cute bird holding a tiny umbrella, forward facing"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": true,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
config/van-gogh.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "device": "cuda",
3
+ "precomputed_path": "./precomputed",
4
+ "guidance_scale": 7.0,
5
+ "style_name_list": [
6
+ "van-gogh"
7
+ ],
8
+ "save_info": {
9
+ "base_exp_dir": "experiments",
10
+ "base_exp_name": "results"
11
+ },
12
+ "reference_info": {
13
+ "ref_seeds": [
14
+ 1
15
+ ],
16
+ "ref_object_list": [
17
+ "The Starry Night"
18
+ ],
19
+ "with_style_description": true,
20
+ "external_init_noise_path": false,
21
+ "guidance_scale": 7.0,
22
+ "use_negative_prompt": true
23
+ },
24
+ "inference_info": {
25
+ "activate_layer_indices_list": [
26
+ [
27
+ [
28
+ 0,
29
+ 0
30
+ ],
31
+ [
32
+ 128,
33
+ 140
34
+ ]
35
+ ]
36
+ ],
37
+ "inf_seeds": [
38
+ 0,
39
+ 1,
40
+ 2,
41
+ 3,
42
+ 4,
43
+ 5,
44
+ 6,
45
+ 7,
46
+ 8,
47
+ 9
48
+ ],
49
+ "inf_object_list": [
50
+ "A dragon"
51
+ ],
52
+ "with_style_description": true,
53
+ "negative_prompts": false,
54
+ "external_init_noise_path": false,
55
+ "attn_map_save_steps": [],
56
+ "guidance_scale": 7.0,
57
+ "use_negative_prompt": true,
58
+ "activate_step_indices_list": [
59
+ [
60
+ [
61
+ 0,
62
+ 49
63
+ ]
64
+ ]
65
+ ],
66
+ "use_advanced_sampling": true,
67
+ "use_shared_attention": false,
68
+ "adain_queries": true,
69
+ "adain_keys": true,
70
+ "adain_values": false
71
+ }
72
+ }
pipelines/__init__.py ADDED
File without changes
pipelines/controlnet.py ADDED
@@ -0,0 +1,844 @@