Error
Opened this issue · 5 comments
Great work you did there :)
I am getting an error while running this code, can you please help me.
Opening videos/fire1.mp4 ....
Traceback (most recent call last):
File "yolo.py", line 143, in
start_video(video_path)
File "yolo.py", line 116, in start_video
model, classes, colors, output_layers = load_yolo()
File "yolo.py", line 24, in load_yolo
output_layers = [layers_names[i[0]-1] for i in net.getUnconnectedOutLayers()]
File "yolo.py", line 24, in
output_layers = [layers_names[i[0]-1] for i in net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.
I would be really glad if you could help me in this.
Thank you :)
@atulyakumar97 I could not reproduce the results for the same reason.
python3 yolo.py --play_video True --video_path videos/fire1.mp4
Opening videos/fire1.mp4 ....
Traceback (most recent call last):
File "yolo.py", line 143, in <module>
start_video(video_path)
File "yolo.py", line 116, in start_video
model, classes, colors, output_layers = load_yolo()
File "yolo.py", line 24, in load_yolo
output_layers = [layers_names[i[0]-1] for i in net.getUnconnectedOutLayers()]
File "yolo.py", line 24, in <listcomp>
output_layers = [layers_names[i[0]-1] for i in net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.
There is an issue with the recent version of OpenCV. I fixed this by downgrading to version 4.5.3.56
pip3 install opencv-python==4.5.3.56
There is an issue with the recent version of OpenCV. I fixed this by downgrading to version 4.5.3.56
pip3 install opencv-python==4.5.3.56
Not able to downgrade opencv-python. Which version of python need to install
This worked for me
YOLO Object Detection
python <= 3.7
ln = net.getLayerNames()
ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
python >3.7
ln = net.getLayerNames()
ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
Thanks