Spaces:
Running
Running
ciover2024
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -72,10 +72,19 @@ def load_upscaling_model():
|
|
72 |
|
73 |
def resize_image(orig_image):
|
74 |
aspect_ratio = orig_image.height / orig_image.width
|
75 |
-
|
|
|
|
|
76 |
new_height = int(new_width * aspect_ratio)
|
77 |
resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
# Function to resize image (simpler interpolation method for speed)
|
81 |
def resize_to_match(input_image, output_image):
|
|
|
72 |
|
73 |
def resize_image(orig_image):
|
74 |
aspect_ratio = orig_image.height / orig_image.width
|
75 |
+
old_width = orig_image.width
|
76 |
+
new_width = int(orig_image.width*1.2)
|
77 |
+
old_height = orig_image.height
|
78 |
new_height = int(new_width * aspect_ratio)
|
79 |
resized_image = orig_image.resize((new_width, new_height), Image.Resampling.LANCZOS)
|
80 |
+
|
81 |
+
left_crop = int((new_width - old_width)/2)
|
82 |
+
right_crop = new_width - int((new_width - old_width) / 2)
|
83 |
+
top_crop = int((new_height - old_height)/2)
|
84 |
+
bottom_crop = new_height - int((new_height - old_height) / 2)
|
85 |
+
cropped_image = resized_image.crop((left, upper,right,lower))
|
86 |
+
|
87 |
+
return cropped_image
|
88 |
|
89 |
# Function to resize image (simpler interpolation method for speed)
|
90 |
def resize_to_match(input_image, output_image):
|