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
Read More:
- IndexError: list index out of range [How to Solve]
- Xpath Error: IndexError: list index out of range [How to Solve]
- Python errors: valueerror: if using all scalar values, you must pass an index (four solutions)
- RuntimeError: Invalid DISPLAY variable [How to Solve]
- [Solved] YOLO v5 Error: AttributeError: Can‘t get attribute SPPF on module models
- [Solved] pytorch loss.backward() Error: RuntimeError: Function AddBackward0 returned an invalid gradient at index 1…
- [Solved] RuntimeError: expected scalar type Long but found Float
- Autograd error in Python: runtimeerror: grad can be implicitly created only for scalar outputs
- [Solved] Runtime error: expected scalar type Float but found Double
- Python IndexError: too many indices for array: array is 1-dimensional, but 2 were i..
- [Solved] Mujoco Error: Missing path to your environment variable.
- Pytorch Error: runtimeerror: expected scalar type double but found float
- [Solved] Pytorch Error: RuntimeError: expected scalar type Double but found Float
- Python Valueerror: cannot index with vector containing Na / Nan values
- [resolution] str.contains() problem] valueerror: cannot index with vector containing Na/Nan values
- Tensorflow: Common Usage of tf.get_variable_scope()
- [Solved] Python Error: local variable ‘var‘ referenced before assignment
- [Solved] RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place
- Django PythonConsole error: Requested setting DEFAULT_INDEX_TABLESPACE