code:
yolo_layers = [layers[i[0] - 1] for i in network.getUnconnectedOutLayers()]
report errors:
Traceback (most recent call last):
File "Run.py", line 201, in <module>
main()
File "Run.py", line 137, in main
detections = yolo.detect(yolo_img)
File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in detect
ln = [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.
Reason:
different opencv versions cause different output formats
Solution:
yolo_layers = [layers[i - 1] for i in network.getUnconnectedOutLayers()]
Reference:
https://stackoverflow.com/questions/69834335/loading-yolo-invalid-index-to-scalar-variable