Description:
This module is about object tracking based on Yolov5 algorithm, design by Tai Hoang and Con Muc :v
$ pip install requirements.txt
$ cd yolov5 && pip install -r requirements.txt
(optional)
$ pip install roboflow
- Specify “weights_path” (onnx weight) and set “view_img” to True if you want to view inference result
- Specify <image_path> and <video_path> to run
- Preapre dataset: get from my kaggle dataset
- Run inference to generate more data:
$ python path/to/yolov5/detect.py
--weights path/to/weights.pt
--img <image_size>
--conf <confidence_score>
--source path/to/source
--save-txt
Notice:
- source: can be 0, 1 for webcam or image path
- generated data can be slightly different from desired, can use Roboflow to change it manually
- Training:
Training with pretrained custom weight:
$ python train.py --img 416 --batch 16 --epochs 100 --patience 25 --weights path/to/weights.pt --cache --cfg path/to/yolov5/models/ yolov5n.yaml --data path/to/data.yaml
Training from scratch (COCO weights):
$ python train.py --img 416 --batch 16 --epochs 100 --patience 25 --weights yolov5s.pt --cache --cfg path/to/yolov5/models/ yolov5n.yaml --data path/to/data.yaml
Ref: Yolov5
Notebook: Google Colab
Notice:
--patience
: early stopping after … epochs (read more at yolov5)- Weights: custom
.pt
weight can be downloaded here; COCO pretrained weights is given in yolov5 - Cfg: choose yolov5n or yolov5s (weights should be of the same model if using custom weights)
- Export to onnx:
$ python export.py --weights path/to/best.pt --include onnx --dynamic --img 416 --data path/to/data.yaml
In this project we use Yolov5 to train a custom model
Link to onnx weights
Link to pt weights