Spaces:
Runtime error
Runtime error
Fix bad size of upscaled image in base 64
Browse files- ESRGANer.py +2 -2
- process_image.py +2 -1
ESRGANer.py
CHANGED
|
@@ -79,6 +79,8 @@ class ESRGANer():
|
|
| 79 |
tiles_x = math.ceil(width / self.tile_size)
|
| 80 |
tiles_y = math.ceil(height / self.tile_size)
|
| 81 |
|
|
|
|
|
|
|
| 82 |
# loop over all tiles
|
| 83 |
for y in range(tiles_y):
|
| 84 |
for x in range(tiles_x):
|
|
@@ -103,8 +105,6 @@ class ESRGANer():
|
|
| 103 |
tile_idx = y * tiles_x + x + 1
|
| 104 |
input_tile = self.img[:, :, input_start_y_pad:input_end_y_pad, input_start_x_pad:input_end_x_pad]
|
| 105 |
|
| 106 |
-
print("Image processing started...")
|
| 107 |
-
|
| 108 |
# upscale tile
|
| 109 |
try:
|
| 110 |
with torch.no_grad():
|
|
|
|
| 79 |
tiles_x = math.ceil(width / self.tile_size)
|
| 80 |
tiles_y = math.ceil(height / self.tile_size)
|
| 81 |
|
| 82 |
+
print("Image processing started...")
|
| 83 |
+
|
| 84 |
# loop over all tiles
|
| 85 |
for y in range(tiles_y):
|
| 86 |
for x in range(tiles_x):
|
|
|
|
| 105 |
tile_idx = y * tiles_x + x + 1
|
| 106 |
input_tile = self.img[:, :, input_start_y_pad:input_end_y_pad, input_start_x_pad:input_end_x_pad]
|
| 107 |
|
|
|
|
|
|
|
| 108 |
# upscale tile
|
| 109 |
try:
|
| 110 |
with torch.no_grad():
|
process_image.py
CHANGED
|
@@ -4,6 +4,7 @@ from run_cmd import run_cmd
|
|
| 4 |
from PIL import Image
|
| 5 |
import tempfile
|
| 6 |
import uuid
|
|
|
|
| 7 |
|
| 8 |
temp_path = tempfile.gettempdir()
|
| 9 |
|
|
@@ -25,6 +26,6 @@ def inference(img, size, type):
|
|
| 25 |
if size == "x2":
|
| 26 |
img_out = img_out.resize((img_out.width // 2, img_out.height // 2), resample=Image.BICUBIC)
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
return img_out, gr.File.update(value=OUTPUT_PATH)
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
import tempfile
|
| 6 |
import uuid
|
| 7 |
+
import numpy as np
|
| 8 |
|
| 9 |
temp_path = tempfile.gettempdir()
|
| 10 |
|
|
|
|
| 26 |
if size == "x2":
|
| 27 |
img_out = img_out.resize((img_out.width // 2, img_out.height // 2), resample=Image.BICUBIC)
|
| 28 |
|
| 29 |
+
img_out = np.array(img_out)
|
| 30 |
|
| 31 |
return img_out, gr.File.update(value=OUTPUT_PATH)
|