Spaces:
Runtime error
Runtime error
Update app.py
Browse filesresize all input
app.py
CHANGED
|
@@ -17,6 +17,7 @@ import os
|
|
| 17 |
from huggingface_hub import hf_hub_url
|
| 18 |
import subprocess
|
| 19 |
import shlex
|
|
|
|
| 20 |
|
| 21 |
torch.set_grad_enabled(False)
|
| 22 |
|
|
@@ -102,6 +103,29 @@ def run(*args):
|
|
| 102 |
opt.prompt, opt.neg_prompt, opt.scale, opt.n_samples, opt.seed, opt.steps, opt.resize_short_edge, opt.cond_tau \
|
| 103 |
= args[-8:]
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
conds = []
|
| 106 |
activated_conds = []
|
| 107 |
for idx, (b, im1, im2, cond_weight) in enumerate(zip(*inps)):
|
|
@@ -122,9 +146,9 @@ def run(*args):
|
|
| 122 |
if b == 'Image':
|
| 123 |
if cond_name not in cond_models:
|
| 124 |
cond_models[cond_name] = get_cond_model(opt, getattr(ExtraCondition, cond_name))
|
| 125 |
-
conds.append(process_cond_module(opt,
|
| 126 |
else:
|
| 127 |
-
conds.append(process_cond_module(opt,
|
| 128 |
|
| 129 |
features = dict()
|
| 130 |
for idx, cond_name in enumerate(activated_conds):
|
|
|
|
| 17 |
from huggingface_hub import hf_hub_url
|
| 18 |
import subprocess
|
| 19 |
import shlex
|
| 20 |
+
import cv2
|
| 21 |
|
| 22 |
torch.set_grad_enabled(False)
|
| 23 |
|
|
|
|
| 103 |
opt.prompt, opt.neg_prompt, opt.scale, opt.n_samples, opt.seed, opt.steps, opt.resize_short_edge, opt.cond_tau \
|
| 104 |
= args[-8:]
|
| 105 |
|
| 106 |
+
ims1 = []
|
| 107 |
+
ims2 = []
|
| 108 |
+
for idx, (b, im1, im2, cond_weight) in enumerate(zip(*inps)):
|
| 109 |
+
if idx > 1:
|
| 110 |
+
if im1 is not None or im2 is not None:
|
| 111 |
+
if im1 is not None:
|
| 112 |
+
h, w, _ = im1.shape
|
| 113 |
+
else:
|
| 114 |
+
h, w, _ = im2.shape
|
| 115 |
+
break
|
| 116 |
+
# resize all the images to the same size
|
| 117 |
+
for idx, (b, im1, im2, cond_weight) in enumerate(zip(*inps)):
|
| 118 |
+
if idx == 0:
|
| 119 |
+
ims1.append(im1)
|
| 120 |
+
ims2.append(im2)
|
| 121 |
+
continue
|
| 122 |
+
if im1 is not None:
|
| 123 |
+
im1 = cv2.resize(im1, (w, h), interpolation=cv2.INTER_CUBIC)
|
| 124 |
+
if im2 is not None:
|
| 125 |
+
im2 = cv2.resize(im2, (w, h), interpolation=cv2.INTER_CUBIC)
|
| 126 |
+
ims1.append(im1)
|
| 127 |
+
ims2.append(im2)
|
| 128 |
+
|
| 129 |
conds = []
|
| 130 |
activated_conds = []
|
| 131 |
for idx, (b, im1, im2, cond_weight) in enumerate(zip(*inps)):
|
|
|
|
| 146 |
if b == 'Image':
|
| 147 |
if cond_name not in cond_models:
|
| 148 |
cond_models[cond_name] = get_cond_model(opt, getattr(ExtraCondition, cond_name))
|
| 149 |
+
conds.append(process_cond_module(opt, ims1[idx], 'image', cond_models[cond_name]))
|
| 150 |
else:
|
| 151 |
+
conds.append(process_cond_module(opt, ims2[idx], cond_name, None))
|
| 152 |
|
| 153 |
features = dict()
|
| 154 |
for idx, cond_name in enumerate(activated_conds):
|