forked from google/prompt-to-prompt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_npi.py
212 lines (200 loc) · 6.35 KB
/
run_npi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# Example of running NPI and ProxNPI
if __name__ == "__main__":
from negative_prompt_inversion import main
########## NPI ##########
main(
image_path="./example_images/gnochi_mirror.jpeg",
offsets=(0,0,200,0),
prompt_src="a cat sitting next to a mirror",
prompt_tar="a tiger sitting next to a mirror",
output_dir="./outputs/npi_real/",
suffix="cat2tiger",
guidance_scale=9,
cross_replace_steps=0.7,
self_replace_steps=0.6,
blend_word=((('cat',), ("tiger",))),
eq_params={"words": ("tiger",), "values": (2,)},
is_replace_controller=True,
proximal=None,
)
########## ProxNPI ##########
main(
image_path="./example_images/gnochi_mirror.jpeg",
offsets=(0,0,200,0),
prompt_src="a cat sitting next to a mirror",
prompt_tar="a tiger sitting next to a mirror",
output_dir="./outputs/npi_real/",
suffix="cat2tiger",
guidance_scale=9,
cross_replace_steps=0.7,
self_replace_steps=0.6,
blend_word=((('cat',), ("tiger",))),
eq_params={"words": ("tiger",), "values": (2,)},
is_replace_controller=True,
proximal="l0",
quantile=0.75,
use_inversion_guidance=True,
recon_lr=1,
recon_t=400,
dilate_mask=2,
)
########## NPI ##########
main(
image_path="./images/cat_chair.png",
prompt_src="A cat sitting on a wooden chair",
prompt_tar="A dog sitting on a wooden chair",
output_dir="./outputs/npi_real/",
suffix="cat2dog",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word="cat,dog",
eq_params="dog,2",
proximal=None,
)
########## ProxNPI ##########
main(
image_path="./images/cat_chair.png",
prompt_src="A cat sitting on a wooden chair",
prompt_tar="A dog sitting on a wooden chair",
output_dir="./outputs/npi_real/",
suffix="cat2dog",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word="cat,dog",
eq_params="dog,2",
proximal="l0",
quantile=0.75,
use_inversion_guidance=True,
recon_lr=1,
recon_t=400,
)
########## ProxNPI ##########
main(
image_path="./images/coffee.jpeg",
prompt_src="drawing of tulip on the coffee",
prompt_tar="drawing of lion on the coffee",
output_dir="./outputs/npi_real/",
suffix="tulip2lion",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.5,
blend_word="tulip,lion",
eq_params="lion,2",
proximal="l0",
quantile=0.7,
)
# More ProxNPI examples
main(
image_path="./images/tiger_white.png",
prompt_src="white tiger on brown ground",
prompt_tar="white cat on brown ground",
output_dir="./outputs/npi_real/",
suffix="tiger2cat",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word="tiger,cat",
eq_params="cat,2",
proximal="l0",
quantile=0.7,
use_inversion_guidance=True,
recon_lr=0.5,
recon_t=600,
)
main(
image_path="./images/plate_fruit.jpeg",
prompt_src="white plate with fruits on it",
prompt_tar="white plate with pizza on it",
output_dir="./outputs/npi_real/",
suffix="fruit2pizza",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word=((('fruits',), ("pizza",))),
eq_params={"words": ("pizza",), "values": (2,)},
proximal="l0",
quantile=0.7,
use_inversion_guidance=True,
recon_lr=0.5,
recon_t=600,
)
main(
image_path="./images/woman_blue_hair.png",
prompt_src="A woman with blue hair in the forest",
prompt_tar="A storm-trooper with blue hair in the forest",
output_dir="./outputs/npi_real/",
suffix="woman2stormtrooper",
guidance_scale=7.5,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word=((('woman',), ("storm-trooper",))),
eq_params={"words": ("storm-trooper",), "values": (2,)},
proximal="l0",
quantile=0.75,
use_inversion_guidance=True,
recon_lr=0.5,
recon_t=600,
)
main(
image_path="./images/van.jpg",
prompt_src="orange van with surfboards on top",
prompt_tar="orange van with flowers on top",
output_dir="./outputs/npi_real/",
suffix="surfboards2flowers",
guidance_scale=9,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word=((('surfboards',), ("flowers",))),
eq_params={"words": ("flowers", ), "values": (2,)},
proximal='l0',
quantile=0.9,
use_inversion_guidance=True,
recon_lr=0.1,
recon_t=1000,
)
# ---------- ProxNPI with ELITE ----------
from prox_npi_elite import main
main(
image_path="./images/cat1.png",
ref_image_path="./images_elite/1.jpg",
prompt_src="a cat sitting",
prompt_tar="a S sitting",
output_dir="./outputs/npi_real_elite/",
suffix="",
guidance_scale=10,
cross_replace_steps=0.3,
self_replace_steps=0.6,
blend_word=((('cat',), ("S",))),
eq_params={"words": ("S",), "values": (5,)},
token_index="0:3",
is_replace_controller=False,
proximal='l0',
quantile=0.6,
npi_interp=0,
use_inversion_guidance=True,
recon_lr=0.5,
recon_t=600,
)
main(
image_path="./images/yellow_cat.jpeg",
ref_image_path="./images_elite/20.jpg",
prompt_src="a cat sitting on ground",
prompt_tar="a S sitting on ground",
output_dir="./outputs/npi_real_elite/",
suffix="",
guidance_scale=10,
cross_replace_steps=0.4,
self_replace_steps=0.6,
blend_word=((('cat',), ("S",))),
eq_params={"words": ("S",), "values": (5,)},
token_index="0:3",
is_replace_controller=False,
proximal='l0',
quantile=0.6,
npi_interp=0,
use_inversion_guidance=True,
recon_lr=0.5,
recon_t=600,
)