代码:
yolo_layers = [layers[i[0] - 1] for i in network.getUnconnectedOutLayers()]
报错:
Traceback (most recent call last):File "Run.py", line 201, in <module>main()File "Run.py", line 137, in maindetections = yolo.detect(yolo_img)File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in detectln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in <listcomp>ln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.
原因:
opencv版本不同引起的输出格式不同
解决:
yolo_layers = [layers[i - 1] for i in network.getUnconnectedOutLayers()]
参考:
https://stackoverflow.com/questions/69834335/loading-yolo-invalid-index-to-scalar-variable