Update app.py
Browse files
app.py
CHANGED
|
@@ -17,13 +17,13 @@ def predict(image):
|
|
| 17 |
width, height = image.size
|
| 18 |
ratio = width / height
|
| 19 |
if(width > height):
|
| 20 |
-
|
| 21 |
-
|
| 22 |
else:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
resized_image = TF.resize(image, (
|
| 27 |
|
| 28 |
padded_image = Image.new("RGB", (256, 256))
|
| 29 |
padded_image.paste(resized_image, (0, 0))
|
|
|
|
| 17 |
width, height = image.size
|
| 18 |
ratio = width / height
|
| 19 |
if(width > height):
|
| 20 |
+
new_height = int(256 / ratio)
|
| 21 |
+
new_width = 256
|
| 22 |
else:
|
| 23 |
+
new_width = int(256 * ratio)
|
| 24 |
+
new_height = 256
|
| 25 |
|
| 26 |
+
resized_image = TF.resize(image, (new_height, new_width))
|
| 27 |
|
| 28 |
padded_image = Image.new("RGB", (256, 256))
|
| 29 |
padded_image.paste(resized_image, (0, 0))
|