FaceMaskDetection icon indicating copy to clipboard operation
FaceMaskDetection copied to clipboard

invalid index to scalar variable

Open simin75simin opened this issue 4 years ago • 2 comments

i tried running it and got the following error.

╰─$ py opencv_dnn_infer.py --img-path /home/<name>/Pictures/Webcam/2021-11-12-101657.jpg 
Traceback (most recent call last):
  File "opencv_dnn_infer.py", line 117, in <module>
    run_on_video(Net, video_path, conf_thresh=0.5)
  File "opencv_dnn_infer.py", line 89, in run_on_video
    img_raw = inference(Net, img_raw, target_shape=(260, 260), conf_thresh=conf_thresh)
  File "opencv_dnn_infer.py", line 47, in inference
    y_bboxes_output, y_cls_output = net.forward(getOutputsNames(net))
  File "opencv_dnn_infer.py", line 41, in getOutputsNames
    return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]
  File "opencv_dnn_infer.py", line 41, in <listcomp>
    return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.

help plz.

simin75simin avatar Nov 19 '21 10:11 simin75simin

nvm somehow i is a scalar now so just remove the [0]

simin75simin avatar Nov 19 '21 10:11 simin75simin

Why I need to remove [0] in windows 10, but in Jetson TX2 some devices need to remove some don't need remove.

aa389393 avatar Mar 10 '22 08:03 aa389393