Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -111,6 +111,14 @@ def fill_image(image, model_selection):
|
|
111 |
target_height=1280
|
112 |
overlap=48
|
113 |
fade_width=24
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
# Calculate the required height for 9:16 ratio
|
115 |
target_height = (source.width * target_ratio[1]) // target_ratio[0]
|
116 |
|
|
|
111 |
target_height=1280
|
112 |
overlap=48
|
113 |
fade_width=24
|
114 |
+
max_width = 720
|
115 |
+
# Resize the image if it's wider than max_width
|
116 |
+
if source.width > max_width:
|
117 |
+
scale_factor = max_width / source.width
|
118 |
+
new_width = max_width
|
119 |
+
new_height = int(source.height * scale_factor)
|
120 |
+
source = source.resize((new_width, new_height), Image.LANCZOS)
|
121 |
+
|
122 |
# Calculate the required height for 9:16 ratio
|
123 |
target_height = (source.width * target_ratio[1]) // target_ratio[0]
|
124 |
|