__yolov8+deepsort 部署 win10

 1.源码及环境准备

实现源码git仓库位置:
https://github.com/MuhammadMoinFaisal/YOLOv8-DeepSORT-Object-Tracking

谷歌原始deepsort 源码下载地址:

https://drive.google.com/drive/folders/1kna8eWGrSfzaR6DtNJ8_GchGgPMv3VC8

下载文件及路径:
deep_sort_pytorch-20240724T025234Z-001.zip

实际上是deep_sort_pytorch 的历史版本:

原始仓库位置:

https://github.com/ZQPei/deep_sort_pytorch.git

 环境:

Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz   2.59 GHz
NVIDIA GeForce GTX 1660 Ti with Max-Q Design
20.0 GB (19.8 GB 可用)

Windows 10 教育版
19044.1826
C:\Users\shaun>nvidia-smi
Thu Jul 25 08:49:45 2024
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 512.72       Driver Version: 512.72       CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
| N/A   48C    P8     4W /  N/A |     93MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

 

C:\Users\shaun>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:28:54_Pacific_Standard_Time_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0

2.部署

主要参考:源码仓库的readme.md 来部署:

YOLOv8-DeepSORT-Object-Tracking

conda create -n YOLOv8-DeepSORT-Object-TrackingPy python=3.8

conda activate YOLOv8-DeepSORT-Object-TrackingPy
git clone https://github.com/MuhammadMoinFaisal/YOLOv8-DeepSORT-Object-Tracking.git
cd YOLOv8-DeepSORT-Object-Tracking
pip install -e '.[dev]'
cd ultralytics/yolo/v8/detect

解压下载的deep_sort 包到当前目录:
deep_sort_pytorch-20240724T025234Z-001.zip

 在遇到下载torch 等大文件下载时间太长的,直接在浏览器下载,然后cd 进入到下载的安装包的位置,运行pip install 安装包全称

例如更换torch

本地下载,直接安装:
cd D:\__ai
pip install torch-1.13.1+cu116-cp38-cp38-win_amd64.whl

pip install torchvision-0.14.1+cu116-cp38-cp38-win_amd64.whl

 环境pip list

Package                    Version              Editable project location
-------------------------- -------------------- -----------------------------------------------------------------------------------------
absl-py                    2.1.0
antlr4-python3-runtime     4.9.3
asttokens                  2.4.1
astunparse                 1.6.3
Babel                      2.15.0
backcall                   0.2.0
backports.strenum          1.3.1
beautifulsoup4             4.12.3
build                      1.2.1
cachetools                 5.4.0
certifi                    2024.7.4
charset-normalizer         3.3.2
check-manifest             0.49
click                      8.1.7
colorama                   0.4.6
contourpy                  1.1.1
coverage                   7.6.0
cycler                     0.12.1
decorator                  5.1.1
easydict                   1.13
exceptiongroup             1.2.2
executing                  2.0.1
filelock                   3.15.4
fonttools                  4.53.1
fsspec                     2024.6.1
gdown                      5.2.0
ghp-import                 2.1.0
gitdb                      4.0.11
GitPython                  3.1.43
google-auth                2.32.0
google-auth-oauthlib       1.0.0
griffe                     0.48.0
grpcio                     1.65.1
hydra-core                 1.3.2
idna                       3.7
importlib_metadata         8.1.0
importlib_resources        6.4.0
iniconfig                  2.0.0
intel-openmp               2021.4.0
ipython                    8.12.3
jedi                       0.19.1
Jinja2                     3.1.4
kiwisolver                 1.4.5
Markdown                   3.6
MarkupSafe                 2.1.5
matplotlib                 3.7.5
matplotlib-inline          0.1.7
mergedeep                  1.3.4
mkdocs                     1.6.0
mkdocs-autorefs            1.0.1
mkdocs-get-deps            0.2.0
mkdocs-material            9.5.30
mkdocs-material-extensions 1.3.1
mkdocstrings               0.25.1
mkdocstrings-python        1.10.5
mkl                        2021.4.0
mpmath                     1.3.0
networkx                   3.1
numpy                      1.23.5
oauthlib                   3.2.2
omegaconf                  2.3.0
opencv-python              4.10.0.84
packaging                  24.1
paginate                   0.5.6
pandas                     2.0.3
parso                      0.8.4
pathspec                   0.12.1
pickleshare                0.7.5
pillow                     10.4.0
pip                        24.0
platformdirs               4.2.2
pluggy                     1.5.0
prompt_toolkit             3.0.47
protobuf                   5.27.2
psutil                     6.0.0
pure_eval                  0.2.3
pyasn1                     0.6.0
pyasn1_modules             0.4.0
Pygments                   2.18.0
pymdown-extensions         10.8.1
pyparsing                  3.1.2
pyproject_hooks            1.1.0
PySocks                    1.7.1
pytest                     8.3.1
pytest-cov                 5.0.0
python-dateutil            2.9.0.post0
pytz                       2024.1
PyYAML                     6.0.1
pyyaml_env_tag             0.1
regex                      2024.5.15
requests                   2.32.3
requests-oauthlib          2.0.0
rsa                        4.9
scipy                      1.10.1
seaborn                    0.13.2
setuptools                 71.0.4
six                        1.16.0
smmap                      5.0.1
soupsieve                  2.5
stack-data                 0.6.3
sympy                      1.13.1
tbb                        2021.13.0
tensorboard                2.14.0
tensorboard-data-server    0.7.2
thop                       0.1.1.post2209072238
tomli                      2.0.1
torch                      1.13.1+cu116
torchvision                0.14.1+cu116
tqdm                       4.66.4
traitlets                  5.14.3
typing_extensions          4.12.2
tzdata                     2024.1
ultralytics                8.0.3                d:\__ai\__deepsort\yolov8-deepsort-object-tracking\__code\yolov8-deepsort-object-tracking
urllib3                    2.2.2
watchdog                   4.0.1
wcwidth                    0.2.13
Werkzeug                   3.0.3
wheel                      0.43.0
zipp                       3.19.2

下载测试视频文件:安装了pip gdown也无法下载。直接打开浏览器,是个播放器页面,直接点击旁边的三个点,另存为,弹窗保存,然后修改名称为test3.mp4

gdown "https://drive.google.com/uc?id=1rjBn8Fl1E_9d0EMVtL24S9aNQOJAveR5&confirm=t"

 测试部署:

第一次会下载 yolov8l.pt,直接在浏览器地址栏输入     https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt 直接下载

在miniconda 的powershell 运行下载会中断,故直接在浏览器下载。

下载后将文件直接放到:YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\ 目录下

python predict.py model=yolov8l.pt source="test3.mp4" show=True

【报错1】

==============================
报错:
ModuleNotFoundError: No module named 'easydict'

解决办法:
pip install easydict
========================

【报错2】我的环境是需要更换torch版本,其他的资料提示需要安装VC_redist.x64.exe 环境的。

==============
运行报错:

(YOLOv8-DeepSORT-Object-TrackingPy) PS D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect> python predict.py model=yolov8l.pt source="test3.mp4" show=True
Traceback (most recent call last):
  File "predict.py", line 4, in <module>
    import torch
  File "C:\Users\shaun\.conda\envs\YOLOv8-DeepSORT-Object-TrackingPy\lib\site-packages\torch\__init__.py", line 143, in <module>
    raise err
OSError: [WinError 126] 找不到指定的模块。 
Error loading "C:\Users\shaun\.conda\envs\YOLOv8-DeepSORT-Object-TrackingPy\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

【解决办法】
更换pytoch 版本 

离线更换

位置在:
D:\__ai

本地下载,直接安装:
cd D:\__ai
pip install torch-1.13.1+cu116-cp38-cp38-win_amd64.whl

pip install torchvision-0.14.1+cu116-cp38-cp38-win_amd64.whl

【报错3】

【报错】

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.


【解决办法】
由于 numpy 新版已经没有 float 属性了,降版本解决 pip install numpy==1.23.5

pip install numpy==1.23.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

 

 

【运行结果】

[2024-07-24 20:57:07,561][root.tracker][INFO] - Loading weights from deep_sort_pytorch/deep_sort/deep/checkpoint/ckpt.t7... Done!
Ultralytics YOLOv8.0.3  Python-3.8.19 torch-1.13.1+cu116 CUDA:0 (NVIDIA GeForce GTX 1660 Ti with Max-Q Design, 6144MiB)
Fusing layers...
YOLOv8l summary: 268 layers, 43668288 parameters, 0 gradients, 165.2 GFLOPs
video 1/1 (1/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 3 cars, 1 truck, 52.0ms
video 1/1 (2/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 truck, 34.1ms
video 1/1 (3/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 truck, 35.1ms
video 1/1 (4/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 2 trucks, 36.1ms
video 1/1 (5/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 2 trucks, 36.1ms
video 1/1 (6/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 2 trucks, 35.9ms
video 1/1 (7/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 1 truck, 35.3ms
video 1/1 (8/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 1 truck, 35.9ms
video 1/1 (9/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 1 truck, 35.1ms
video 1/1 (10/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 1 truck, 31.2ms
video 1/1 (11/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 6 cars, 2 trucks, 31.2ms
video 1/1 (12/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 5 cars, 1 truck, 37.4ms
video 1/1 (13/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 6 cars, 1 truck, 31.2ms
video 1/1 (14/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 6 cars, 1 truck, 32.0ms
video 1/1 (15/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 7 cars, 1 truck, 45.0ms
.......
video 1/1 (502/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 3 trucks, 46.9ms video 1/1 (503/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 3 trucks, 31.2ms video 1/1 (504/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 train, 3 trucks, 37.8ms video 1/1 (505/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 3 cars, 3 trucks, 37.7ms video 1/1 (506/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 train, 3 trucks, 31.2ms video 1/1 (507/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 train, 3 trucks, 31.2ms video 1/1 (508/508) D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect\test3.mp4: 384x640 4 cars, 1 train, 3 trucks, 46.9ms Speed: 0.6ms pre-process, 36.0ms inference, 1.7ms postprocess per image at shape (1, 3, 640, 640) Results saved to D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\runs\detect\train5 (YOLOv8-DeepSORT-Object-TrackingPy) PS D:\__ai\__deepsort\YOLOv8-DeepSORT-Object-Tracking\__code\YOLOv8-DeepSORT-Object-Tracking\ultralytics\yolo\v8\detect>

 

 

posted @ 2024-07-24 20:26  OzTaking  阅读(222)  评论(0编辑  收藏  举报