yolov9
yolov9 copied to clipboard
`AttributeError: 'list' object has no attribute 'device'`
While trying to run detect.py
I encountered an error.
command:
!python detect.py --weights /content/weights/yolov9-e.pt --conf 0.1 --source /content/dog.jpeg
error:
detect: weights=['/content/weights/yolov9-e.pt'], source=/content/dog.jpeg, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLOv5 🚀 v0.1-2-ge7d68de Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)
Fusing layers...
Model summary: 1119 layers, 69470144 parameters, 0 gradients, 244.0 GFLOPs
Traceback (most recent call last):
File "/content/yolov9/detect.py", line 231, in <module>
main(opt)
File "/content/yolov9/detect.py", line 226, in main
run(**vars(opt))
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/content/yolov9/detect.py", line 102, in run
pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)
File "/content/yolov9/utils/general.py", line 905, in non_max_suppression
device = prediction.device
AttributeError: 'list' object has no attribute 'device'
reproducible example
https://colab.research.google.com/drive/1hq-hORpv8pHjwjBz-slPUuKfpXyTXSEg?usp=sharing
line 903 in utils/general.py
prediction = prediction[0][0] # select only inference output
Got same error in detect.py
@Dragos-Stan provides a temporal solution.
To inference yolov9 models, we need follow val_dual.py
to construct detect_dual.py
. Or do re-parameterization for yolov9 models, then using detect.py
.
Currently, re-parametwrization part is under construction.
It works!
https://github.com/WongKinYiu/yolov9/issues/11#issuecomment-1960078993 should be corrected.
line 903 in utils/general.py
prediction = prediction[0][1] # select only inference output, [0][0] for aux prediction, [0][1] for main prediction.
So, the correct one is as follows, right?
line 903 in utils/general.py
prediction = prediction[0][1]
So, the correct one is as follows, right?
line 903 in utils/general.py prediction = prediction[0][1]
I followed yr ways, it worked with yolov9-c and yolov9-e. But:
line 903 in utils/general.py
prediction = prediction[0]
worked with gelan-c.pt and gelan-e.pt.
Following this discussion, I opened a PR with a (probably temporal) fix. It makes detect.py
work with both yolov9
and gelan
models.
I am getting the same error and fixed the general.py file as here discussions https://github.com/WongKinYiu/yolov9/compare/main...noorkhokhar99:yolov9:patch-1
@SkalskiP Your fix is working for me for a yolov9-c model. Haven't tested ELAN.
Is this a better fix than @Dragos-Stan 's given it works for either architecture?
#11 (comment) should be corrected.
line 903 in utils/general.py prediction = prediction[0][1] # select only inference output, [0][0] for aux prediction, [0][1] for main prediction.
Hi @mkrupczak3 👋🏻 My fix should work with both GELAN and YOLOv9 architectures. Take a look here. I use it to run both models.
@SkalskiP I found your fix applies to detect.py
but does not fix val.py
. Fixing utils/general.py
according to WongKinYiu's comment fixes both however. I'm using that now
@mkrupczak3 what's wrong with validation? I've done it yesterday and it works for me.
Altering just detect.py
does not fix val.py
for dual models such as yolov9-c. Modifying utils/general.py
as described does fix val.py
however,
line 903 in utils/general.py prediction = prediction[0][0] # select only inference output
thanks
line 903 in utils/general.py prediction = prediction[0][0] # select only inference output
thanks
https://github.com/WongKinYiu/yolov9/issues/11#issuecomment-1960610186
Following this discussion, I opened a PR with a (probably temporal) fix. It makes work with both and models.
detect.py``yolov9``gelan
thanks,its work
Use detect_dual.py
instead of detect.py