Fix the bug that multi webcam detection failed with OpenVINO (#11935)
* 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>pull/10752/head^2
parent
69b0faf2f7
commit
c0b0729386
14
detect.py
14
detect.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue