YOLOv5-DeepSORT-TensorRT 项目使用教程
1. 项目的目录结构及介绍
yolov5-deepsort-tensorrt/
├── README.md
├── requirements.txt
├── demo_trt.py
├── config/
│ ├── default.yaml
│ └── ...
├── src/
│ ├── yolov5/
│ │ ├── yolov5.cpp
│ │ └── ...
│ ├── deepsort/
│ │ ├── deepsort.cpp
│ │ └── ...
│ └── ...
├── weights/
│ ├── yolov5s.wts
│ └── ...
└── ...
- README.md: 项目说明文档。
- requirements.txt: 项目依赖文件。
- demo_trt.py: 项目启动文件。
- config/: 配置文件目录。
- src/: 源代码目录,包含 YOLOv5 和 DeepSORT 的实现。
- weights/: 模型权重文件目录。
2. 项目的启动文件介绍
demo_trt.py
这是项目的主要启动文件,用于运行 YOLOv5 和 DeepSORT 的 TensorRT 引擎。
import sys
import os
from src.yolov5 import YOLOv5
from src.deepsort import DeepSORT
def main():
# 加载配置
config_path = "config/default.yaml"
# 初始化 YOLOv5 和 DeepSORT
yolov5 = YOLOv5(config_path)
deepsort = DeepSORT(config_path)
# 运行检测和跟踪
yolov5.run()
deepsort.run()
if __name__ == "__main__":
main()
3. 项目的配置文件介绍
config/default.yaml
这是项目的默认配置文件,包含了 YOLOv5 和 DeepSORT 的参数设置。
yolov5:
weights: "weights/yolov5s.wts"
engine: "weights/yolov5s.engine"
input_size: [640, 640]
conf_thres: 0.5
iou_thres: 0.5
deepsort:
model_path: "weights/deepsort.engine"
max_dist: 0.2
min_confidence: 0.3
nms_max_overlap: 1.0
max_iou_distance: 0.7
max_age: 70
n_init: 3
nn_budget: 100
- yolov5: YOLOv5 相关配置。
- weights: YOLOv5 权重文件路径。
- engine: YOLOv5 TensorRT 引擎文件路径。
- input_size: 输入图像尺寸。
- conf_thres: 置信度阈值。
- iou_thres: IOU 阈值。
- deepsort: DeepSORT 相关配置。
- model_path: DeepSORT TensorRT 引擎文件路径。
- max_dist: 最大距离。
- min_confidence: 最小置信度。
- nms_max_overlap: NMS 最大重叠。
- max_iou_distance: 最大 IOU 距离。
- max_age: 最大年龄。
- n_init: 初始化次数。
- nn_budget: NN 预算。