Update app.py
Browse files
app.py
CHANGED
@@ -273,8 +273,20 @@ def object_detection_density_edge(image, conf_threshold=0.25, iou_threshold=0.45
|
|
273 |
|
274 |
|
275 |
# Function to resize and encode an image
|
276 |
-
def resize_image(image, max_size=
|
277 |
print("resize_image initialized")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
|
279 |
|
280 |
print("Create io.BytesIO instance")
|
|
|
273 |
|
274 |
|
275 |
# Function to resize and encode an image
|
276 |
+
def resize_image(image, max_size=3000):
|
277 |
print("resize_image initialized")
|
278 |
+
if max(image.size) > max_size:
|
279 |
+
|
280 |
+
print("Image size is over the max size, resizing")
|
281 |
+
ratio = max_size / float(max(image.size))
|
282 |
+
print("Ratio is: " + str(ratio))
|
283 |
+
|
284 |
+
new_size = tuple([int(x * ratio) for x in image.size])
|
285 |
+
print("New size is: " + str(new_size))
|
286 |
+
|
287 |
+
print("Resizing image")
|
288 |
+
image = image.resize(new_size, Image.LANCZOS)
|
289 |
+
|
290 |
|
291 |
|
292 |
print("Create io.BytesIO instance")
|