Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,6 +187,7 @@ def infer_ode(args, infer_args, text_encoder, tokenizer, vae, model):
|
|
| 187 |
with torch.autocast("cuda", dtype):
|
| 188 |
(
|
| 189 |
cap,
|
|
|
|
| 190 |
resolution,
|
| 191 |
num_sampling_steps,
|
| 192 |
cfg_scale,
|
|
@@ -199,6 +200,7 @@ def infer_ode(args, infer_args, text_encoder, tokenizer, vae, model):
|
|
| 199 |
|
| 200 |
metadata = dict(
|
| 201 |
cap=cap,
|
|
|
|
| 202 |
resolution=resolution,
|
| 203 |
num_sampling_steps=num_sampling_steps,
|
| 204 |
cfg_scale=cfg_scale,
|
|
@@ -252,6 +254,16 @@ def infer_ode(args, infer_args, text_encoder, tokenizer, vae, model):
|
|
| 252 |
cap_feats, cap_mask = encode_prompt(
|
| 253 |
[cap] + [""], text_encoder, tokenizer, 0.0
|
| 254 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
cap_mask = cap_mask.to(cap_feats.device)
|
| 256 |
|
| 257 |
train_res = 1024
|
|
@@ -432,6 +444,14 @@ def main():
|
|
| 432 |
interactive=True,
|
| 433 |
value="Miss Mexico portrait of the most beautiful mexican woman, Exquisite detail, 30-megapixel, 4k, 85-mm-lens, sharp-focus, f:8, "
|
| 434 |
"ISO 100, shutter-speed 1:125, diffuse-back-lighting, award-winning photograph, small-catchlight, High-sharpness, facial-symmetry, 8k",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
)
|
| 436 |
with gr.Row():
|
| 437 |
res_choices = ["1024x1024", "512x2048", "2048x512"] + [
|
|
@@ -581,6 +601,7 @@ def main():
|
|
| 581 |
on_submit,
|
| 582 |
[
|
| 583 |
cap,
|
|
|
|
| 584 |
resolution,
|
| 585 |
num_sampling_steps,
|
| 586 |
cfg_scale,
|
|
|
|
| 187 |
with torch.autocast("cuda", dtype):
|
| 188 |
(
|
| 189 |
cap,
|
| 190 |
+
neg_cap,
|
| 191 |
resolution,
|
| 192 |
num_sampling_steps,
|
| 193 |
cfg_scale,
|
|
|
|
| 200 |
|
| 201 |
metadata = dict(
|
| 202 |
cap=cap,
|
| 203 |
+
neg_cap=neg_cap,
|
| 204 |
resolution=resolution,
|
| 205 |
num_sampling_steps=num_sampling_steps,
|
| 206 |
cfg_scale=cfg_scale,
|
|
|
|
| 254 |
cap_feats, cap_mask = encode_prompt(
|
| 255 |
[cap] + [""], text_encoder, tokenizer, 0.0
|
| 256 |
)
|
| 257 |
+
if neg_cap != "":
|
| 258 |
+
neg_cap_feats, neg_cap_mask = encode_prompt(
|
| 259 |
+
[neg_cap] + [""],
|
| 260 |
+
text_encoder,
|
| 261 |
+
tokenizer,
|
| 262 |
+
0.0,
|
| 263 |
+
)
|
| 264 |
+
cap_feats = torch.cat([neg_cap_feats, cap_feats], dim=0)
|
| 265 |
+
cap_mask = torch.cat([neg_cap_mask, cap_mask], dim=0)
|
| 266 |
+
|
| 267 |
cap_mask = cap_mask.to(cap_feats.device)
|
| 268 |
|
| 269 |
train_res = 1024
|
|
|
|
| 444 |
interactive=True,
|
| 445 |
value="Miss Mexico portrait of the most beautiful mexican woman, Exquisite detail, 30-megapixel, 4k, 85-mm-lens, sharp-focus, f:8, "
|
| 446 |
"ISO 100, shutter-speed 1:125, diffuse-back-lighting, award-winning photograph, small-catchlight, High-sharpness, facial-symmetry, 8k",
|
| 447 |
+
placeholder="Enter a caption.",
|
| 448 |
+
)
|
| 449 |
+
neg_cap = gr.Textbox(
|
| 450 |
+
lines=2,
|
| 451 |
+
label="Negative Caption",
|
| 452 |
+
interactive=True,
|
| 453 |
+
value="",
|
| 454 |
+
placeholder="Enter a negative caption.",
|
| 455 |
)
|
| 456 |
with gr.Row():
|
| 457 |
res_choices = ["1024x1024", "512x2048", "2048x512"] + [
|
|
|
|
| 601 |
on_submit,
|
| 602 |
[
|
| 603 |
cap,
|
| 604 |
+
neg_cap,
|
| 605 |
resolution,
|
| 606 |
num_sampling_steps,
|
| 607 |
cfg_scale,
|