中文教程:
[BLOG] https://www.steamforfun.cn/?p=413
[CSDN] http://t.csdn.cn/8ZSka
@[TOC](Yolov5 Object Detection)
Object Detaction by pytorch, yolov5 and opencv. This project uses yolov5 to train a custom model. The project has the following functions.
Thanks to my idol ultralytics, yolov5 makes AI more easier. This project is based on yolov5, here is Yolov5 officail github webside. https://github.com/ultralytics/yolov5 After download this repository, yolov5.pt have been download in 'yolov5' so you could use five different pre-tained model to generate a custom model offline.
The directory also includes two parts, which this project calls the workspace.
The first part consists of three folders, named datasets, voc_dataset and yolo_dataset.
datasets: the final storage location of the custom dataset
voc_dataset: the storage location of pascal voc dataset
yolo_dataset: the storage location of yolo dataset [temporary]
The second part consists of four scrpit, named test_installation.py, preprocess.py, voc_to_yolo.py and data_split.py. Full comments are in every python script.
Install the item named "C++ for Desktop Development".
// Run Anaconda Prompt, coding...
conda create -n pytorch python>3.8
activate tensorflow
pip install pytorch
pip install labelImg
pip install opencv-python
pip install pillow
pip install shutil
pip install xml
pip install yaml
pip install json
pip install glob
- [Optional] Test the installation of yolov5 environment, please run "test_installation.py".
- [Optional] Put images in folder named "voc_dataset", subfolders named "classes_index".
- Run "preprocess.py" to rename and resize the images.
- Run labelImg to annotate all the images.
- [Optional] Run "voc_to_yolo.py", transform your dataset from pascal voc format to yolo format.
- Run "data_split.py" to split yolo_dataset, generate train, valid and test dataset. In addition, you could enter "Y/N" to Confirm whether to generate final dataset and move to 'datasets'.
- Follow yolov5 officail guidence to train and deploy your custom model.