Skip to content

Commit

Permalink
Fix the bug that multi webcam detection failed with OpenVINO (#11935)
Browse files Browse the repository at this point in the history
* Fix the bug that multi webcam detection failed with OpenVINO

It would failed with the following error when detect multi webcam.
"Input blob size is not equal network input size (2457600!=1228800)"

Signed-off-by: Chao Qin <chaoqin_cmkj@163.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Chao Qin <chaoqin_cmkj@163.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
XevenQC and pre-commit-ci[bot] committed Jan 3, 2024
1 parent 69b0faf commit c0b0729
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ def run(
im /= 255 # 0 - 255 to 0.0 - 1.0
if len(im.shape) == 3:
im = im[None] # expand for batch dim
if model.xml and im.shape[0] > 1:
ims = torch.chunk(im, im.shape[0], 0)

# Inference
with dt[1]:
visualize = increment_path(save_dir / Path(path).stem, mkdir=True) if visualize else False
pred = model(im, augment=augment, visualize=visualize)

if model.xml and im.shape[0] > 1:
pred = None
for image in ims:
if pred is None:
pred = model(image, augment=augment, visualize=visualize).unsqueeze(0)
else:
pred = torch.cat((pred, model(image, augment=augment, visualize=visualize).unsqueeze(0)), dim=0)
pred = [pred, None]
else:
pred = model(im, augment=augment, visualize=visualize)
# NMS
with dt[2]:
pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)
Expand Down

0 comments on commit c0b0729

Please sign in to comment.