1. Create yolo v5 environment
yolov5 defect detection case
Summary
This article is mainly for the pure white who uses yolov5 for the first time and does not even configure the parameters, and records the process of my first use.
From downloading yolov5, installing dependencies, to training models and recognizing them.
2. Download yolov5 and install dependencies
git way:
git clone https://github.com/ultralytics/yolov5.git
Download the zip directly from github and unzip it:
https://github.com/ultralytics/yolov5
Use pycharm to directly open this folder as a project.
For the first use, we will use two files, and we will touch other files in the future:
train.py is our script for training
detect.py is the script for detection
The first step in setting up the environment is to install the graphics card driver, and then to install cuda toolkit and cudnn.
You can choose to run YoloV5 as a CPU or GPU environment. The default CPU environment does not need to be configured, and the GPU environment needs to install cuda corresponding to the graphics card version.
1. Create a new virtual environment in the anaconda environment
2. Activate the switching environment,
go to the pytorch official website to query the version that matches CUDA, and run the corresponding command (https: https://pytorch.org/get-started/previous-versions/)
Verify that gpu version 3 is installed
, download yolo v5
4、
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
(Comment out torch, etc.)
Problem:
AttributeError: module 'distutils' has no attribute 'version'
Solution:
https://zhuanlan.zhihu.com/p/556704117
pip install setuptools==58.0.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
https://blog.csdn.net/hjxu2016/article/details/121303818
3. Training results
As follows:
Interpretation of results:
training times, GPU consumption
bounding box loss, target detection loss, classification loss, total, targets, P, R, [email protected], [email protected]:.95, validation set val Box, validation set val obj, validation set val cls
[email protected]:.95. It is obtained by calculating a map every 0.05 from iou from 0.5 to 0.95, and finally averaging these maps.