Update app.py
Browse files
app.py
CHANGED
@@ -41,8 +41,28 @@ def resize_image_dimensions(
|
|
41 |
original_resolution_wh: Tuple[int, int],
|
42 |
maximum_dimension: int = IMAGE_SIZE
|
43 |
) -> Tuple[int, int]:
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
#if width <= maximum_dimension and height <= maximum_dimension:
|
47 |
# width = width - (width % 32)
|
48 |
# height = height - (height % 32)
|
@@ -59,7 +79,7 @@ def resize_image_dimensions(
|
|
59 |
# new_width = new_width - (new_width % 32)
|
60 |
# new_height = new_height - (new_height % 32)
|
61 |
|
62 |
-
return
|
63 |
|
64 |
|
65 |
@spaces.GPU(duration=80)
|
|
|
41 |
original_resolution_wh: Tuple[int, int],
|
42 |
maximum_dimension: int = IMAGE_SIZE
|
43 |
) -> Tuple[int, int]:
|
44 |
+
# width, height = original_resolution_wh
|
45 |
+
w, h = original_resolution_wh
|
46 |
+
w_original, h_original = w, h
|
47 |
+
|
48 |
+
if w > h:
|
49 |
+
aspect_ratiow = w / h
|
50 |
+
w = IMAGE_SIZE
|
51 |
+
h = IMAGE_SIZE * aspect_ratiow
|
52 |
+
|
53 |
+
if h > w:
|
54 |
+
aspect_ratioh = h / w
|
55 |
+
w = IMAGE_SIZE * aspect_ratioh
|
56 |
+
h = IMAGE_SIZE
|
57 |
+
|
58 |
+
if h == w:
|
59 |
+
w = IMAGE_SIZE
|
60 |
+
h = IMAGE_SIZE
|
61 |
+
|
62 |
+
#was_resized = False
|
63 |
+
|
64 |
+
#w = w - w % 8
|
65 |
+
#h = h - h % 8
|
66 |
#if width <= maximum_dimension and height <= maximum_dimension:
|
67 |
# width = width - (width % 32)
|
68 |
# height = height - (height % 32)
|
|
|
79 |
# new_width = new_width - (new_width % 32)
|
80 |
# new_height = new_height - (new_height % 32)
|
81 |
|
82 |
+
return w, h
|
83 |
|
84 |
|
85 |
@spaces.GPU(duration=80)
|