YOLOV4+DeepSort車流量檢測基礎版


YOLOV4+DeepSort車流量檢測基礎版

資源下載:

鏈接:https://pan.baidu.com/s/1Mv1VI1Wa5MUaHuKz9hlniQ
提取碼:lmpk
復制這段內容后打開百度網盤手機App,操作更方便哦--來自百度網盤超級會員V4的分享

1.配置Anaconda+Pycharm

參考:https://www.cnblogs.com/shijingwen/p/14181885.html

2.環境配置

在 Anconda Prompt 中,推薦創建新的虛擬環境

# 創建虛擬環境  xxx自己命名
conda create xxx
# 激活虛擬環境
​
# 安裝依賴,這里使用的TensorFlow 2  GPU版
pip install -r requirement-gpu.txt

Tips:

1. 使用tensorflow-gpu版需配置GPU參考:help/pdf/Windows版YOLOv4目標檢測實戰:Windows系統上的軟件安裝,如果不使用tensorflow-gpu使用配置文件:config/requirement.txt
2. requirement-gpu.txt或requirement.txt配置文件放C:\Users\xxxx下

 

 

 例如我的就把配置文件放在C:\Users\xxxx下(Ps:xxxx是我的當前用戶文件位置)

如果網絡不好可以使用國內鏡像, pip install xx -i http://xxx
國內的幾個常用鏡像地址:
豆瓣 : https://pypi.douban.com/simple
中國科學科技大學 : https://mirrors.ustc.edu.cn/pypi/web/simple/
清華大學 :https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

3.預訓練模型下載

本demo使用YOLOV4進行目標檢測+DeepSort進行跟蹤。

使用官方預訓練好的目標檢測模型,有80類物體可以檢測。

yolov4.weights:https://drive.google.com/file/d/1cewMfusmPjYWbrnuJRuKhPMwRe_b9PaT/view?usp=sharing

yolov4-tiny.weights(小模型,運行更快但精度略低):https://drive.google.com/file/d/1ZVmrenfMJBqIWf5f5NAHNBxQw6DNJgvO/view?usp=sharing

Tips:

模型在: model 文件夾下
 4.使用YOLOV4
# 將Darknet權重轉換為Tensorflow模型
python save_model.py --model yolov4 
​
# 在視頻上運行yolov4深度排序對象跟蹤器
python object_tracker.py --video ./data/video/test.mp4 --output ./outputs/demo.avi --model yolov4
​
# 在網絡攝像頭上運行yolov4深度排序對象跟蹤器(將視頻標志設置為0)
python object_tracker.py --video 0 --output ./outputs/webcam.avi --model yolov4
  1. 使用YOLOV4-Tiny

# 保存yolov4-tiny模型
python save_model.py --weights ./data/yolov4-tiny.weights --output ./checkpoints/yolov4-tiny-416 --model yolov4 --tiny
​
# 運行yolov4-tiny對象跟蹤器
python object_tracker.py --weights ./checkpoints/yolov4-tiny-416 --model yolov4 --video ./data/video/test.mp4 --output ./outputs/tiny.avi --tiny

6.目標跟蹤的范圍

一般情況下,默認是coco數據集中所有的80個類。可以在

demo/object_tracker.py中更改如下第160和163行位置代碼

Tips:

    # 注釋160,它讀取cocoa .names里的跟蹤類
160 #allowed_classes = list(class_names.values())
<span style="color: #008000;">#</span><span style="color: #008000;"> 自己從80類中選需要的類,這里只允許car類</span>

163 allowed_classes = ['car']

7.命令行參數參考

save_model.py:
  --weights: path to weights file
    (default: './data/yolov4.weights')
  --output: path to output
    (default: './checkpoints/yolov4-416')
  --[no]tiny: yolov4 or yolov4-tiny
    (default: 'False')
  --input_size: define input size of export model
    (default: 416)
  --framework: what framework to use (tf, trt, tflite)
    (default: tf)
  --model: yolov3 or yolov4
    (default: yolov4)

object_tracker.py:
--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: yolov4 or yolov4-tiny
(default:
'false')
--weights: path to weights file
(default:
'./checkpoints/yolov4-416')
--framework: what framework to use (tf, trt, tflite)
(default: tf)
--model: yolov3 or yolov4
(default: yolov4)
--size: resize images to
(default:
416)
--iou: iou threshold
(default:
0.45)
--score: confidence threshold
(default:
0.50)
--dont_show: dont show video output
(default: False)
--info: print detailed info about tracked objects
(default: False)

 

 Tips: YOLOV4+DeepSort車流量檢測網頁顯示


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM