Simple project that applied YOLOv5 in detection of dogs and cats
- Python 3.10.6
Install requirements
pip install -r requirements.txt
- Data used for this project can be found here.
- Dataset creation: Refer to YOLOv5 Train Custom Data for more information. In short, labels and bouding boxes were converted in to .txt format as follow:
class x_center y_center width height
- Data config for training: Standard YOLOv5 YAML format. Refer to
dataset.yaml
for details.
path: ../data/ # dataset root dir
train: train/images # train images (relative to 'path') 80% images
val: valid/images # val images (relative to 'path') 20% images
test: # test images (optional)
# Classes (2 classes)
names:
0: cat
1: dog
The model was trained with 10 epochs and standard COCO128 configuration (batch-size, image size and pretrained --weights yolov5s.pt
)
python train.py --img 640 --batch 16 --epochs 10 --data ../dataset.yaml --weights yolov5s.pt --device 0
Training results on valid set: Metrics:
detect.py
runs inference on a variety of sources.
python detect.py --weights [path-to-model] --source [path-to-file]
Input Image | Result Image |
---|---|