Digital Control System Project

Description:
This module is about object tracking based on Yolov5 algorithm, design by Tai Hoang and Con Muc :v

Usage

Preparation

$ pip install requirements.txt
$ cd yolov5 && pip install -r requirements.txt

(optional)

$ pip install roboflow

Inference:

  1. Specify “weights_path” (onnx weight) and set “view_img” to True if you want to view inference result
  2. Specify <image_path> and <video_path> to run

Yolov5

  1. Preapre dataset: get from my kaggle dataset
  2. 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
  1. 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)
  1. Export to onnx:
$ python export.py --weights path/to/best.pt --include onnx --dynamic --img 416 --data path/to/data.yaml

Github repo

link

Weights

In this project we use Yolov5 to train a custom model

Link to onnx weights

Link to pt weights