Spaces:
Running
on
Zero
Running
on
Zero
Alexander Bagus
commited on
Commit
·
92fdedf
1
Parent(s):
d7a3206
22
Browse files
app.py
CHANGED
|
@@ -122,10 +122,11 @@ def inference(
|
|
| 122 |
print("Error: edit_dict or mask_image is empty.")
|
| 123 |
return None
|
| 124 |
|
| 125 |
-
|
|
|
|
| 126 |
# rescale to prevent OOM
|
| 127 |
input_image = edit_dict['background']
|
| 128 |
-
input_image, width, height = image_utils.rescale_image(input_image,
|
| 129 |
sample_size = [height, width]
|
| 130 |
|
| 131 |
print("DEBUG: inpaint_image")
|
|
@@ -136,14 +137,14 @@ def inference(
|
|
| 136 |
|
| 137 |
print("DEBUG: mask_image")
|
| 138 |
if mask_image is not None:
|
| 139 |
-
mask_image, w, h = image_utils.rescale_image(mask_image,
|
| 140 |
mask_image = get_image_latent(mask_image, sample_size=sample_size)[:, :1, 0]
|
| 141 |
else:
|
| 142 |
mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 143 |
|
| 144 |
# print("DEBUG: control_image_torch")
|
| 145 |
# processor = Processor('canny')
|
| 146 |
-
# control_image, w, h = image_utils.rescale_image(input_image, scale_target,
|
| 147 |
# control_image = control_image.resize((1024, 1024))
|
| 148 |
# control_image = processor(control_image, to_pil=True)
|
| 149 |
# control_image = control_image.resize((width, height))
|
|
|
|
| 122 |
print("Error: edit_dict or mask_image is empty.")
|
| 123 |
return None
|
| 124 |
|
| 125 |
+
upscale_target = 2
|
| 126 |
+
upscale_nearest = 16
|
| 127 |
# rescale to prevent OOM
|
| 128 |
input_image = edit_dict['background']
|
| 129 |
+
input_image, width, height = image_utils.rescale_image(input_image, upscale_target, upscale_nearest, max_size=1280)
|
| 130 |
sample_size = [height, width]
|
| 131 |
|
| 132 |
print("DEBUG: inpaint_image")
|
|
|
|
| 137 |
|
| 138 |
print("DEBUG: mask_image")
|
| 139 |
if mask_image is not None:
|
| 140 |
+
mask_image, w, h = image_utils.rescale_image(mask_image, upscale_target, upscale_nearest, max_size=1280)
|
| 141 |
mask_image = get_image_latent(mask_image, sample_size=sample_size)[:, :1, 0]
|
| 142 |
else:
|
| 143 |
mask_image = torch.ones([1, 1, sample_size[0], sample_size[1]]) * 255
|
| 144 |
|
| 145 |
# print("DEBUG: control_image_torch")
|
| 146 |
# processor = Processor('canny')
|
| 147 |
+
# control_image, w, h = image_utils.rescale_image(input_image, scale_target, upscale_nearest, max_size=1280)
|
| 148 |
# control_image = control_image.resize((1024, 1024))
|
| 149 |
# control_image = processor(control_image, to_pil=True)
|
| 150 |
# control_image = control_image.resize((width, height))
|