🔗 https://github.com/WongKinYiu/yolor
conda create -n yolor python=3.9
conda activate yolor
cd yolor
Enter the cmd to check version.
nvidia-smi
Go through Pytorch to copy installmental command.
🔗https://pytorch.org/get-started/locally/
After that, you must make sure that your Torch can work.
Enter the cmd to make sure.
python
import torch
torch.cuda.is_available()
If it work successfully, it'll show * True *.
pip install -r requirements.txt
Scroll it until you see the title named "Testing", you'll see a link named yolor_p6.pt. Just download it!!
Because my service is Windows, not Ubuntu, we need to execute it like below.
If you master yolor, you can skip this step. The main purpose in the step is to make sure the sucess of necessiry installment.
If you don't have Git, you can download from the link.
🔗 https://git-scm.com/downloads
After you opened it, it'll like this.
Then, your yolor/scripts will full of zips, including test2017, train2017, val2017, and cco2017label.
You can move them to anywhere, but onething must make sure that their paths are same with yolor/data/coco.yaml.
Enter the command as following to test whether verything is alright.
python test.py --data data/coco.yaml --img 1280 --batch 32 --conf 0.001 --iou 0.65 --device 0 --cfg cfg/yolor_p6.cfg --weights weights/yolor_p6.pt --name yolor_p6_val
Let me show you how it's like
First, open your anaconda prompt, then enter in:
pip install labelimg
after finished, you can open it by the command:
labelimg
After the application is opend, then open the folder full of pictures.
Finally, circle the object you wanna train for detection.
You can copy if from any .cfg file and amend some variables.
Like me, i chose yolor_p6.cfg.
And considering my Ram, so justify batch, subdivision, width, height, learning_rate, max_batches, steps.
steps = (0.8 * max_batches ,0.9 * max_batches)
filters = (classes + 5) * 3 Search "[yolo]", and change the filters before "yolo", like bellowing picture shows.
It approximately in line 1569,1573,11577,1581,1605,1649,1693,1737.
It record the paths of your data handled in the last step, the number of classes, and classes' names.
⚠ Type is .yaml
Store your own classes in lines like yolov4.
⚠ Type is .names
python train.py --batch-size 4 --img 640 640 --data data/your.yaml --cfg cfg/your.cfg --epochs 300
If it break accidently, you don't need to train it from the start. Let me show you
python train.py --batch-size 4 --img 640 640 --data data/your.yaml --cfg cfg/your.cfg --weights runs/train/yolor_p6/weights/best.pt --epochs 300
After training ,your weight will store in yolor/runs/train/yolor_???
Test in Videos
python detect.py --source path/your_video--cfg cfg/your.cfg --weights runs/train/your_best.pt
Test in Images
python detect.py --source path/image/pic.jpg --cfg cfg/your.cfg --weights runs/train/your_best.pt
Besides, you can run images for not just one. In other words, the model can detect a folder full of images one time.
python detect.py --source path/img_folder --cfg cfg/your.cfg --weights runs/train/your_best.pt