The installation went flawlessly but there seems to be an incompatibility issue with the newest version (commit #10220 SHA: 6992dde4bd628f6bffe7d4c5025afadf79ed679b of yoloV5:
When executing python detector.py with the specified parameters, we encountered:
ImportError: cannot import name ‘scale_coords’ from ‘utils.general’
The detection window did not open.
In some version of yoloV5, presumably commit #9570 on Sept. 24 2022:
“new scale_segments() function” the scale_coords function was changed to the scale_segments function. We tried earlier commits which at least opened the detection window but with a black screen and further issues arose:
“/home/(my paths)…/yolov5/detector.py”, line 100, in torch_thread
model = attempt_load(weights, map_location=device) # load FP32
TypeError: attempt_load() got an unexpected keyword argument ‘map_location’
The attempt_load() function apparently does not accept this argument.
We went down the road of even older commits but at one point there was an issue with the pytorch version, because the yoloV5 repo we chose was so old.
If you have any help or further questions please do not hesitate to ask. We think that an updated version of detector.py might fix the problem.
HI there! i am facing the similar issue with the detector.py which is
ImportError: cannot import name ‘scale_coords’ from ‘utils.general’
as someone mentioned in this post, after scale_coords changes to scale_segments still there are problems arose. did anyone solve detector.py errors without any problem ? if yes please feel free to suggest me.
My task is to track the objects along with their 3D information using Zed-2i. if anyone has any idea how it can be achieved please share your inputs.
Thank you
Parvathi
This is the actual solution. It’s difficult for us to follow every version of every yolov(x), so we have to stay at a specific commit. The problem is, the documentation seems better on the C++ sample, sorry for that. We’ll improve the python documentation.
Hello, can you be more specific about the exact yolov5 branch that worked for your python code? I’ve tried a few but always had mismatches in the interpreter or a blank screen in a window.
Thank you for the information and for helping out.
Sorry for the late response…
Verified on linux and jetson SDK computers.
Many thanks for the tips to every one of this chain.
momi193, your tip on the link to the code is great!
I am not sure if the following issue analysis is valid for this chain.
Bounding box of the detected object gets far longer height calculation in the xywh2abcd(xywh, im_shape) function. I’ve tested this from the latest sdk 4.0 down to 3.6.5 .
What could be the root cause for this?
I’m trying to use custom object detection python on jetson orin agx jet pack 5.1.1 with zed sdk ZED_SDK_Tegra_L4T35.3_v4.0.1.zstd and yolov5 v7.0.
In result, I’m getting Exception of AttributeError regarding the “DETECTION_MODEL” in line 166 of the detector.py script see below.
result of running command: python3 detector.py --weights yolov5m.pt
Intializing Network…
Initializing Camera…
Initialized Camera
Traceback (most recent call last):
File “detector.py”, line 256, in
main()
File “detector.py”, line 166, in main
obj_param.detection_model = sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS
AttributeError: module ‘pyzed.sl’ has no attribute ‘DETECTION_MODEL’
YOLOv5 v7.0-151-g3e14883 Python-3.8.10 torch-2.0.0 CPU
Fusing layers…
YOLOv5m_v6 summary: 290 layers, 21172173 parameters, 0 gradients
^CException ignored in: <module ‘threading’ from ‘/usr/lib/python3.8/threading.py’>
Traceback (most recent call last):
File “/usr/lib/python3.8/threading.py”, line 1388, in _shutdown
lock.acquire()
KeyboardInterrupt:
result of running in the debugger
Exception has occurred: AttributeError
module ‘pyzed.sl’ has no attribute ‘DETECTION_MODEL’
File “/usr/local/zed/samples/object detection/custom detector/python/pytorch_yolov5/detector.py”, line 166, in main
obj_param.detection_model = sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS
File “/usr/local/zed/samples/object detection/custom detector/python/pytorch_yolov5/detector.py”, line 256, in
main()
AttributeError: module ‘pyzed.sl’ has no attribute ‘DETECTION_MODEL’