Matskevichivan / Counting-People

29 stars 16 forks source link

Ask about IndexError #2

Open DDD-2000 opened 2 years ago

DDD-2000 commented 2 years ago

I have a IndexError: invalid index to scalar variable. in return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]

all Traceback:

File "C:\Users\wu\AppData\Local\Temp/ipykernel_5392/3847898624.py", line 1, in runfile('D:/SCHOOL WORK/Counting-People-master/counting_people.py', wdir='D:/SCHOOL WORK/Counting-People-master')

File "D:\soft\Anaconda\envs\opencv_gui\lib\site-packages\debugpy_vendored\pydevd_pydev_bundle\pydev_umd.py", line 167, in runfile execfile(filename, namespace)

File "D:\soft\Anaconda\envs\opencv_gui\lib\site-packages\debugpy_vendored\pydevd_pydev_imps_pydev_execfile.py", line 25, in execfile exec(compile(contents + "\n", file, 'exec'), glob, loc)

File "D:/SCHOOL WORK/Counting-People-master/counting_people.py", line 285, in outs = net.forward(getOutputsNames(net))

File "D:/SCHOOL WORK/Counting-People-master/counting_people.py", line 68, in getOutputsNames return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]

File "D:/SCHOOL WORK/Counting-People-master/counting_people.py", line 68, in return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]

IndexError: invalid index to scalar variable.

want to know how to fixed it

snakepowerpoint commented 2 years ago

Try return [layersNames[i - 1] for i in net.getUnconnectedOutLayers()]

It seems that the getUnconnectedOutLayers function returns different numpy format in different versions of opencv.