Spaces:
Sleeping
Sleeping
nicer
Browse files- app.py +0 -4
- maskrcnn_benchmark/engine/predictor_glip.py +7 -0
app.py
CHANGED
@@ -61,10 +61,6 @@ athetics_params = {
|
|
61 |
|
62 |
def predict(image, text, ground_tokens=""):
|
63 |
ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
|
64 |
-
aspect_ratio = image.width / image.height
|
65 |
-
new_height = 500
|
66 |
-
new_width = int(new_height * aspect_ratio)
|
67 |
-
image = image.resize((new_width, new_height))
|
68 |
result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
69 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
70 |
return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]]
|
|
|
61 |
|
62 |
def predict(image, text, ground_tokens=""):
|
63 |
ground_tokens = None if ground_tokens.strip() == "" else ground_tokens.strip().split(";")
|
|
|
|
|
|
|
|
|
64 |
result, _ = glip_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
65 |
fiber_result, _ = fiber_demo.run_on_web_image(deepcopy(image[:, :, [2, 1, 0]]), text, 0.5, ground_tokens, **athetics_params)
|
66 |
return result[:, :, [2, 1, 0]], fiber_result[:, :, [2, 1, 0]]
|
maskrcnn_benchmark/engine/predictor_glip.py
CHANGED
@@ -147,6 +147,13 @@ class GLIPDemo(object):
|
|
147 |
top_predictions = self._post_process(predictions, thresh)
|
148 |
|
149 |
result = original_image.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
if self.show_mask_heatmaps:
|
151 |
return self.create_mask_montage(result, top_predictions)
|
152 |
|
|
|
147 |
top_predictions = self._post_process(predictions, thresh)
|
148 |
|
149 |
result = original_image.copy()
|
150 |
+
def resize_image_by_height(image, new_height=500):
|
151 |
+
height, width, _ = image.shape
|
152 |
+
aspect_ratio = width / height
|
153 |
+
new_width = int(new_height * aspect_ratio)
|
154 |
+
resized_image = cv2.resize(image, (new_width, new_height))
|
155 |
+
return resized_img
|
156 |
+
result = resize_image_by_height(result)
|
157 |
if self.show_mask_heatmaps:
|
158 |
return self.create_mask_montage(result, top_predictions)
|
159 |
|