Code is cleaned and working fine now, promise 🤞
- Use YOLOv5 or EfficientDet for vehicle detection task, only considers objects in Region of Interest (ROI)
- Use DeepSORT for car tracking, not need to retrain this model, only inference
- Use Cosine Similarity to assign object's tracks to most similar directions.
- Count each type of vehicle on each direction.
- For inference, use this notebook
- To retrain detection model, follow instructions from my template
- AIC-HCMC-2020: link
- Direction and ROI annotation format:
cam_01.json # match video name
{
"shapes": [
{
"label": "zone",
"points": [[x1,y1], [x2,y2], [x3,y3], [x4,y4], ... ] #Points of a polygon
},
{
"label": "direction01",
"points": [[x1,y1], [x2,y2]] #Points of vector
},
{
"label": "direction{id}",
"points": [[x1,y1], [x2,y2]]
},...
],
}
- Download finetuned models from on AIC-HCMC-2020 dataset:
Model | Image Size | Weights | MAP-S | MAP-M | MAP-L | ALL |
---|---|---|---|---|---|---|
EfficientDet-D2 | 640x640 | link | 0.061 | 0.456 | 0.475 | 0.451 |
YOLOv5s | 640x640 | link | 0.17 | 0.466 | 0.487 | 0.466 |
YOLOv5m | 640x640 | link | 0.187 | 0.487 | 0.501 | 0.481 |
- File structure
this repo
│ detect.py
└───configs
│ configs.yaml # Contains model's configurations
│ cam_configs.yaml # Contains DEEPSORT's configuration for each video
- Install dependencies by
pip install -r requirements.txt
- To run full pipeline:
python run.py --input_path=<input video or dir> --output_path=<output dir> --weight=<trained weight>
- Extra Parameters:
- --min_conf: minimum confident for detection
- --min_iou: minimum iou for detection
- DeepSORT from https://github.com/ZQPei/deep_sort_pytorch
- YOLOv5 from https://github.com/ultralytics/yolov5
- Train YOLOv5 using https://github.com/kaylode/custom-template/tree/detection