Closed prashant-py-debug closed 2 years ago
I have solved the above issue. but after running the video for a while i am receiving this error message. outputs = deepsort.update(xywhs, confs, clss, frame) File "C:\Third_eye_approach3_yolov5\tracking\Yolov5_DeepSort_Pytorch\deep_sort_pytorch\deep_sort\deep_sort.py", line 39, in update self.tracker.update(detections, classes) File "C:\Third_eye_approach3_yolov5\tracking\Yolov5_DeepSort_Pytorch\deep_sort_pytorch\deep_sort\sort\tracker.py", line 78, in update self.tracks[track_idx].update( File "C:\Third_eye_approach3_yolov5\tracking\Yolov5_DeepSort_Pytorch\deep_sort_pytorch\deep_sort\sort\track.py", line 155, in update self.mean, self.covariance = kf.update( File "C:\Third_eye_approach3_yolov5\tracking\Yolov5_DeepSort_Pytorch\deep_sort_pytorch\deep_sort\sort\kalman_filter.py", line 174, in update chol_factor, lower = scipy.linalg.cho_factor( File "C:\Users\prash\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\linalg\decomp_cholesky.py", line 152, in cho_factor c, lower = _cholesky(a, lower=lower, overwrite_a=overwrite_a, clean=False, File "C:\Users\prash\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\linalg\decomp_cholesky.py", line 37, in _cholesky raise LinAlgError("%d-th leading minor of the array is not positive " numpy.linalg.LinAlgError: 2-th leading minor of the array is not positive definite
hi , i am trying to use the deepsort with yolo5s to get the bboxes for downstream use like showing the trajectory of the object. what i am doing:
My code: ` import os os.environ["OMP_NUM_THREADS"] = "1" os.environ["OPENBLAS_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" os.environ["VECLIB_MAXIMUM_THREADS"] = "1" os.environ["NUMEXPR_NUM_THREADS"] = "1"
import sys sys.path.insert(0, './yolov5')
from yolov5.models.experimental import attempt_load from yolov5.utils.downloads import attempt_download from yolov5.models.common import DetectMultiBackend from yolov5.utils.datasets import LoadImages, LoadStreams from yolov5.utils.general import LOGGER, check_img_size, non_max_suppression, scale_coords, check_imshow, xyxy2xywh from yolov5.utils.torch_utils import select_device, time_sync from yolov5.utils.plots import Annotator, colors from deep_sort_pytorch.utils.parser import get_config from deep_sort_pytorch.deep_sort import DeepSort import argparse import os import platform import shutil import time from pathlib import Path import cv2 import torch import torch.backends.cudnn as cudnn import numpy as np
path = "road.mp4" deep_sort_weights = 'deep_sort_pytorch/deep_sort/deep/checkpoint/ckpt.t7' config_deepsort="deep_sort_pytorch/configs/deep_sort.yaml" font = cv2.FONT_HERSHEY_SIMPLEX
names = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
initialize deepsort
cfg = get_config() cfg.merge_from_file(config_deepsort) attempt_download(deep_sort_weights, repo='mikel-brostrom/Yolov5_DeepSort_Pytorch') deepsort = DeepSort(cfg.DEEPSORT.REID_CKPT, max_dist=cfg.DEEPSORT.MAX_DIST, min_confidence=cfg.DEEPSORT.MIN_CONFIDENCE, max_iou_distance=cfg.DEEPSORT.MAX_IOU_DISTANCE, max_age=cfg.DEEPSORT.MAX_AGE, n_init=cfg.DEEPSORT.N_INIT, nn_budget=cfg.DEEPSORT.NN_BUDGET, use_cuda=True)
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
def x1y1x2y2_to_xywh(x1y1x2y2): xywhs = torch.zeros_like(x1y1x2y2) for i,xyxy in enumerate(x1y1x2y2): x1,y1,x2,y2 = xyxy[0],xyxy[1],xyxy[2],xyxy[3] w = x2 - x1 h = y2 - y1 xywhs[i,0] = x1 xywhs[i,1] = y1 xywhs[i,2] = w xywhs[i,3] = h return xywhs
cap = cv2.VideoCapture(path) while True:
`