Spaces:
Running
on
Zero
Running
on
Zero
Alexander Bagus
commited on
Commit
·
a30ad4e
1
Parent(s):
0d0dc50
app.py
CHANGED
|
@@ -118,7 +118,7 @@ def inference(
|
|
| 118 |
print("Error: input_image is empty.")
|
| 119 |
return None
|
| 120 |
|
| 121 |
-
|
| 122 |
|
| 123 |
# input_image, width, height = scale_image(input_image, image_scale)
|
| 124 |
# control_mode='HED'
|
|
@@ -139,19 +139,25 @@ def inference(
|
|
| 139 |
control_image, width, height = rescale_image(input_image, image_scale, 16)
|
| 140 |
control_image = control_image.resize((1024, 1024))
|
| 141 |
|
| 142 |
-
print("DEBUG:
|
|
|
|
| 143 |
control_image = processor(control_image, to_pil=True)
|
| 144 |
control_image = control_image.resize((width, height))
|
| 145 |
-
|
| 146 |
-
sample_size = [height, width]
|
| 147 |
-
if mask_image is not None:
|
| 148 |
-
mask_image = get_image_latent(mask_image, sample_size=sample_size)[:, :1, 0]
|
| 149 |
-
else:
|
| 150 |
-
mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 151 |
-
|
| 152 |
-
print("DEBUG: control_image_torch")
|
| 153 |
control_image_torch = get_image_latent(control_image, sample_size=sample_size)[:, :, 0]
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
# generation
|
| 156 |
if randomize_seed: seed = random.randint(0, MAX_SEED)
|
| 157 |
generator = torch.Generator().manual_seed(seed)
|
|
@@ -163,6 +169,8 @@ def inference(
|
|
| 163 |
width=width,
|
| 164 |
generator=generator,
|
| 165 |
guidance_scale=guidance_scale,
|
|
|
|
|
|
|
| 166 |
control_image=control_image_torch,
|
| 167 |
num_inference_steps=num_inference_steps,
|
| 168 |
control_context_scale=control_context_scale,
|
|
|
|
| 118 |
print("Error: input_image is empty.")
|
| 119 |
return None
|
| 120 |
|
| 121 |
+
|
| 122 |
|
| 123 |
# input_image, width, height = scale_image(input_image, image_scale)
|
| 124 |
# control_mode='HED'
|
|
|
|
| 139 |
control_image, width, height = rescale_image(input_image, image_scale, 16)
|
| 140 |
control_image = control_image.resize((1024, 1024))
|
| 141 |
|
| 142 |
+
print("DEBUG: control_image_torch")
|
| 143 |
+
sample_size = [height, width]
|
| 144 |
control_image = processor(control_image, to_pil=True)
|
| 145 |
control_image = control_image.resize((width, height))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
control_image_torch = get_image_latent(control_image, sample_size=sample_size)[:, :, 0]
|
| 147 |
|
| 148 |
+
# mask_image = None
|
| 149 |
+
# inpaint_image = None
|
| 150 |
+
|
| 151 |
+
# if mask_image is not None:
|
| 152 |
+
# mask_image = get_image_latent(mask_image, sample_size=sample_size)[:, :1, 0]
|
| 153 |
+
# else:
|
| 154 |
+
# mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 155 |
+
|
| 156 |
+
# if inpaint_image is not None:
|
| 157 |
+
# inpaint_image = get_image_latent(inpaint_image, sample_size=sample_size)[:, :, 0]
|
| 158 |
+
# else:
|
| 159 |
+
# inpaint_image = torch.zeros([1, 3, sample_size[0], sample_size[1]])
|
| 160 |
+
|
| 161 |
# generation
|
| 162 |
if randomize_seed: seed = random.randint(0, MAX_SEED)
|
| 163 |
generator = torch.Generator().manual_seed(seed)
|
|
|
|
| 169 |
width=width,
|
| 170 |
generator=generator,
|
| 171 |
guidance_scale=guidance_scale,
|
| 172 |
+
image = None,
|
| 173 |
+
mask_image = None,
|
| 174 |
control_image=control_image_torch,
|
| 175 |
num_inference_steps=num_inference_steps,
|
| 176 |
control_context_scale=control_context_scale,
|