bharath5673 / StrongSORT-YOLO

Real-time multi-camera multi-object tracker using (YOLOv5, YOLOv7,YOLOv8) and StrongSORT with OSNet
244 stars 71 forks source link

Model not working with custom YOLOv8 weights #29

Open userkw opened 3 months ago

userkw commented 3 months ago

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 commented 3 months ago

what is the error?

On Tue, Mar 19, 2024 at 9:01 PM userkw @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/bharath5673/StrongSORT-YOLO/issues/29, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBKZLLIESCIWZ6OFS7ZMILYZBK63AVCNFSM6AAAAABE5ZYE5OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE4TKMRZGY3DMMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

userkw commented 3 months ago

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 commented 3 months ago

@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'>