Welcome to our guide on enhancing YOLOv2 to track multiple objects in real time! This project focuses on leveraging the power of YOLOv2 to generalize object tracking beyond a single type, effectively paving the way for versatile applications. In this blog post, we will walk you through the setup, getting started steps, and some troubleshooting tips.
Intro
The aim of this project is to facilitate real-time multiple object tracking using YOLOv2. While the default architecture is designed to track a single type of object, it can be easily modified to accommodate various objects. Initially, the project supports tracking people, as the pretrained weights for Deep SORT were specifically trained for this purpose.
Dependencies
Before diving into installation, make sure you have the following dependencies set up in your Python environment:
- Python
- NumPy
- OpenCV 3
- TensorFlow 1.0
- Cython
- Scikit-learn – [scikit-learn](http://scikit-learn.org/stable)
- Scikit-image – [scikit-image](http://scikit-image.org/download)
- FilterPy – [FilterPy](https://github.com/rlabbe/filterpy)
Setup
Follow these steps to set up your environment:
- Clone the repository:
git clone https://github.com/bendidi/Tracking-with-darkflow.git - Initialize all submodules:
git submodule update --init --recursive - Navigate to the darkflow directory and build in place:
python3 setup.py build_ext --inplace
Getting Started
Now that the environment is set up, let’s get started!
- Download the YOLO weights: For YOLO weights, you can read more [here](http://pjreddie.com/darknet/yolo). If you encounter issues while locating the weight files, you can find alternate versions [here](https://drive.google.com/drive/folders/0B1tW_VtY7onidEwyQ2FtQVplWEU).
- The architecture tested is
cfgyolo.cfgwith the weightsbinyolo.weights. - Download the Deep SORT weights from [here](https://drive.google.com/open?id=1eXm0EB8r4BywqHJzaorXTSOkIfFdTq59).
- Extract the folder and copy it to
deep_sort/resources. - Edit the flags in
run.pybased on your configuration: - demo: Path to your video file or set it to “camera” to use a live feed.
- model: Choose the YOLO configuration.
- load: Load the corresponding weights you just obtained.
- threshold: Set the confidence threshold for detections.
- gpu: Specify how much GPU to utilize.
- track: Activate or deactivate tracking.
- trackObj: List of objects to track
- saveVideo: Decide whether to save the processed video.
- display: Choose to display the video while processing or not.
After configuring, simply run:
python run.py
Now sit back and enjoy your real-time tracking experience!
Performance Insights
Here are some performance metrics for reference:
- YOLO with track flag set to False: 30 fps
- YOLO with track flag set to True (using Deep SORT): 14 fps
- YOLO with both track and background subtraction flags set to True: 10.5 fps
Keep in mind that skipping frames may boost speed but could decrease accuracy!
Troubleshooting
If you encounter any issues during setup or while running the project, here are some troubleshooting tips:
- Ensure all dependencies are installed correctly in your Python environment.
- Double-check the paths in your
run.pyfile to make sure they point to the correct weight files and configurations. - Try adjusting the
thresholdparameter to see if it improves the detection quality. - Reduce the resolution of the input video feed if you experience performance lags.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.
Disclaimer
This project utilizes codes forked from the following sources:
- [thtrieu/darkflow](https://github.com/thtrieu/darkflow) for real-time object detections and classifications.
- [nwojke/deep_sort](https://github.com/nwojke/deep_sort) for Simple Online Realtime Tracking with a Deep Association Metric.
Citation
If you’re excited about the technical underpinnings, here are some citation references you might find useful:
- Yolov2:
@article{redmon2016yolo9000,
title={YOLO9000: Better, Faster, Stronger},
author={Redmon, Joseph and Farhadi, Ali},
journal={arXiv preprint arXiv:1612.08242},
year={2016}
} - Deep SORT:
@article{Wojke2017simple,
title={Simple Online and Realtime Tracking with a Deep Association Metric},
author={Wojke, Nicolai and Bewley, Alex and Paulus, Dietrich},
journal={arXiv preprint arXiv:1703.07402},
year={2017}
}
Happy coding and tracking!
