Spaces:
Running
on
L4
Running
on
L4
Alexander Becker
commited on
Commit
·
21f2036
1
Parent(s):
2b8654e
Crop and warn instead of error
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ from super_resolve import process
|
|
15 |
|
16 |
REPO_ID_EDSR = "prs-eth/thera-edsr-pro"
|
17 |
REPO_ID_RDN = "prs-eth/thera-rdn-pro"
|
18 |
-
MAX_SIZE =
|
19 |
|
20 |
print(f"JAX devices: {jax.devices()}")
|
21 |
print(f"JAX device type: {jax.devices()[0].device_kind}")
|
@@ -56,6 +56,9 @@ class TheraApp(DualVisionApp):
|
|
56 |
<p align="center" style="margin-top: 0px;">
|
57 |
<strong>Upload a photo or select an example below to do arbitrary-scale super-resolution in real time!</strong>
|
58 |
</p>
|
|
|
|
|
|
|
59 |
"""
|
60 |
)
|
61 |
|
@@ -96,8 +99,15 @@ class TheraApp(DualVisionApp):
|
|
96 |
model = kwargs.get("model", self.DEFAULT_MODEL)
|
97 |
|
98 |
if max(*image_in.size) > MAX_SIZE:
|
99 |
-
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
source = np.asarray(image_in) / 255.
|
103 |
|
|
|
15 |
|
16 |
REPO_ID_EDSR = "prs-eth/thera-edsr-pro"
|
17 |
REPO_ID_RDN = "prs-eth/thera-rdn-pro"
|
18 |
+
MAX_SIZE = 500
|
19 |
|
20 |
print(f"JAX devices: {jax.devices()}")
|
21 |
print(f"JAX device type: {jax.devices()[0].device_kind}")
|
|
|
56 |
<p align="center" style="margin-top: 0px;">
|
57 |
<strong>Upload a photo or select an example below to do arbitrary-scale super-resolution in real time!</strong>
|
58 |
</p>
|
59 |
+
<p align="center" style="margin-top: 0px;">
|
60 |
+
<strong>Note: The model has not been trained on input images with JPEG artifacts, so this may not work well.</strong>
|
61 |
+
</p>
|
62 |
"""
|
63 |
)
|
64 |
|
|
|
99 |
model = kwargs.get("model", self.DEFAULT_MODEL)
|
100 |
|
101 |
if max(*image_in.size) > MAX_SIZE:
|
102 |
+
gr.Warning(f"The image has been cropped to enable a smooth experience for all users.")
|
103 |
+
width, height = image_in.size
|
104 |
+
crop_width = min(width, MAX_SIZE)
|
105 |
+
crop_height = min(height, MAX_SIZE)
|
106 |
+
left = (width - crop_width) / 2
|
107 |
+
top = (height - crop_height) / 2
|
108 |
+
right = left + crop_width
|
109 |
+
bottom = top + crop_height
|
110 |
+
image_in = image_in.crop((left, top, right, bottom))
|
111 |
|
112 |
source = np.asarray(image_in) / 255.
|
113 |
|