Spaces:
Runtime error
Runtime error
Eugene Siow
commited on
Commit
·
30a37ef
1
Parent(s):
6ac361c
Add resize image.
Browse files
app.py
CHANGED
@@ -41,6 +41,10 @@ def get_model(model_name, scale):
|
|
41 |
|
42 |
def inference(img, scale_str, model_name):
|
43 |
scale = int(scale_str.replace('x', ''))
|
|
|
|
|
|
|
|
|
44 |
model = get_model(model_name, scale)
|
45 |
inputs = ImageLoader.load_image(img)
|
46 |
preds = model(inputs)
|
@@ -81,4 +85,4 @@ gr.Interface(
|
|
81 |
],
|
82 |
enable_queue=True,
|
83 |
allow_flagging=False,
|
84 |
-
).launch(debug=
|
|
|
41 |
|
42 |
def inference(img, scale_str, model_name):
|
43 |
scale = int(scale_str.replace('x', ''))
|
44 |
+
width, height = img.size
|
45 |
+
print(width, height)
|
46 |
+
if width > 2048 or height > 2048:
|
47 |
+
img = img.thumbnail((2048, 2048), Image.ANTIALIAS)
|
48 |
model = get_model(model_name, scale)
|
49 |
inputs = ImageLoader.load_image(img)
|
50 |
preds = model(inputs)
|
|
|
85 |
],
|
86 |
enable_queue=True,
|
87 |
allow_flagging=False,
|
88 |
+
).launch(debug=False)
|