yolov5-6.2 classification algorithm detailed explanation

yolov5 is a very useful target detection algorithm. With the development of deep learning, the author has subsequently updated the classification and segmentation algorithms. yolov8 even added a human body pose estimation algorithm. Today we will mainly explain the classification algorithm!

Recently, I happened to see the iFLYTEK game of HKUST, which used a classification algorithm. Thinking that yolov5 has this function, I tried it!

Official warehouse address : https://github.com/ultralytics/yolov5

Dataset operations:

Prepare the data set yourself, this is the basic knowledge. If you are not sure, you can simply learn it.

I downloaded the data set from iFlytek. There is only one training set and competition-specific test data. I need to manually divide the training set and verification set by myself.

Here I provide a small script that I made myself. I wrote it according to my own needs. It is only used for classification and should be eaten with caution.

Create a datasets folder in the same directory as the yolov5-6.2 file.

Store your own datasets  in the datasets folder . For example,  the format of my dataset folder  data is as follows

 

 Classify according to the label, and the same is true for the verification set. Because mine is used for the competition, it is not divided into the test set. The final data is uploaded to the official website of HKUST for scoring.

2) Start training

Open yolov5-3.2/classify/train.py, run in yolov5 environment.
Revise:

--model', type=str, default='yolov5x-cls.pt'
--data', type=str, default=your own data address

Modify the location of a data set and a weight file. I will attach the weight file at the end of the article. It’s a good thing to say that many bloggers on csdn even charge for this thing. Isn’t this bullying honest people?

 

insert image description here

 so it ran

If you want to test the accuracy, you are dividing a test set yourself

----------------------------------------------------------------------------------

possible bugs

AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipeli

This may be a CV2 version problem, reinstall opencv

Python calls git error

#出错原因:git环境变量设置问题
#简便解决办法:在导入包的上方增加以下代码
import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"

 Another error is that the picture cannot be found, and a bunch of format numbers are displayed. That is because of the problem of data set division. For example, there is a problem with your picture classification. There are various classification folders in the train directory, and there must also be val At least one with test, the format is the same as train

Category weights file

Link: https://pan.baidu.com/s/1U7TksPuZingHA9fmPoFqIw 
Extraction code: 0e72

 

Guess you like

Origin blog.csdn.net/weixin_45303602/article/details/130996517