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.
Go to the directory of the yolov7 you just downloaded and install the third-party libraries required by yolov7.
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 test
to the path of our own data set;
2. Modify the number of categories according to your own needs;
3. names
Modify into the name of its own category.
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
in the yolov7 project , and put the pre-trained model in it.weight
5. Modify training parameters
Open it train.py
and change the following parameters according to your actual situation.
--weights
The pre-trained model file you just downloaded--cfg
In the folder under the yolov7 project foldercfg
, select your corresponding model
--data
The data file just modified
6. Start training
Excuting an order
python train.py
After training is completed, you will be prompted
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