IndexError: invalid index to scalar variable.

为了提取网络层每一层的名称,源代码:

import cv2
layersNames = net.getLayerNames()
output_layers_names = [layersNames[i[0]- 1] for i in net.getUnconnectedOutLayers()]

报错信息:

IndexError: invalid index to scalar variable._第1张图片

根据提示应该是无效的索引,因为是opencv下,考虑到版本问题,将[i[0]-1]改为[i-1]

output_layers_names = [layersNames[i- 1] for i in net.getUnconnectedOutLayers()]

运行成功

你可能感兴趣的:(python报错解决方案,python,jupyter,list)