Skip to content

Commit

Permalink
fix(types): fix location and bounding box in converters (#3847)
Browse files Browse the repository at this point in the history
* fix(types): fix location and bounding box in converters

* fix(types): fix location and bounding box in converters
  • Loading branch information
hanxiao committed Nov 1, 2021
1 parent d78530b commit 6104e4b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions jina/types/document/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,17 @@ def convert_image_blob_to_sliding_windows(
strides=(row_step * stride_h, col_step * stride_w, row_step, col_step, 1),
writeable=False,
)

cur_loc_h, cur_loc_w = 0, 0
if self.location:
cur_loc_h, cur_loc_w = self.location[:2]

bbox_locations = [
(h * stride_h + cur_loc_h, w * stride_w + cur_loc_w, window_h, window_w)
for h in range(expanded_img.shape[0])
for w in range(expanded_img.shape[1])
]
expanded_img = expanded_img.reshape((-1, window_h, window_w, c))
if as_chunks:
bbox_locations = [
(h * stride_h, w * stride_w)
for h in range(expanded_img.shape[0])
for w in range(expanded_img.shape[1])
]
from . import Document

for location, _blob in zip(bbox_locations, expanded_img):
Expand Down

0 comments on commit 6104e4b

Please sign in to comment.