Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in detect_dual.py: s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string #515

Open
JFMeyer2k opened this issue Jun 25, 2024 · 0 comments

Comments

@JFMeyer2k
Copy link

JFMeyer2k commented Jun 25, 2024

I am training a YoloV9-e model by

python3 train_dual.py --workers 4 --device 0 --batch 8 --data data/custom.yaml --img 650 --cfg models/detect/yolov9-e.yaml --weights 'yolov9-e.pt' --name yolov9-e --hyp hyp.scratch-high.yaml --min-items 0 --epochs 500 --close-mosaic 15

If I want to run an inference with

python3 detect_dual.py --nosave --save-txt --conf-thres 0.1 --imgsz 650 --weights '/yolo/yolov9//runs/train/yolov9-e/weights/best.pt' --source '/images/' --project '/images/'--name 'inference' --device 0

I get the error:

detect_dual: weights=['/home/ec2-user/yolo/yolov9//runs/train/yolov9-e/weights/best.pt'], source=/home/ec2-user/yolo/images/inference/Test/Hudl_Focus_Flex_FAI_vs_Netherlands_team_only_1/images_orig/, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=0, view_img=False, save_txt=True, save_conf=False, save_crop=False, nosave=True, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=/home/ec2-user/yolo/images/inference/Test/Hudl_Focus_Flex_FAI_vs_Netherlands_team_only_1/images_orig/, name=inference, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1
YOLO 🚀 v0.1-104-g5b1ea9a Python-3.10.9 torch-2.3.1+cu121 CUDA:0 (NVIDIA L4, 22491MiB)

Fusing layers... 
yolov9-e summary: 839 layers, 68553982 parameters, 0 gradients, 240.7 GFLOPs
Traceback (most recent call last):
  File "/home/ec2-user/yolo/yolov9/detect_dual.py", line 233, in <module>
    main(opt)
  File "/home/ec2-user/yolo/yolov9/detect_dual.py", line 228, in main
    run(**vars(opt))
  File "/opt/conda/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/ec2-user/yolo/yolov9/detect_dual.py", line 132, in run
    s += f"{n} {names[int(c)]}{'s' * (n > 1)}, "  # add to string
KeyError: 2

I already followed the advice from #11, #162, and #50

Where @WongKinYiu explicitly mentioned to

yolo-*.yaml: use detect_dual.py.
gelan-*.yaml: use detect.py.

However, even though I am using detect_dual.py and tried changing utils/general.py according to the previously mentioned issue (see above), I still get the above error.

Update:

@JFMeyer2k JFMeyer2k changed the title Error detect_dual.py Error in detect_dual.py: s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant