Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,16 +30,14 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2111.098
|
|
30 |
|
31 |
def inference(img,task):
|
32 |
os.system('mkdir temp')
|
33 |
-
|
|
|
|
|
34 |
width, height = img.size
|
35 |
if max(width,height) > max_res:
|
36 |
-
scale =
|
37 |
-
|
38 |
-
|
39 |
-
height = int(scale*max_res)
|
40 |
-
if height > max_res:
|
41 |
-
height = max_res
|
42 |
-
width = int(scale*max_res)
|
43 |
img = img.resize((width,height), Image.ANTIALIAS)
|
44 |
|
45 |
img.save("temp/image.jpg", "JPEG")
|
|
|
30 |
|
31 |
def inference(img,task):
|
32 |
os.system('mkdir temp')
|
33 |
+
|
34 |
+
# Resize the longer edge of the input image
|
35 |
+
max_res = 512
|
36 |
width, height = img.size
|
37 |
if max(width,height) > max_res:
|
38 |
+
scale = max_res /max(width,height)
|
39 |
+
width = int(scale*width)
|
40 |
+
height = int(scale*height)
|
|
|
|
|
|
|
|
|
41 |
img = img.resize((width,height), Image.ANTIALIAS)
|
42 |
|
43 |
img.save("temp/image.jpg", "JPEG")
|