Skip to content

Commit

Permalink
Fix the bug that multi webcam detection failed with OpenVINO
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XevenQC committed Aug 2, 2023
1 parent f9f023a commit f03d467
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,23 @@ 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 f03d467

Please sign in to comment.