Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -783,6 +783,16 @@ class Upscale:
|
|
| 783 |
print(f"> Processing image {gallery_idx:02d}, Shape: {img_cv2.shape}")
|
| 784 |
bg_upsample_img = None
|
| 785 |
if upscale_model and self.realesrganer and hasattr(self.realesrganer, "enhance"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
bg_upsample_img, _ = auto_split_upscale(img_cv2, self.realesrganer.enhance, self.scale) if is_auto_split_upscale else self.realesrganer.enhance(img_cv2, outscale=self.scale)
|
| 787 |
current_progress += progressRatio/progressTotal
|
| 788 |
if progress:
|
|
|
|
| 783 |
print(f"> Processing image {gallery_idx:02d}, Shape: {img_cv2.shape}")
|
| 784 |
bg_upsample_img = None
|
| 785 |
if upscale_model and self.realesrganer and hasattr(self.realesrganer, "enhance"):
|
| 786 |
+
# ---------------- SAFETY GUARD ----------------
|
| 787 |
+
h, w = img_cv2.shape[:2]
|
| 788 |
+
MAX_OUTPUT_PIXELS = 80_000_000
|
| 789 |
+
out_pixels = h * w * (self.scale ** 2)
|
| 790 |
+
|
| 791 |
+
if out_pixels > MAX_OUTPUT_PIXELS:
|
| 792 |
+
raise RuntimeError(
|
| 793 |
+
f"Image too large for upscale: {h}x{w} @ x{self.scale}"
|
| 794 |
+
)
|
| 795 |
+
# ----------------------------------------------
|
| 796 |
bg_upsample_img, _ = auto_split_upscale(img_cv2, self.realesrganer.enhance, self.scale) if is_auto_split_upscale else self.realesrganer.enhance(img_cv2, outscale=self.scale)
|
| 797 |
current_progress += progressRatio/progressTotal
|
| 798 |
if progress:
|