【Yolov7】Configuration parameters and training model

1. Download Yolov7

Github address: https://github.com/WongKinYiu/yolov7
or command line download

git clone https://github.com/WongKinYiu/yolov7.git

2. Create a new Python environment

Use Acaconda to create a clean environment. I named it yolov7. Select 3.8 for the python version.
Insert image description here
Go to the directory of the yolov7 you just downloaded and install the third-party libraries required by yolov7.
Insert image description here

3. Modify training data parameters

Open the yolov7 project, then open the data folder, and make a copy coco.yaml
. 1. Modify the paths of trian, val, and inside testto the path of our own data set;
2. Modify the number of categories according to your own needs;
3. namesModify into the name of its own category.
Insert image description here

4. Download the pre-trained model

Github address: https://github.com/WongKinYiu/yolov7/releases
Find a file of the model you want to train, create a new folder
Insert image description here
in the yolov7 project , and put the pre-trained model in it.weight
Insert image description here

5. Modify training parameters

Open it train.pyand change the following parameters according to your actual situation.

  • --weightsThe pre-trained model file you just downloaded
  • --cfgIn the folder under the yolov7 project folder cfg, select your corresponding model
    Insert image description here
  • --dataThe data file just modified
    Insert image description here

6. Start training

Excuting an order

python train.py

After training is completed, you will be prompted
Insert image description here

7. Test

python detect.py --weights runs/train/exp/weights/best.pt --conf 0.25 --img-size 640 --source testimg.png --device 0 --save-txt

Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/iiinoname/article/details/129072191