If the article is an original article, please indicate the source of the original article when reprinting it.
1. Introduction to DeepSORT
DeepSORT is a computer vision tracking algorithm used to track objects while assigning an ID to each object. DeepSORT is an extension of the SORT (Simple Online Real-Time Tracking) algorithm. DeepSORT introduces deep learning into the SORT algorithm to reduce identity switching by adding appearance descriptors, thereby improving tracking efficiency.
This is to provide two demos, one is tracking and counting people; the other is vehicle counting and tracking;
2. Environment construction
I don’t have a GPU computer, so I modified some parameters and ran it on the CPU, just for learning and verification.
1. Create a virtual environment
conda create -n yolov5_deepsort_env python==3.8
2. Activate the environment
conda activate yolov5_deepsort_env
3. Download code
链接:https://pan.baidu.com/s/1CSfqIrDh-r17wDvm_rOF-A?pwd=1234
提取码:1234
4. Install yolov5
Enter the storage path and change it to your own path:
cd G:\enpei_Project_Code\02_deepsort\yolov5-deepsort
Install
pip install -r .\requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
Successful installation:
Next verify
3. Test
implement
python .\count_car.py
The result was an error
So the following handles various errors:
错误1:ImportError: cannot import name 'EasyDict' from 'easydict' (unknown location)
The reason is that the easydict version is wrong and the version needs to be specified.
Solution: Download easydict and reinstall it;
download link:
After downloading, unzip and install. The installation instructions are as follows:
python setup.py install --user
错误2:RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'
Reason: Because there is no Cuda support, the half-precision VAE module cannot be used for inference
Processing: Find half under the file and change all to float
错误3:AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
deal with:
Open D:\Anaconda3\envs\yolov5-6.0\lib\site-packages\torch\nn\modules\upsampling.py (note the path, it is under the environment)
Modify code
def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)
# return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
# recompute_scale_factor=self.recompute_scale_factor)
错误4:AttributeError: module 'numpy' has no attribute 'float'.
Reason: Wrong numpy version, reinstall numpy
deal with:
pip uninstall numpy
pip install numpy==1.20.3
After all errors are handled, run
python .\count_car.py
The code is relatively easy to understand and worth learning. However, the code will not be parsed here.
If there is any infringement or you need the complete code, please contact the blogger in time.