Spaces:
Sleeping
Sleeping
resize
Browse files
app.py
CHANGED
@@ -67,8 +67,16 @@ def resize_image_by_height(image, new_height=500):
|
|
67 |
resized_image = cv2.resize(image, (new_width, new_height))
|
68 |
return resized_image
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
def predict(image, text, ground_tokens=""):
|
71 |
-
image =
|
72 |
ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
|
73 |
result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
74 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
|
|
67 |
resized_image = cv2.resize(image, (new_width, new_height))
|
68 |
return resized_image
|
69 |
|
70 |
+
def resize_image_by_width(image, new_width=500):
|
71 |
+
import cv2
|
72 |
+
height, width, _ = image.shape
|
73 |
+
aspect_ratio = height / width
|
74 |
+
new_height = int(new_width * aspect_ratio)
|
75 |
+
resized_image = cv2.resize(image, (new_width, new_height))
|
76 |
+
return resized_image
|
77 |
+
|
78 |
def predict(image, text, ground_tokens=""):
|
79 |
+
image = resize_image_by_width(image)
|
80 |
ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
|
81 |
result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
82 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|