GithubHelp home page GithubHelp logo

snehitvaddi / yolov3-object-tracking Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 3.0 64.5 MB

Object tracking with YOLOv3, YOLOv3-tiny, Deep Sort and Tensorflow. This repository implements YOLOv3 and Deep SORT in order to perfrom real-time object tracking.

License: Apache License 2.0

Python 76.38% Jupyter Notebook 23.62%
yolov3 deep-learning machine-learning project btech final-year-project btech-project cse python programming object-detection

yolov3-object-tracking's Introduction

Object Tracking using YOLOv3, Deepsort 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.

πŸ›  Video Example

πŸ“‹ Example
Demo of Object Tracker
Demo of Object Tracker

Detailed tutorial by @The AI Guy on Object TrackingYoutube Tutorial.

🧠 Original Repo πŸ’‘ Colab Notebook
Github Colab

πŸƒβ€β™‚οΈ Getting started

πŸ“₯ Pip

# TensorFlow CPU
pip install -r requirements.txt

# TensorFlow GPU
pip install -r requirements-gpu.txt

πŸ“₯ Conda (Recommended)

# 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

πŸ›  Nvidia Driver (For GPU, if you haven't set it up already)

# Ubuntu 18.04
sudo apt-add-repository -r 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: You can 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

If you are on Windows, you can directly download the YOLOv3 weights from πŸ‘‰ here

Using Custom trained weights

Learn How To Train Custom YOLOV3 Weights Here: https://www.youtube.com/watch?v=zJDUhGL26iU

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` (May not properly in Colab)

#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 have followed all the steps properly then you should see the output as below by running first command.

python object_tracker.py --video ./data/video/test.mp4 --output ./data/video/results.avi

πŸ“§ Acknowledgments

yolov3-object-tracking's People

Contributors

dependabot[bot] avatar snehitvaddi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yolov3-object-tracking's Issues

Error while executing object_tracker.py in COLAB

W0315 07:24:22.164951 140703536494464 object_tracker.py:83] Empty Frame
W0315 07:24:22.265901 140703536494464 object_tracker.py:83] Empty Frame
W0315 07:24:22.366825 140703536494464 object_tracker.py:83] Empty Frame
Traceback (most recent call last):
File "object_tracker.py", line 163, in
app.run(main)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 312, in run
_run_main(main, args)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 258, in _run_main
sys.exit(main(argv))
File "object_tracker.py", line 155, in main
if FLAGS.ouput:
File "/usr/local/lib/python3.7/dist-packages/absl/flags/_flagvalues.py", line 481, in getattr
raise AttributeError(name)
AttributeError: ouput

No result
result

Thank!

Issue running in Colab

Hi man, when running "object_tracker.py" in Colab, it gives me this error: "cannot connect to X server". It is in fact in your Colab. The thing is that I cannot convert the video to mp4 because the "traffic-results2.avi" is empty, damaged. If I download it, it would't let me open it.

Any idea why? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.