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

Model not working with custom YOLOv8 weights #29

Open
userkw opened this issue Mar 19, 2024 · 3 comments
Open

Model not working with custom YOLOv8 weights #29

userkw opened this issue Mar 19, 2024 · 3 comments

Comments

@userkw
Copy link

userkw commented Mar 19, 2024

I'm encountering an issue with my YOLOv8 model when attempting to use custom weights. Despite specifying the appropriate configuration parameters, the model does not seem to be detecting objects correctly. Below, I've outlined the specifics of the problem along with relevant code snippets and command line execution details:

""
model = YOLO('yolov8_cus.pt') # Loading custom YOLOv8 weights
model.overrides['conf'] = 0.3 # NMS confidence threshold
model.overrides['iou'] = 0.4 # NMS IoU threshold
model.overrides['agnostic_nms'] = False # NMS class-agnostic
model.overrides['max_det'] = 1000 # Maximum number of detections per image
names = model.names
""

cmd line i used :!python track_v8.py --source cas_yl.mp4 --track

@bharath5673
Copy link
Owner

bharath5673 commented Mar 20, 2024 via email

@userkw
Copy link
Author

userkw commented Mar 21, 2024

The problem arises when I use my model here:
model = YOLO('yolov8_cus.pt')
The tracker doesn't track anything, but when I use a pre-trained model like yolov8.pt, it works well.

@userkw
Copy link
Author

userkw commented Mar 22, 2024

@bharath5673 when i use my custom model i get this error i rename my custom model best.pt :yolov5s:
(env1) C:\Users\elkis\OneDrive\Desktop\StrongSORT-YOLO>python track_v5.py --source casgenerale_yl.mp4 --yolo-weights weights/yolov5s.pt --img 640
track_v5: yolo_weights=['weights/yolov5s.pt'], strong_sort_weights=C:\Users\elkis\OneDrive\Desktop\StrongSORT-YOLO\weights\osnet_x0_25_msmt17.pt, config_strongsort=strong_sort/configs/strong_sort.yaml, source=casgenerale_yl.mp4, imgsz=[640, 640], conf_thres=0.5, iou_thres=0.5, max_det=1000, device=, show_vid=False, save_txt=False, save_conf=False, save_crop=False, save_vid=False, nosave=False, count=False, draw=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\track, name=exp, exist_ok=False, line_thickness=2, hide_labels=False, hide_conf=False, hide_class=False, half=False, dnn=False
YOLOv5 2024-3-22 Python-3.8.18 torch-2.2.1+cpu CPU

Traceback (most recent call last):
File "track_v5.py", line 411, in
main(opt)
File "track_v5.py", line 406, in main
run(**vars(opt))
File "C:\Users\elkis\anaconda3\envs\env1\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "track_v5.py", line 114, in run
model = DetectMultiBackend(yolo_weights, device=device, dnn=dnn, data=None, fp16=half)
File "C:\Users\elkis\OneDrive\Desktop\StrongSORT-YOLO\yolov5\models\common.py", line 334, in init
model = attempt_load(weights if isinstance(weights, list) else w, device=device, inplace=True, fuse=fuse)
File "C:\Users\elkis\OneDrive\Desktop\StrongSORT-YOLO\yolov5\models\experimental.py", line 80, in attempt_load
ckpt = torch.load(attempt_download(w), map_location='cpu') # load
File "C:\Users\elkis\anaconda3\envs\env1\lib\site-packages\torch\serialization.py", line 1026, in load
return _load(opened_zipfile,
File "C:\Users\elkis\anaconda3\envs\env1\lib\site-packages\torch\serialization.py", line 1438, in _load
result = unpickler.load()
File "C:\Users\elkis\anaconda3\envs\env1\lib\site-packages\torch\serialization.py", line 1431, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'DetectionModel' on <module 'models.yolo' from 'C:\Users\elkis\OneDrive\Desktop\StrongSORT-YOLO\yolov5\models\yolo.py'>

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

2 participants