Spaces:
Runtime error
Runtime error
Add type annotation
Browse files
model.py
CHANGED
|
@@ -48,9 +48,9 @@ SD_XL_BASE_RATIOS = {
|
|
| 48 |
}
|
| 49 |
|
| 50 |
|
| 51 |
-
def find_closest_aspect_ratio(target_width, target_height):
|
| 52 |
target_ratio = target_width / target_height
|
| 53 |
-
closest_ratio =
|
| 54 |
min_difference = float("inf")
|
| 55 |
|
| 56 |
for ratio_str, (width, height) in SD_XL_BASE_RATIOS.items():
|
|
@@ -64,7 +64,7 @@ def find_closest_aspect_ratio(target_width, target_height):
|
|
| 64 |
return closest_ratio
|
| 65 |
|
| 66 |
|
| 67 |
-
def resize_to_closest_aspect_ratio(image):
|
| 68 |
target_width, target_height = image.size
|
| 69 |
closest_ratio = find_closest_aspect_ratio(target_width, target_height)
|
| 70 |
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
|
| 51 |
+
def find_closest_aspect_ratio(target_width: int, target_height: int) -> str:
|
| 52 |
target_ratio = target_width / target_height
|
| 53 |
+
closest_ratio = ""
|
| 54 |
min_difference = float("inf")
|
| 55 |
|
| 56 |
for ratio_str, (width, height) in SD_XL_BASE_RATIOS.items():
|
|
|
|
| 64 |
return closest_ratio
|
| 65 |
|
| 66 |
|
| 67 |
+
def resize_to_closest_aspect_ratio(image: PIL.Image.Image) -> PIL.Image.Image:
|
| 68 |
target_width, target_height = image.size
|
| 69 |
closest_ratio = find_closest_aspect_ratio(target_width, target_height)
|
| 70 |
|