YoLoV7 image classification/target detection process (with code + detailed operation instructions)

1. Prepare data


The images are in my_1imgs, one is the original image jpg, and the other is the label xml file drawn with labelimg. (This drawing is a rectangular box)
Copy your own data set (after the original image and labels are prepared) and these two files into VOCdevkit, and the ImageSets will be empty.


2. Modify the model training and prediction process


①Go to model_data to find the file my_classes.txt, and write your own recognition type in it.
②Open the voc_annotation.py file. You only need to modify classes_path="model_data/my_classes.txt" (that is, locate the file you just modified and modify it to your own type)
③Run the voc_annotation.py file to generate: ImageSets was empty before, but now it contains test.txt and train.txt etc.; there are also 2007_train.txt and 2007_val.txt.
Be sure to check if there is anything in these files, that is, the specific paths and names of your own images and labels. If they are empty or wrong, training will not work.
④Open the train.py file and modify the content to prepare for training. Please see the comments for specific modifications. The main things that need to be modified are:
     a. classes_path (same as above)
     b. model_path (pre-training weights, .pth file, which selects different weights according to different models. They all need to be downloaded and do not need to be written by yourself)
     c , Cuda=True or False (do you want to use cuda, don't use it if the video memory is small; if you don't have NVIDIA, you can't run on the GPU, so don't use it) d.
     Freeze_Epoch modification, usually 50, 100, 200, etc.
⑤ Run the train.py file. It will start running normally, and the corresponding weight file results will be saved in the logs folder.
⑥After training, find the best weight logs/best_epoch_weights.pth file. This is the final weight file trained and is needed for prediction.
⑦First open the yolo.py file and modify the parameters before predicting. (Corresponding to file modification) "model_path" and "classes_path" under two classes YOLO_ONNX and class YOLO need to be modified.
         "model_path" : 'logs/best_epoch_weights.pth',
         "classes_path" : 'model_data/my_classes.txt',
⑧Run yolo.py, and then run predict.py for prediction. If you follow the above, there will be no errors and you can predict normally. .
⑨Run get_map.py for objective indicator analysis. The map (F1; Recall; Precision) result map will be saved in map_out.

Code:

Link: https://pan.baidu.com/s/1tEnjGHej39BLnWsRBEMiJg 
Extraction code: t278

Description: win10+64 ​​bit, pytorch1.2.0, python3.6

The data set is not well prepared, and all training prediction results are not good.

Guess you like

Origin blog.csdn.net/m0_63172128/article/details/131981920