# Object Tracking using YOLOv3, Deep Sort and Tensorflow
This repository implements YOLOv3 and Deep SORT in order to perfrom real-time object tracking. Yolov3 is an algorithm that uses deep convolutional neural networks to perform object detection. We can feed these object detections into Deep SORT (Simple Online and Realtime Tracking with a Deep Association Metric) in order for a real-time object tracker to be created.
![Demo of Object Tracker](data/helpers/demo.gif)
## Getting started
#### Conda (Recommended)
```bash
# Tensorflow CPU
conda env create -f conda-cpu.yml
conda activate tracker-cpu
# Tensorflow GPU
conda env create -f conda-gpu.yml
conda activate tracker-gpu
```
#### Pip
```bash
# TensorFlow CPU
pip install -r requirements.txt
# TensorFlow GPU
pip install -r requirements-gpu.txt
```
### Nvidia Driver (For GPU, if you haven't set it up already)
```bash
# Ubuntu 18.04
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt install nvidia-driver-430
# Windows/Other
https://www.nvidia.com/Download/index.aspx
```
### Downloading official pretrained weights
For Linux: Let's download official yolov3 weights pretrained on COCO dataset.
```
# yolov3
wget https://pjreddie.com/media/files/yolov3.weights -O weights/yolov3.weights
# yolov3-tiny
wget https://pjreddie.com/media/files/yolov3-tiny.weights -O weights/yolov3-tiny.weights
```
For Windows:
You can download the yolov3 weights by clicking [here](https://pjreddie.com/media/files/yolov3.weights) and yolov3-tiny [here](https://pjreddie.com/media/files/yolov3-tiny.weights) then save them to the weights folder.
### Using Custom trained weights
<strong> Learn How To Train Custom YOLOV3 Weights Here: https://www.youtube.com/watch?v=zJDUhGL26iU </strong>
Add your custom weights file to weights folder and your custom .names file into data/labels folder.
### Saving your yolov3 weights as a TensorFlow model.
Load the weights using `load_weights.py` script. This will convert the yolov3 weights into TensorFlow .tf model files!
```
# yolov3
python load_weights.py
# yolov3-tiny
python load_weights.py --weights ./weights/yolov3-tiny.weights --output ./weights/yolov3-tiny.tf --tiny
# yolov3-custom (add --tiny flag if your custom weights were trained for tiny model)
python load_weights.py --weights ./weights/<YOUR CUSTOM WEIGHTS FILE> --output ./weights/yolov3-custom.tf --num_classes <# CLASSES>
```
After executing one of the above lines, you should see proper .tf files in your weights folder. You are now ready to run object tracker.
## Running the Object Tracker
Now you can run the object tracker for whichever model you have created, pretrained, tiny, or custom.
```
# yolov3 on video
python object_tracker.py --video ./data/video/test.mp4 --output ./data/video/results.avi
#yolov3 on webcam
python object_tracker.py --video 0 --output ./data/video/results.avi
#yolov3-tiny
python object_tracker.py --video ./data/video/test.mp4 --output ./data/video/results.avi --weights ./weights/yolov3-tiny.tf --tiny
#yolov3-custom (add --tiny flag if your custom weights were trained for tiny model)
python object_tracker.py --video ./data/video/test.mp4 --output ./data/video/results.avi --weights ./weights/yolov3-custom.tf --num_classes <# CLASSES> --classes ./data/labels/<YOUR CUSTOM .names FILE>
```
The output flag saves your object tracker results as an avi file for you to watch back. It is not necessary to have the flag if you don't want to save the resulting video.
There is a test video uploaded in the data/video folder called test.mp4. If you followed all the steps properly with the pretrained coco yolov3.weights model then when your run the object tracker wiht the first command above you should see the following.
#### Video Example
![Demo of Object Tracker](data/helpers/demo.gif)
#### Webcam Example
This is a demo of running the object tracker using the above command for running the object tracker on your webcam.
![Webcam Demo](data/helpers/webcam_demo.gif)
## Command Line Args Reference
```
load_weights.py:
--output: path to output
(default: './weights/yolov3.tf')
--[no]tiny: yolov3 or yolov3-tiny
(default: 'false')
--weights: path to weights file
(default: './weights/yolov3.weights')
--num_classes: number of classes in the model
(default: '80')
(an integer)
object_tracker.py:
--classes: path to classes file
(default: './data/labels/coco.names')
--video: path to input video (use 0 for webcam)
(default: './data/video/test.mp4')
--output: path to output video (remember to set right codec for given format. e.g. XVID for .avi)
(default: None)
--output_format: codec used in VideoWriter when saving video to file
(default: 'XVID)
--[no]tiny: yolov3 or yolov3-tiny
(default: 'false')
--weights: path to weights file
(default: './weights/yolov3.tf')
--num_classes: number of classes in the model
(default: '80')
(an integer)
--yolo_max_boxes: maximum number of detections at one time
(default: '100')
(an integer)
--yolo_iou_threshold: iou threshold for how close two boxes can be before they are detected as one box
(default: 0.5)
(a float)
--yolo_score_threshold: score threshold for confidence level in detection for detection to count
(default: 0.5)
(a float)
```
## Acknowledgments
* [Yolov3 TensorFlow Amazing Implementation](https://github.com/zzh8829/yolov3-tf2)
* [Deep SORT Repository](https://github.com/nwojke/deep_sort)
* [Yolo v3 official paper](https://arxiv.org/abs/1804.02767)
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
Monet_traffic.zip (92个子文件)
Monet_traffic
yolov3_tf2
batch_norm.py 397B
utils.py 6KB
dataset.py 6KB
models.py 12KB
__pycache__
models.cpython-37.pyc 10KB
dataset.cpython-37.pyc 4KB
utils.cpython-37.pyc 5KB
models.cpython-36.pyc 10KB
batch_norm.cpython-36.pyc 710B
utils.cpython-36.pyc 5KB
batch_norm.cpython-37.pyc 737B
dataset.cpython-36.pyc 4KB
banmaxian.txt 107B
shixian.txt 183B
requirements-gpu.txt 84B
.DS_Store 14KB
simsun.ttc 10.01MB
detection.txt 5KB
load_weights.py 1KB
车道线标定.py 2KB
model_data
yolo_anchors.txt 77B
DeepSORT.png 460KB
DeepSORT.pdf 333KB
coco_classes.txt 705B
mars-small128.pb 10.72MB
voc_classes.txt 155B
config.js 262B
.vscode
settings.json 86B
simsunttc
simsun.ttc 10.01MB
conda-cpu.yml 178B
out.png 2.13MB
requirements.txt 80B
weights
yolov3.tf.data-00001-of-00002 66KB
.DS_Store 6KB
yolov3.weights 236.52MB
yolov3.tf.index 24KB
yolov3.tf.data-00000-of-00002 236.52MB
.gitkeep 1B
checkpoint 75B
background.png 2.18MB
LICENSE 11KB
tools
generate_detections.py 8KB
__pycache__
generate_detections.cpython-36.pyc 8KB
generate_detections.cpython-37.pyc 8KB
freeze_model.py 8KB
conda-gpu.yml 220B
object_tracker.py 13KB
Monet_tracker.py 13KB
提取背景.py 368B
README.md 5KB
__pycache__
dw.cpython-37.pyc 1KB
predict.cpython-37.pyc 13KB
dingwei.cpython-37.pyc 3KB
dingwei.cpython-36.pyc 3KB
data
.DS_Store 8KB
labels
coco.names 705B
video
.DS_Store 6KB
test.mp4 18.87MB
fonts
futur.ttf 49KB
cascade.xml 336KB
.gitignore 2KB
deep_sort
preprocessing.py 2KB
detection.py 2KB
__init__.py 28B
tracker.py 5KB
linear_assignment.py 8KB
iou_matching.py 3KB
__pycache__
iou_matching.cpython-36.pyc 3KB
preprocessing.cpython-37.pyc 2KB
track.cpython-36.pyc 5KB
tracker.cpython-37.pyc 5KB
linear_assignment.cpython-37.pyc 7KB
iou_matching.cpython-37.pyc 3KB
detection.cpython-36.pyc 2KB
nn_matching.cpython-37.pyc 6KB
tracker.cpython-36.pyc 5KB
detection.cpython-37.pyc 2KB
kalman_filter.cpython-36.pyc 7KB
kalman_filter.cpython-37.pyc 7KB
__init__.cpython-37.pyc 170B
track.cpython-37.pyc 5KB
__init__.cpython-36.pyc 143B
linear_assignment.cpython-36.pyc 7KB
preprocessing.cpython-36.pyc 2KB
nn_matching.cpython-36.pyc 6KB
track.py 5KB
kalman_filter.py 8KB
nn_matching.py 6KB
banmaxian.txt 88B
resize.py 3KB
shixian.txt 171B
dingwei.py 3KB
共 92 条
- 1
fuhao7i
- 粉丝: 253
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0