The detections algorithm generated by YOLOv5 The tracking algorithm generated by Deep Sort Counting vehicles in area using pointPolygonTest
- Create new folder:
- Run Virtual Environment:
- Git clone:
git clone https://github.com/hiimjulyy0307/yolov5_deepsort_counting_vehicles.git
- Install package:
pip install -r requirements.txt
- CUDA Deep Neural Network (cuDNN)
- Setting cuDNN global folder
- Install pytorch versions PyTorch
Im using cudnn 11.6 so
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
Make sure that you Run Virtual Environment before you run :D
-
File Track.py detect + tracking and not counting
-
File Track2.py detect + tracking and counting vehicles using YOLOv5l.pt (you can changes version of YOLOv5 n s m l x)
-
File Track3.py detect + tracking and counting vehicles using Custom training model (vietnamese version - base on yolov5s.pt)
-
Can changes variable about yolo_model, deep_sort_model, source, ... from line 320 and up.
parser.add_argument('--yolo_model', nargs='+', type=str, default='yolov5l.pt', help='model.pt path(s)')
parser.add_argument('--deep_sort_model', type=str, default='osnet_x0_25')
parser.add_argument('--source', type=str, default='videos\hihi.mp4', help='source') # file/folder, 0 for webcam
parser.add_argument('--output', type=str, default='inference/output', help='output folder') # output folder
parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
parser.add_argument('--conf-thres', type=float, default=0.5, help='object confidence threshold')
parser.add_argument('--iou-thres', type=float, default=0.5, help='IOU threshold for NMS')
parser.add_argument('--fourcc', type=str, default='mp4v', help='output video codec (verify ffmpeg support)')
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--show-vid', action='store_false', help='display tracking video results')
parser.add_argument('--save-vid', action='store_true', help='save video tracking results')
parser.add_argument('--save-txt', action='store_true', help='save MOT compliant results to *.txt')
$ python track.py
track2.py
track3.py