yolov8_tracking reproduction

foreword

Detection and tracking are always inseparable brothers. Today, I chose a relatively well-known network to reproduce the tracking effect.

first look at the effect

insert image description here

yolov8_tracking reproduction

clone warehouse

Warehouse Address

https://github.com/mikel-brostrom/yolov8_tracking

Command Line

git clone --recurse-submodules https://github.com/mikel-brostrom/yolov8_tracking.git

Note: yolov8_trackingThere are sub-warehouses in the warehouse, so you need to use--recurse-submodules

Environment configuration

conda create -n yolo-track python=3.8
cd yolov8_tracking
pip install -r requirements.txt

numpy installation error

Error message

Using cached oauthlib-3.2.2-py3-none-any.whl (151 kB)
Building wheels for collected packages: lap
  Building wheel for lap (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 236, in <module>
          setup_package()
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lap
  Running setup.py clean for lap
Failed to build lap
Installing collected packages: lap, executing, easydict, backcall, zipp, urllib3, typing-extensions, traitlets, tensorboard-data-server, sympy, soupsieve, smmap, six, rsa, PyYAML, PySocks, pyparsing, pygments, pyasn1-modules, psutil, protobuf, prompt-toolkit, Pillow, parso, packaging, oauthlib, numpy, networkx, MarkupSafe, kiwisolver, idna, grpcio, fonttools, filelock, decorator, cycler, colorama, charset-normalizer, cachetools, absl-py, werkzeug, tqdm, sentry-sdk, scipy, requests, python-dateutil, opencv-python, matplotlib-inline, jinja2, jedi, importlib-resources, importlib-metadata, google-auth, gitdb, contourpy, beautifulsoup4, asttokens, torch, stack-data, requests-oauthlib, pandas, matplotlib, markdown, gitpython, torchvision, thop, seaborn, ipython, google-auth-oauthlib, gdown, filterpy, tensorboard, ultralytics
  Running setup.py install for lap ... error
  error: subprocess-exited-with-error

  × Running setup.py install for lap did not run successfully.
  │ exit code: 1
  ╰─> [13 lines of output]
      Partial import of lap during the build process.
      Traceback (most recent call last):
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 127, in get_numpy_status
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 236, in <module>
          setup_package()
        File "C:\Users\xinxi\AppData\Local\Temp\pip-install-dfe22xmq\lap_189420c6b93848c5baadcb9e681756d7\setup.py", line 220, in setup_package
          raise ImportError('lap requires numpy, '
      ImportError: lap requires numpy, please "pip install numpy".
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lap

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Solution

The above is very clear, ImportError: lap requires numpy, please "pip install numpy"
So, manually install numpy first

pip install numpy

then continue

pip install -r requirements.txt

recurring network

Reproduce using the camera

python track.py --source 0

weight file error

Error message

track: yolo_weights=E:\1\yolo_track\yolov8_tracking\weights\yolov8s-seg.pt, reid_weights=E:\1\yolo_track\yolov8_tracking\weights\osnet_x0_25_msmt17.pt, tracking_method=deepocsort, tracking_config=trackers\deepocsort\configs\deepocsort.yaml, source=0, 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_trajectories=False, save_vid=False, nosave=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, vid_stride=1, retina_masks=False
Ultralytics YOLOv8.0.20  Python-3.8.16 torch-2.0.0+cpu CPU
Downloading https://github.com/ultralytics/assets/releases/download/v9.0/yolov8s-seg.pt to E:\1\yolo_track\yolov8_tracking\weights\yolov8s-seg.pt...
ERROR: HTTP Error 404: Not Found
Re-attempting https://github.com/ultralytics/assets/releases/download/v9.0/yolov8s-seg.pt to E:\1\yolo_track\yolov8_tracking\weights\yolov8s-seg.pt...
curl: (3) URL using bad/illegal format or missing URL
ERROR: Downloaded file 'E:\1\yolo_track\yolov8_tracking\weights\yolov8s-seg.pt' does not exist or size is < min_bytes=100000.0
E:\1\yolo_track\yolov8_tracking\weights\yolov8s-seg.pt missing, try downloading from https://github.com/ultralytics/assets/releases/v9.0

Solution

The prompt here is that the file does not exist, and the url is actually wrong. The real url should be https://github.com/ultralytics/assets/releases/
insert image description here
Download the file manually, and then follow the path in the above error prompt, that is, place it in weightsthe folder

dd

uc?id=1Kkx2zW89jq_NETu4u42CFZTMVD5Hwm6e

  File "track.py", line 136, in run
    tracker = create_tracker(tracking_method, tracking_config, reid_weights, device, half)
  File "E:\1\yolo_track\yolov8_tracking\trackers\multi_tracker_zoo.py", line 69, in create_tracker
    botsort = OCSort(
  File "E:\1\yolo_track\yolov8_tracking\trackers\deepocsort\ocsort.py", line 360, in __init__
    self.embedder = ReIDDetectMultiBackend(weights=model_weights, device=device, fp16=fp16)
  File "E:\1\yolo_track\yolov8_tracking\trackers\strongsort\reid_multibackend.py", line 60, in __init__
    gdown.download(model_url, str(w), quiet=False)
  File "C:\Users\xinxi\miniconda3\envs\yolo-track\lib\site-packages\gdown\download.py", line 161, in download
    res = sess.get(url, stream=True, verify=verify)
  File "C:\Users\xinxi\miniconda3\envs\yolo-track\lib\site-packages\requests\sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "C:\Users\xinxi\miniconda3\envs\yolo-track\lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\xinxi\miniconda3\envs\yolo-track\lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\xinxi\miniconda3\envs\yolo-track\lib\site-packages\requests\adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='drive.google.com', port=443): Max retries exceeded with url: /uc?id=1Kkx2zW89jq_NETu4u42CFZTMVD5Hwm6e (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)')))

It seems to be a file problem again, look at the wrong record, please pay attention to this sentence

File "E:\1\yolo_track\yolov8_tracking\trackers\strongsort\reid_multibackend.py", line 60, in __init__
    gdown.download(model_url, str(w), quiet=False)

The corresponding source code is

        if w.suffix == '.pt':
            model_url = get_model_url(w)
            if not file_exists(w) and model_url is not None:
                gdown.download(model_url, str(w), quiet=False)
            elif file_exists(w):
                pass
            else:
                print(f'No URL associated to the chosen StrongSORT weights ({w}). Choose between:')
                show_downloadeable_models()
                exit()

Pay attention to model_urlthe variables, and finally you can locate reid_model_factory.pythe file. The corresponding download path is:
insert image description here
We download this file manually, and the downloaded file name is: osnet_x0_25_msmt17_combineall_256x128_amsgrad_ep150_stp60_lr0.0015_b64_fb10_softmax_labelsmooth_flip_jitter.pth
But you need to pay attention

 gdown.download(model_url, str(w), quiet=False)

In this statement, the second parameter of download is the renamed file name, which is wprinted out osnet_x0_25_msmt17.pt. Therefore, the above file needs to be renamed osnet_x0_25_msmt17.ptand placed in weightsthe folder.
Now in the weights folder, there is Two pt files (but in fact, only one is needed, and it is OK to read the code too much. It is estimated that it is a problem of passing parameters. Because of the existence of default parameters, it leads to relying on two pt files). Both files depend
insert image description here
on Download from google, if the download fails, you can comment or private message, I will send it separately.

other tests

$ python track.py --source 0                               # webcam
                           img.jpg                         # image
                           vid.mp4                         # video
                           path/                           # directory
                           path/*.jpg                      # glob
                           'https://youtu.be/Zgi9g1ksQHc'  # YouTube
                           'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream

Guess you like

Origin blog.csdn.net/2301_77258991/article/details/129792292